提交 8438a236 authored 作者: liuhaiquan's avatar liuhaiquan

commit

上级 e5e88269
package com.clx.performance.param.pc.customer;
import com.msl.common.base.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class PageCustomerComplaintTypeParam extends PageParam {
@ApiModelProperty("名称")
private String name;
}
package com.clx.performance.param.pc.customer;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* @ClassName SaveComplaintTypeParam
* @Description
* @Author kavin
* @Date 2023/12/7 10:46
* @Version 1.0
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SaveComplaintTypeParam {
private Integer id;
@Size(min=1 ,max = 10)
@NotBlank(message = "分类名称不能为空")
@ApiModelProperty(value = "分类名称")
private String name;
}
package com.clx.performance.vo.pc.customer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* @ClassName CustomerComplaintTypeVO
* @Description
* @Author kavin
* @Date 2023/12/7 11:42
* @Version 1.0
*/
@Getter
@Setter
public class CustomerComplaintTypeVO {
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("投诉类型名称")
private String name; //投诉类型名称
@ApiModelProperty("创建时间")
private LocalDateTime createTime; //创建时间
@ApiModelProperty("最后编辑时间")
private LocalDateTime modifiedTime; //修改时间
}
package com.clx.performance.controller.pc.customer;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.pc.customer.PageCustomerComplaintTypeParam;
import com.clx.performance.param.pc.customer.SaveComplaintTypeParam;
import com.clx.performance.service.customer.CustomerComplaintTypeService;
import com.clx.performance.vo.pc.customer.CustomerComplaintTypeVO;
import com.msl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName CustomerComplaintTypeController
* @Description
* @Author kavin
* @Date 2023/12/7 10:44
* @Version 1.0
*/
@Slf4j
@RestController
@RequestMapping(value="/pc/carrier/customer/complaint")
@Validated
@Api(tags = "客服-投诉分类")
@AllArgsConstructor
public class CustomerComplaintTypeController {
private final CustomerComplaintTypeService customerComplaintTypeService;
@ApiOperation(value = "保存/更新投诉分类",notes = "<br>By:刘海泉")
@PostMapping("/pageCarrierOrderChildList")
public Result<Object> saveCustomerComplaintType(@RequestBody @Validated SaveComplaintTypeParam param){
customerComplaintTypeService.saveCustomerComplaintType(param);
return Result.ok();
}
@ApiOperation(value = "投诉分类列表",notes = "<br>By:刘海泉")
@PostMapping("/pageCustomerComplaintType")
public Result<CustomerComplaintTypeVO> pageCustomerComplaintType(@RequestBody @Validated PageCustomerComplaintTypeParam param){
IPage<CustomerComplaintTypeVO> page = customerComplaintTypeService.pageCustomerComplaintType(param);
return Result.page(page.getRecords(), page.getTotal(), page.getPages());
}
}
package com.clx.performance.dao.customer;
import com.clx.performance.mapper.customer.CustomerComplaintTypeMapper;
import com.clx.performance.model.customer.CustomerComplaintType;
import com.msl.common.dao.BaseDao;
public interface CustomerComplaintTypeDao extends BaseDao<CustomerComplaintTypeMapper, CustomerComplaintType, Integer> {
long countByNameExcludeSelf(String name, Integer id);
}
package com.clx.performance.dao.impl.customer;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.clx.performance.dao.customer.CustomerComplaintTypeDao;
import com.clx.performance.mapper.customer.CustomerComplaintTypeMapper;
import com.clx.performance.model.customer.CustomerComplaintType;
import com.msl.common.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.Objects;
/**
* @ClassName CustomerComplaintTypeDaoImpl
* @Description
* @Author kavin
* @Date 2023/12/7 11:25
* @Version 1.0
*/
@Repository
public class CustomerComplaintTypeDaoImpl extends BaseDaoImpl<CustomerComplaintTypeMapper, CustomerComplaintType, Integer> implements CustomerComplaintTypeDao {
@Override
public long countByNameExcludeSelf(String name, Integer id) {
LambdaQueryWrapper<CustomerComplaintType> query = new LambdaQueryWrapper<>();
query.eq(CustomerComplaintType :: getName,name);
if(Objects.nonNull(id)){
query.ne(CustomerComplaintType :: getId,id);
}
return baseMapper.selectCount(query);
}
}
package com.clx.performance.mapper.customer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.performance.model.customer.CustomerComplaintType;
public interface CustomerComplaintTypeMapper extends BaseMapper<CustomerComplaintType> {
}
package com.clx.performance.model.customer;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.msl.common.config.KeyColumn;
import com.msl.common.model.HasKey;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* @ClassName CustomerComplaintType
* @Description
* @Author kavin
* @Date 2023/12/7 10:54
* @Version 1.0
*/
@Getter
@Setter
@NoArgsConstructor
@TableName(autoResultMap = true)
public class CustomerComplaintType implements HasKey<Integer> {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String name; //投诉类型名称
private LocalDateTime createTime; //创建时间
private LocalDateTime modifiedTime; //修改时间
@KeyColumn("id")
@Override
public Integer gainKey() {
return id;
}
}
package com.clx.performance.service.customer;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.pc.customer.PageCustomerComplaintTypeParam;
import com.clx.performance.param.pc.customer.SaveComplaintTypeParam;
import com.clx.performance.vo.pc.customer.CustomerComplaintTypeVO;
public interface CustomerComplaintTypeService {
void saveCustomerComplaintType(SaveComplaintTypeParam param);
IPage<CustomerComplaintTypeVO> pageCustomerComplaintType(PageCustomerComplaintTypeParam param);
}
package com.clx.performance.service.customer.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.dao.customer.CustomerComplaintTypeDao;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.model.customer.CustomerComplaintType;
import com.clx.performance.param.pc.customer.PageCustomerComplaintTypeParam;
import com.clx.performance.param.pc.customer.SaveComplaintTypeParam;
import com.clx.performance.service.customer.CustomerComplaintTypeService;
import com.clx.performance.vo.pc.customer.CustomerComplaintTypeVO;
import com.msl.common.exception.ServiceSystemException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @ClassName CustomerComplaintTypeServiceImpl
* @Description
* @Author kavin
* @Date 2023/12/7 10:51
* @Version 1.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class CustomerComplaintTypeServiceImpl implements CustomerComplaintTypeService {
private final CustomerComplaintTypeDao customerComplaintTypeDao;
@Override
public void saveCustomerComplaintType(SaveComplaintTypeParam param) {
long count = customerComplaintTypeDao.countByNameExcludeSelf(param.getName(),param.getId());
if(count > 0 ){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"分类名称重复");
}
if(Objects.isNull(param.getId())){ // 新增
CustomerComplaintType insert = new CustomerComplaintType();
insert.setName(param.getName());
customerComplaintTypeDao.saveEntity(insert);
}else{ //更新
CustomerComplaintType update = new CustomerComplaintType();
update.setId(param.getId());
update.setName(param.getName());
customerComplaintTypeDao.updateEntityByKey(update);
}
}
@Override
public IPage<CustomerComplaintTypeVO> pageCustomerComplaintType(PageCustomerComplaintTypeParam param) {
return null;
}
}
package com.clx.performance.struct.customer;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.model.customer.CustomerComplaintType;
import com.clx.performance.vo.pc.customer.CustomerComplaintTypeVO;
import com.msl.common.utils.DateStructUtil;
import com.msl.common.utils.DateUtils;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
public interface CustomerComplaintTypeStruct {
Page<CustomerComplaintTypeVO> convert(IPage<CustomerComplaintType> page);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论