Showing
11 changed files
with
933 additions
and
0 deletions
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/customer/GetCustomerShortBo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.bo.customer; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | ||
| 5 | +import com.lframework.starter.web.inner.entity.SysDept; | ||
| 6 | +import com.lframework.starter.web.inner.service.system.SysDeptService; | ||
| 7 | +import com.lframework.xingyun.basedata.entity.Customer; | ||
| 8 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 9 | +import com.lframework.starter.common.constants.StringPool; | ||
| 10 | +import com.lframework.starter.web.core.bo.BaseBo; | ||
| 11 | +import java.time.LocalDateTime; | ||
| 12 | + | ||
| 13 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | ||
| 14 | +import io.swagger.annotations.ApiModelProperty; | ||
| 15 | + | ||
| 16 | +import lombok.Data; | ||
| 17 | +import org.apache.commons.lang3.StringUtils; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * <p> | ||
| 21 | + * 客户简称 GetBo | ||
| 22 | + * </p> | ||
| 23 | + * | ||
| 24 | + */ | ||
| 25 | +@Data | ||
| 26 | +public class GetCustomerShortBo extends BaseBo<CustomerShort> { | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * ID | ||
| 30 | + */ | ||
| 31 | + @ApiModelProperty("ID") | ||
| 32 | + private String id; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 客户简称 | ||
| 36 | + */ | ||
| 37 | + @ApiModelProperty("客户简称") | ||
| 38 | + private String shortName; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 客户ID | ||
| 42 | + */ | ||
| 43 | + @ApiModelProperty("客户ID") | ||
| 44 | + private String customerId; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 客户名称 | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty("客户名称") | ||
| 50 | + private String customerName; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 客户类型 | ||
| 54 | + */ | ||
| 55 | + @ApiModelProperty("客户类型") | ||
| 56 | + private String type; | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 办事处ID | ||
| 60 | + */ | ||
| 61 | + @ApiModelProperty("办事处ID") | ||
| 62 | + private String deptId; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 办事处名称 | ||
| 66 | + */ | ||
| 67 | + @ApiModelProperty("办事处名称") | ||
| 68 | + private String deptName; | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 区域ID | ||
| 72 | + */ | ||
| 73 | + @ApiModelProperty("区域ID") | ||
| 74 | + private String region; | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 区域名称 | ||
| 78 | + */ | ||
| 79 | + @ApiModelProperty("区域名称") | ||
| 80 | + private String regionName; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 创建人ID | ||
| 84 | + */ | ||
| 85 | + @ApiModelProperty("创建人ID") | ||
| 86 | + private String createById; | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 更新人ID | ||
| 90 | + */ | ||
| 91 | + @ApiModelProperty("更新人ID") | ||
| 92 | + private String updateById; | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 创建时间 | ||
| 96 | + */ | ||
| 97 | + @ApiModelProperty("创建时间") | ||
| 98 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 99 | + private LocalDateTime createTime; | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 更新时间 | ||
| 103 | + */ | ||
| 104 | + @ApiModelProperty("更新时间") | ||
| 105 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 106 | + private LocalDateTime updateTime; | ||
| 107 | + | ||
| 108 | + public GetCustomerShortBo() { | ||
| 109 | + | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public GetCustomerShortBo(CustomerShort dto) { | ||
| 113 | + | ||
| 114 | + super(dto); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @Override | ||
| 118 | + public BaseBo<CustomerShort> convert(CustomerShort dto) { | ||
| 119 | + return super.convert(dto); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + @Override | ||
| 123 | + protected void afterInit(CustomerShort dto) { | ||
| 124 | + if (StringUtils.isNotBlank(dto.getCustomerId())) { | ||
| 125 | + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); | ||
| 126 | + Customer customer = customerService.findById(dto.getCustomerId()); | ||
| 127 | + this.customerName = customer == null ? null : customer.getName(); | ||
| 128 | + } | ||
| 129 | + SysDeptService deptService = ApplicationUtil.getBean(SysDeptService.class); | ||
| 130 | + if (StringUtils.isNotBlank(dto.getDeptId())) { | ||
| 131 | + SysDept dept = deptService.findById(dto.getDeptId()); | ||
| 132 | + this.deptName = dept == null ? null : dept.getName(); | ||
| 133 | + } | ||
| 134 | + if (StringUtils.isNotBlank(dto.getRegion())) { | ||
| 135 | + SysDept dept = deptService.findById(dto.getRegion()); | ||
| 136 | + this.regionName = dept == null ? null : dept.getName(); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | +} |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/customer/QueryCustomerShortBo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.bo.customer; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 5 | +import com.lframework.starter.common.constants.StringPool; | ||
| 6 | +import com.lframework.starter.web.core.bo.BaseBo; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import io.swagger.annotations.ApiModelProperty; | ||
| 10 | + | ||
| 11 | +import lombok.Data; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * <p> | ||
| 15 | + * 客户简称 QueryBo | ||
| 16 | + * </p> | ||
| 17 | + * | ||
| 18 | + */ | ||
| 19 | +@Data | ||
| 20 | +public class QueryCustomerShortBo extends BaseBo<CustomerShort> { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * ID | ||
| 24 | + */ | ||
| 25 | + @ApiModelProperty("ID") | ||
| 26 | + private String id; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 客户简称 | ||
| 30 | + */ | ||
| 31 | + @ApiModelProperty("客户简称") | ||
| 32 | + private String shortName; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 客户ID | ||
| 36 | + */ | ||
| 37 | + @ApiModelProperty("客户ID") | ||
| 38 | + private String customerId; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 客户名称 | ||
| 42 | + */ | ||
| 43 | + @ApiModelProperty("客户名称") | ||
| 44 | + private String customerName; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 客户类型 | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty("客户类型") | ||
| 50 | + private String type; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 办事处ID | ||
| 54 | + */ | ||
| 55 | + @ApiModelProperty("办事处ID") | ||
| 56 | + private String deptId; | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 办事处名称 | ||
| 60 | + */ | ||
| 61 | + @ApiModelProperty("办事处名称") | ||
| 62 | + private String deptName; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 区域ID | ||
| 66 | + */ | ||
| 67 | + @ApiModelProperty("区域ID") | ||
| 68 | + private String region; | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 区域名称 | ||
| 72 | + */ | ||
| 73 | + @ApiModelProperty("区域名称") | ||
| 74 | + private String regionName; | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 创建人ID | ||
| 78 | + */ | ||
| 79 | + @ApiModelProperty("创建人ID") | ||
| 80 | + private String createById; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 更新人ID | ||
| 84 | + */ | ||
| 85 | + @ApiModelProperty("更新人ID") | ||
| 86 | + private String updateById; | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 创建时间 | ||
| 90 | + */ | ||
| 91 | + @ApiModelProperty("创建时间") | ||
| 92 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 93 | + private LocalDateTime createTime; | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * 更新时间 | ||
| 97 | + */ | ||
| 98 | + @ApiModelProperty("更新时间") | ||
| 99 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 100 | + private LocalDateTime updateTime; | ||
| 101 | + | ||
| 102 | + public QueryCustomerShortBo() { | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + public QueryCustomerShortBo(CustomerShort dto) { | ||
| 107 | + | ||
| 108 | + super(dto); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public BaseBo<CustomerShort> convert(CustomerShort dto) { | ||
| 113 | + return super.convert(dto); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + protected void afterInit(CustomerShort dto) { | ||
| 118 | + | ||
| 119 | + } | ||
| 120 | +} |
| 1 | +package com.lframework.xingyun.basedata.controller; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | ||
| 4 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | ||
| 5 | +import com.lframework.xingyun.basedata.bo.customer.GetCustomerShortBo; | ||
| 6 | +import com.lframework.xingyun.basedata.bo.customer.QueryCustomerShortBo; | ||
| 7 | +import com.lframework.xingyun.basedata.vo.customer.QueryCustomerShortVo; | ||
| 8 | +import com.lframework.xingyun.basedata.service.customer.CustomerShortService; | ||
| 9 | +import com.lframework.xingyun.basedata.vo.customer.CreateCustomerShortVo; | ||
| 10 | +import com.lframework.xingyun.basedata.vo.customer.UpdateCustomerShortVo; | ||
| 11 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 12 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 13 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 14 | +import com.lframework.starter.web.core.components.resp.InvokeResult; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import javax.validation.constraints.NotBlank; | ||
| 18 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 19 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | ||
| 20 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 21 | +import io.swagger.annotations.ApiOperation; | ||
| 22 | +import com.lframework.starter.common.utils.CollectionUtil; | ||
| 23 | +import io.swagger.annotations.Api; | ||
| 24 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 25 | +import org.springframework.validation.annotation.Validated; | ||
| 26 | +import org.springframework.web.bind.annotation.*; | ||
| 27 | + | ||
| 28 | +import javax.validation.Valid; | ||
| 29 | +import java.util.List; | ||
| 30 | +import java.util.stream.Collectors; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * 客户简称 Controller | ||
| 34 | + * | ||
| 35 | + */ | ||
| 36 | +@Api(tags = "客户简称") | ||
| 37 | +@Validated | ||
| 38 | +@RestController | ||
| 39 | +@RequestMapping("/customer/short") | ||
| 40 | +public class CustomerShortController extends DefaultBaseController { | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + @Resource | ||
| 45 | + private CustomerShortService customerShortService; | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 查询列表 | ||
| 51 | + */ | ||
| 52 | + @ApiOperation("查询列表") | ||
| 53 | + @HasPermission({"customer:customer:query"}) | ||
| 54 | + @GetMapping("/query") | ||
| 55 | + public InvokeResult<PageResult<QueryCustomerShortBo>> query(@Valid QueryCustomerShortVo vo) { | ||
| 56 | + PageResult<CustomerShort> pageResult = customerShortService.query(getPageIndex(vo), getPageSize(vo), vo); | ||
| 57 | + List<CustomerShort> dataList = pageResult.getDatas(); | ||
| 58 | + List<QueryCustomerShortBo> results = null; | ||
| 59 | + if (!CollectionUtil.isEmpty(dataList)) { | ||
| 60 | + results = dataList.stream().map(QueryCustomerShortBo::new).collect(Collectors.toList()); | ||
| 61 | + } | ||
| 62 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 根据ID查询 | ||
| 67 | + */ | ||
| 68 | + @ApiOperation("根据ID查询") | ||
| 69 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 70 | + @HasPermission({"customer:customer:query"}) | ||
| 71 | + @GetMapping | ||
| 72 | + public InvokeResult<GetCustomerShortBo> get(@NotBlank(message = "id不能为空!") String id) { | ||
| 73 | + CustomerShort data = customerShortService.findById(id); | ||
| 74 | + if (data == null) { | ||
| 75 | + throw new DefaultClientException("客户简称不存在!"); | ||
| 76 | + } | ||
| 77 | + GetCustomerShortBo result = new GetCustomerShortBo(data); | ||
| 78 | + | ||
| 79 | + return InvokeResultBuilder.success(result); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 新增 | ||
| 84 | + */ | ||
| 85 | + @ApiOperation("新增") | ||
| 86 | + @HasPermission({"customer:customer:add"}) | ||
| 87 | + @PostMapping | ||
| 88 | + public InvokeResult<Void> create(@Valid CreateCustomerShortVo vo) { | ||
| 89 | + customerShortService.create(vo); | ||
| 90 | + return InvokeResultBuilder.success(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 修改 | ||
| 95 | + */ | ||
| 96 | + @ApiOperation("修改") | ||
| 97 | + @HasPermission({"customer:customer:modify"}) | ||
| 98 | + @PutMapping | ||
| 99 | + public InvokeResult<Void> update(@Valid UpdateCustomerShortVo vo) { | ||
| 100 | + customerShortService.update(vo); | ||
| 101 | + return InvokeResultBuilder.success(); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * 根据ID删除 | ||
| 106 | + */ | ||
| 107 | + @ApiOperation("根据ID删除") | ||
| 108 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 109 | + @HasPermission({"customer:customer:delete"}) | ||
| 110 | + @DeleteMapping | ||
| 111 | + public InvokeResult<Void> deleteById(@NotBlank(message = "id不能为空!") String id) { | ||
| 112 | + customerShortService.deleteById(id); | ||
| 113 | + return InvokeResultBuilder.success(); | ||
| 114 | + } | ||
| 115 | +} |
| 1 | +package com.lframework.xingyun.basedata.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 4 | +import com.lframework.starter.web.core.dto.BaseDto; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.FieldFill; | ||
| 7 | +import com.lframework.starter.web.core.entity.BaseEntity; | ||
| 8 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 9 | +import lombok.Data; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * <p> | ||
| 13 | + * 客户简称 | ||
| 14 | + * </p> | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +@TableName("base_data_customer_short") | ||
| 19 | +public class CustomerShort extends BaseEntity implements BaseDto { | ||
| 20 | + | ||
| 21 | + private static final long serialVersionUID = 1L; | ||
| 22 | + | ||
| 23 | + public static final String CACHE_NAME = "CustomerShort"; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * ID | ||
| 27 | + */ | ||
| 28 | + private String id; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 客户简称 | ||
| 32 | + */ | ||
| 33 | + private String shortName; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 客户ID | ||
| 37 | + */ | ||
| 38 | + private String customerId; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 客户名称 | ||
| 42 | + */ | ||
| 43 | + @TableField(exist = false) | ||
| 44 | + private String customerName; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 客户类型 | ||
| 48 | + */ | ||
| 49 | + private String type; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 办事处ID | ||
| 53 | + */ | ||
| 54 | + private String deptId; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 办事处名称 | ||
| 58 | + */ | ||
| 59 | + @TableField(exist = false) | ||
| 60 | + private String deptName; | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 区域ID | ||
| 64 | + */ | ||
| 65 | + private String region; | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 区域名称 | ||
| 69 | + */ | ||
| 70 | + @TableField(exist = false) | ||
| 71 | + private String regionName; | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 创建人ID | ||
| 75 | + */ | ||
| 76 | + @TableField(fill = FieldFill.INSERT) | ||
| 77 | + private String createById; | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 更新人ID | ||
| 81 | + */ | ||
| 82 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 83 | + private String updateById; | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 创建时间 | ||
| 87 | + */ | ||
| 88 | + @TableField(fill = FieldFill.INSERT) | ||
| 89 | + private LocalDateTime createTime; | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 更新时间 | ||
| 93 | + */ | ||
| 94 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 95 | + private LocalDateTime updateTime; | ||
| 96 | + | ||
| 97 | +} |
| 1 | +package com.lframework.xingyun.basedata.impl.customer; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 6 | +import com.github.pagehelper.PageInfo; | ||
| 7 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 8 | +import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | ||
| 9 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 10 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 11 | +import com.lframework.starter.web.core.utils.OpLogUtil; | ||
| 12 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 13 | +import com.lframework.starter.web.core.utils.IdUtil; | ||
| 14 | +import com.lframework.starter.common.utils.ObjectUtil; | ||
| 15 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | ||
| 16 | +import com.lframework.starter.web.core.utils.PageHelperUtil; | ||
| 17 | +import com.lframework.starter.common.utils.Assert; | ||
| 18 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | ||
| 19 | +import org.apache.commons.lang3.StringUtils; | ||
| 20 | +import org.springframework.transaction.annotation.Transactional; | ||
| 21 | +import com.lframework.xingyun.basedata.mappers.CustomerShortMapper; | ||
| 22 | +import com.lframework.xingyun.basedata.service.customer.CustomerShortService; | ||
| 23 | +import com.lframework.xingyun.basedata.vo.customer.CreateCustomerShortVo; | ||
| 24 | +import com.lframework.xingyun.basedata.vo.customer.QueryCustomerShortVo; | ||
| 25 | +import com.lframework.xingyun.basedata.vo.customer.UpdateCustomerShortVo; | ||
| 26 | +import org.springframework.stereotype.Service; | ||
| 27 | + | ||
| 28 | +import java.util.List; | ||
| 29 | + | ||
| 30 | +@Service | ||
| 31 | +public class CustomerShortServiceImpl extends BaseMpServiceImpl<CustomerShortMapper, CustomerShort> implements CustomerShortService { | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public PageResult<CustomerShort> query(Integer pageIndex, Integer pageSize, QueryCustomerShortVo vo) { | ||
| 37 | + Assert.greaterThanZero(pageIndex); | ||
| 38 | + Assert.greaterThanZero(pageSize); | ||
| 39 | + | ||
| 40 | + PageHelperUtil.startPage(pageIndex, pageSize); | ||
| 41 | + List<CustomerShort> dataList = this.query(vo); | ||
| 42 | + | ||
| 43 | + return PageResultUtil.convert(new PageInfo<>(dataList)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public List<CustomerShort> query(QueryCustomerShortVo vo) { | ||
| 48 | + return getBaseMapper().query(vo); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public CustomerShort findById(String id) { | ||
| 53 | + return getBaseMapper().selectById(id); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @OpLog(type = OtherOpLogType.class, name = "新增客户简称,ID:{}", params = {"#id"}) | ||
| 57 | + @Transactional(rollbackFor = Exception.class) | ||
| 58 | + @Override | ||
| 59 | + public String create(CreateCustomerShortVo vo) { | ||
| 60 | + // 数据校验 | ||
| 61 | + CustomerShort customerShort = getByCustomerId(vo.getCustomerId()); | ||
| 62 | + if (customerShort != null) { | ||
| 63 | + throw new DefaultClientException("当前客户已存在简称,请勿重复添加!"); | ||
| 64 | + } | ||
| 65 | + CustomerShort data = new CustomerShort(); | ||
| 66 | + data.setId(IdUtil.getId()); | ||
| 67 | + data.setShortName(vo.getShortName()); | ||
| 68 | + data.setCustomerId(vo.getCustomerId()); | ||
| 69 | + data.setType(vo.getType()); | ||
| 70 | + data.setDeptId(vo.getDeptId()); | ||
| 71 | + data.setRegion(vo.getRegion()); | ||
| 72 | + | ||
| 73 | + getBaseMapper().insert(data); | ||
| 74 | + | ||
| 75 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 76 | + OpLogUtil.setExtra(vo); | ||
| 77 | + | ||
| 78 | + return data.getId(); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @OpLog(type = OtherOpLogType.class, name = "修改客户简称,ID:{}", params = {"#id"}) | ||
| 82 | + @Transactional(rollbackFor = Exception.class) | ||
| 83 | + @Override | ||
| 84 | + public void update(UpdateCustomerShortVo vo) { | ||
| 85 | + CustomerShort data = getBaseMapper().selectById(vo.getId()); | ||
| 86 | + if (ObjectUtil.isNull(data)) { | ||
| 87 | + throw new DefaultClientException("客户简称不存在!"); | ||
| 88 | + } | ||
| 89 | + // 数据校验 | ||
| 90 | + CustomerShort customerShort = getByCustomerId(vo.getCustomerId()); | ||
| 91 | + if (customerShort != null && !vo.getId().equals(customerShort.getId())) { | ||
| 92 | + throw new DefaultClientException("当前客户已存在简称,请勿重复添加!"); | ||
| 93 | + } | ||
| 94 | + LambdaUpdateWrapper<CustomerShort> updateWrapper = Wrappers.lambdaUpdate(CustomerShort.class) | ||
| 95 | + .set(CustomerShort::getShortName, vo.getShortName()) | ||
| 96 | + .set(CustomerShort::getCustomerId, vo.getCustomerId()) | ||
| 97 | + .set(CustomerShort::getType, vo.getType()) | ||
| 98 | + .set(CustomerShort::getDeptId, vo.getDeptId()) | ||
| 99 | + .set(CustomerShort::getRegion, vo.getRegion()) | ||
| 100 | + .eq(CustomerShort::getId, vo.getId()); | ||
| 101 | + getBaseMapper().update(updateWrapper); | ||
| 102 | + | ||
| 103 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 104 | + OpLogUtil.setExtra(vo); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @OpLog(type = OtherOpLogType.class, name = "删除客户简称,ID:{}", params = {"#id"}) | ||
| 108 | + @Transactional(rollbackFor = Exception.class) | ||
| 109 | + @Override | ||
| 110 | + public void deleteById(String id) { | ||
| 111 | + // todo 已被使用的数据不允许删除 | ||
| 112 | + getBaseMapper().deleteById(id); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 116 | + public CustomerShort getByCustomerId(String customerId) { | ||
| 117 | + if (StringUtils.isBlank(customerId)) { | ||
| 118 | + return null; | ||
| 119 | + } | ||
| 120 | + LambdaQueryWrapper<CustomerShort> queryWrapper = Wrappers.lambdaQuery(CustomerShort.class); | ||
| 121 | + queryWrapper.eq(CustomerShort::getCustomerId, customerId); | ||
| 122 | + | ||
| 123 | + return getBaseMapper().selectOne(queryWrapper); | ||
| 124 | + } | ||
| 125 | +} |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/mappers/CustomerShortMapper.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.mappers; | ||
| 2 | + | ||
| 3 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 4 | +import com.lframework.starter.web.core.mapper.BaseMapper; | ||
| 5 | +import com.lframework.xingyun.basedata.vo.customer.QueryCustomerShortVo; | ||
| 6 | +import org.apache.ibatis.annotations.Param; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * <p> | ||
| 12 | + * 客户简称 Mapper 接口 | ||
| 13 | + * </p> | ||
| 14 | + * | ||
| 15 | + */ | ||
| 16 | +public interface CustomerShortMapper extends BaseMapper<CustomerShort> { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 查询列表 | ||
| 20 | + * | ||
| 21 | + * @param vo 查询条件 | ||
| 22 | + * @return List<CustomerShort> | ||
| 23 | + */ | ||
| 24 | + List<CustomerShort> query(@Param("vo") QueryCustomerShortVo vo); | ||
| 25 | +} |
| 1 | +package com.lframework.xingyun.basedata.service.customer; | ||
| 2 | + | ||
| 3 | +import com.lframework.xingyun.basedata.vo.customer.CreateCustomerShortVo; | ||
| 4 | +import com.lframework.xingyun.basedata.vo.customer.QueryCustomerShortVo; | ||
| 5 | +import com.lframework.xingyun.basedata.vo.customer.UpdateCustomerShortVo; | ||
| 6 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | ||
| 7 | +import com.lframework.starter.web.core.service.BaseMpService; | ||
| 8 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 客户简称 Service | ||
| 13 | + */ | ||
| 14 | +public interface CustomerShortService extends BaseMpService<CustomerShort> { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 查询列表 | ||
| 18 | + * | ||
| 19 | + * @return PageResult<CustomerShort> | ||
| 20 | + */ | ||
| 21 | + PageResult<CustomerShort> query(Integer pageIndex, Integer pageSize, QueryCustomerShortVo vo); | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 查询列表 | ||
| 25 | + * | ||
| 26 | + * @param vo 查询条件 | ||
| 27 | + * @return List<CustomerShort> | ||
| 28 | + */ | ||
| 29 | + List<CustomerShort> query(QueryCustomerShortVo vo); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 根据ID查询 | ||
| 33 | + * | ||
| 34 | + * @param id 主键ID | ||
| 35 | + * @return CustomerShort | ||
| 36 | + */ | ||
| 37 | + CustomerShort findById(String id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 创建 | ||
| 41 | + * | ||
| 42 | + * @param vo 数据实体 | ||
| 43 | + * @return String | ||
| 44 | + */ | ||
| 45 | + String create(CreateCustomerShortVo vo); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 修改 | ||
| 49 | + * | ||
| 50 | + * @param vo 数据实体 | ||
| 51 | + */ | ||
| 52 | + void update(UpdateCustomerShortVo vo); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 根据ID删除 | ||
| 56 | + * | ||
| 57 | + * @param id 主键ID | ||
| 58 | + */ | ||
| 59 | + void deleteById(String id); | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 根据客户ID获取客户简称 | ||
| 63 | + * | ||
| 64 | + * @param customerId 客户ID | ||
| 65 | + * @return CustomerShort | ||
| 66 | + */ | ||
| 67 | + CustomerShort getByCustomerId(String customerId); | ||
| 68 | +} |
| 1 | +package com.lframework.xingyun.basedata.vo.customer; | ||
| 2 | + | ||
| 3 | +import javax.validation.constraints.NotBlank; | ||
| 4 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import org.hibernate.validator.constraints.Length; | ||
| 7 | +import java.io.Serializable; | ||
| 8 | +import lombok.Data; | ||
| 9 | + | ||
| 10 | +@Data | ||
| 11 | +public class CreateCustomerShortVo implements BaseVo, Serializable { | ||
| 12 | + | ||
| 13 | + private static final long serialVersionUID = 1L; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 客户简称 | ||
| 17 | + */ | ||
| 18 | + @ApiModelProperty(value = "客户简称", required = true) | ||
| 19 | + @NotBlank(message = "请输入客户简称!") | ||
| 20 | + @Length(message = "客户简称最多允许50个字符!") | ||
| 21 | + private String shortName; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 客户ID | ||
| 25 | + */ | ||
| 26 | + @ApiModelProperty(value = "客户ID", required = true) | ||
| 27 | + @NotBlank(message = "请输入客户ID!") | ||
| 28 | + @Length(message = "客户ID最多允许32个字符!") | ||
| 29 | + private String customerId; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 客户类型 | ||
| 33 | + */ | ||
| 34 | + @ApiModelProperty(value = "客户类型", required = true) | ||
| 35 | + @NotBlank(message = "请输入客户类型!") | ||
| 36 | + @Length(message = "客户类型最多允许20个字符!") | ||
| 37 | + private String type; | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 办事处ID | ||
| 41 | + */ | ||
| 42 | + @ApiModelProperty(value = "办事处ID", required = true) | ||
| 43 | + @NotBlank(message = "请输入办事处ID!") | ||
| 44 | + @Length(message = "办事处ID最多允许32个字符!") | ||
| 45 | + private String deptId; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 区域ID | ||
| 49 | + */ | ||
| 50 | + @ApiModelProperty(value = "区域ID", required = true) | ||
| 51 | + @NotBlank(message = "请输入区域ID!") | ||
| 52 | + @Length(message = "区域ID最多允许32个字符!") | ||
| 53 | + private String region; | ||
| 54 | +} |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/vo/customer/QueryCustomerShortVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.vo.customer; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | +import com.lframework.starter.web.core.vo.PageVo; | ||
| 5 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import java.io.Serializable; | ||
| 8 | + | ||
| 9 | +@Data | ||
| 10 | +public class QueryCustomerShortVo extends PageVo implements BaseVo, Serializable { | ||
| 11 | + | ||
| 12 | + private static final long serialVersionUID = 1L; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 客户简称 | ||
| 16 | + */ | ||
| 17 | + @ApiModelProperty("客户简称") | ||
| 18 | + private String shortName; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 客户ID | ||
| 22 | + */ | ||
| 23 | + @ApiModelProperty("客户ID") | ||
| 24 | + private String customerId; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 客户名称 | ||
| 28 | + */ | ||
| 29 | + @ApiModelProperty("客户名称") | ||
| 30 | + private String customerName; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 客户类型 | ||
| 34 | + */ | ||
| 35 | + @ApiModelProperty("客户类型") | ||
| 36 | + private String type; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 办事处ID | ||
| 40 | + */ | ||
| 41 | + @ApiModelProperty("办事处ID") | ||
| 42 | + private String deptId; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 办事处名称 | ||
| 46 | + */ | ||
| 47 | + @ApiModelProperty("办事处名称") | ||
| 48 | + private String deptName; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 区域ID | ||
| 52 | + */ | ||
| 53 | + @ApiModelProperty("区域ID") | ||
| 54 | + private String region; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 区域名称 | ||
| 58 | + */ | ||
| 59 | + @ApiModelProperty("区域名称") | ||
| 60 | + private String regionName; | ||
| 61 | +} |
| 1 | +package com.lframework.xingyun.basedata.vo.customer; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | +import javax.validation.constraints.NotBlank; | ||
| 5 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import org.hibernate.validator.constraints.Length; | ||
| 8 | +import java.io.Serializable; | ||
| 9 | + | ||
| 10 | +@Data | ||
| 11 | +public class UpdateCustomerShortVo implements BaseVo, Serializable { | ||
| 12 | + | ||
| 13 | + private static final long serialVersionUID = 1L; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * ID | ||
| 17 | + */ | ||
| 18 | + @ApiModelProperty(value = "ID", required = true) | ||
| 19 | + @NotBlank(message = "id不能为空!") | ||
| 20 | + private String id; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 客户简称 | ||
| 24 | + */ | ||
| 25 | + @ApiModelProperty(value = "客户简称", required = true) | ||
| 26 | + @NotBlank(message = "请输入客户简称!") | ||
| 27 | + @Length(message = "客户简称最多允许50个字符!") | ||
| 28 | + private String shortName; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 客户ID | ||
| 32 | + */ | ||
| 33 | + @ApiModelProperty(value = "客户ID", required = true) | ||
| 34 | + @NotBlank(message = "请输入客户ID!") | ||
| 35 | + @Length(message = "客户ID最多允许32个字符!") | ||
| 36 | + private String customerId; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 客户类型 | ||
| 40 | + */ | ||
| 41 | + @ApiModelProperty(value = "客户类型", required = true) | ||
| 42 | + @NotBlank(message = "请输入客户类型!") | ||
| 43 | + @Length(message = "客户类型最多允许20个字符!") | ||
| 44 | + private String type; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 办事处ID | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty(value = "办事处ID", required = true) | ||
| 50 | + @NotBlank(message = "请输入办事处ID!") | ||
| 51 | + @Length(message = "办事处ID最多允许32个字符!") | ||
| 52 | + private String deptId; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 区域ID | ||
| 56 | + */ | ||
| 57 | + @ApiModelProperty(value = "区域ID", required = true) | ||
| 58 | + @NotBlank(message = "请输入区域ID!") | ||
| 59 | + @Length(message = "区域ID最多允许32个字符!") | ||
| 60 | + private String region; | ||
| 61 | +} |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="com.lframework.xingyun.basedata.mappers.CustomerShortMapper"> | ||
| 4 | + | ||
| 5 | + <resultMap id="CustomerShort" type="com.lframework.xingyun.basedata.entity.CustomerShort"> | ||
| 6 | + <id column="id" property="id"/> | ||
| 7 | + <result column="short_name" property="shortName"/> | ||
| 8 | + <result column="customer_id" property="customerId"/> | ||
| 9 | + <result column="customer_name" property="customerName"/> | ||
| 10 | + <result column="type" property="type"/> | ||
| 11 | + <result column="dept_id" property="deptId"/> | ||
| 12 | + <result column="dept_name" property="deptName"/> | ||
| 13 | + <result column="region" property="region"/> | ||
| 14 | + <result column="region_name" property="regionName"/> | ||
| 15 | + <result column="create_by_id" property="createById"/> | ||
| 16 | + <result column="update_by_id" property="updateById"/> | ||
| 17 | + <result column="create_time" property="createTime"/> | ||
| 18 | + <result column="update_time" property="updateTime"/> | ||
| 19 | + </resultMap> | ||
| 20 | + | ||
| 21 | + <sql id="CustomerShort_sql"> | ||
| 22 | + SELECT | ||
| 23 | + tb.id, | ||
| 24 | + tb.short_name, | ||
| 25 | + tb.customer_id, | ||
| 26 | + c.name as customer_name, | ||
| 27 | + tb.type, | ||
| 28 | + tb.dept_id, | ||
| 29 | + d.name as dept_name, | ||
| 30 | + tb.region, | ||
| 31 | + r.name as region_name, | ||
| 32 | + tb.create_by_id, | ||
| 33 | + tb.update_by_id, | ||
| 34 | + tb.create_time, | ||
| 35 | + tb.update_time | ||
| 36 | + FROM base_data_customer_short AS tb | ||
| 37 | + LEFT JOIN base_data_customer c ON tb.customer_id = c.id | ||
| 38 | + LEFT JOIN sys_dept d ON tb.dept_id = d.id | ||
| 39 | + LEFT JOIN sys_dept r ON tb.region = r.id | ||
| 40 | + </sql> | ||
| 41 | + | ||
| 42 | + <select id="query" resultMap="CustomerShort"> | ||
| 43 | + <include refid="CustomerShort_sql"/> | ||
| 44 | + <where> | ||
| 45 | + <if test="vo.customerId != null and vo.customerId != ''"> | ||
| 46 | + AND tb.customer_id = #{vo.customerId} | ||
| 47 | + </if> | ||
| 48 | + <if test="vo.type != null and vo.type != ''"> | ||
| 49 | + AND tb.type = #{vo.type} | ||
| 50 | + </if> | ||
| 51 | + <if test="vo.deptId != null and vo.deptId != ''"> | ||
| 52 | + AND tb.dept_id = #{vo.deptId} | ||
| 53 | + </if> | ||
| 54 | + <if test="vo.region != null and vo.region != ''"> | ||
| 55 | + AND tb.region = #{vo.region} | ||
| 56 | + </if> | ||
| 57 | + <if test="vo.customerName != null and vo.customerName != ''"> | ||
| 58 | + AND c.name LIKE CONCAT('%', #{vo.customerName}, '%') | ||
| 59 | + </if> | ||
| 60 | + <if test="vo.shortName != null and vo.shortName != ''"> | ||
| 61 | + AND tb.short_name LIKE CONCAT('%', #{vo.shortName}, '%') | ||
| 62 | + </if> | ||
| 63 | + <if test="vo.deptName != null and vo.deptName != ''"> | ||
| 64 | + AND d.name LIKE CONCAT('%', #{vo.deptName}, '%') | ||
| 65 | + </if> | ||
| 66 | + </where> | ||
| 67 | + </select> | ||
| 68 | +</mapper> |