CRM:【线索】使用BeanUtils替换mapstruct

This commit is contained in:
min 2024-01-10 00:38:23 +08:00
parent 99b8465e29
commit 0ee7fedea8
3 changed files with 6 additions and 22 deletions

View File

@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
import io.swagger.v3.oas.annotations.Operation;
@ -65,7 +65,7 @@ public class CrmClueController {
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
public CommonResult<CrmClueRespVO> getClue(@RequestParam("id") Long id) {
CrmClueDO clue = clueService.getClue(id);
return success(CrmClueConvert.INSTANCE.convert(clue));
return success(BeanUtils.toBean(clue, CrmClueRespVO.class));
}
@GetMapping("/page")
@ -73,7 +73,7 @@ public class CrmClueController {
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) {
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId());
return success(CrmClueConvert.INSTANCE.convertPage(pageResult));
return success(BeanUtils.toBean(pageResult, CrmClueRespVO.class));
}
@GetMapping("/export-excel")
@ -84,7 +84,7 @@ public class CrmClueController {
pageReqVO.setPageSize(PAGE_SIZE_NONE);
List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList();
// 导出 Excel
List<CrmClueExcelVO> datas = CrmClueConvert.INSTANCE.convertList02(list);
List<CrmClueExcelVO> datas = BeanUtils.toBean(list, CrmClueExcelVO.class);
ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas);
}

View File

@ -1,18 +1,11 @@
package cn.iocoder.yudao.module.crm.convert.clue;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExcelVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 线索 Convert
*
@ -23,15 +16,6 @@ public interface CrmClueConvert {
CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class);
// TODO @min这几个 convert都使用 BeanUtils 替代哈
CrmClueDO convert(CrmClueSaveReqVO bean);
CrmClueRespVO convert(CrmClueDO bean);
PageResult<CrmClueRespVO> convertPage(PageResult<CrmClueDO> page);
List<CrmClueExcelVO> convertList02(List<CrmClueDO> list);
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmClueTransferReqVO reqVO, Long userId);

View File

@ -60,7 +60,7 @@ public class CrmClueServiceImpl implements CrmClueService {
validateRelationDataExists(createReqVO);
// 插入
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class);
clueMapper.insert(clue);
// 返回
return clue.getId();
@ -75,7 +75,7 @@ public class CrmClueServiceImpl implements CrmClueService {
validateRelationDataExists(updateReqVO);
// 更新
CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO);
CrmClueDO updateObj = BeanUtils.toBean(updateReqVO, CrmClueDO.class);
clueMapper.updateById(updateObj);
}