Commit 0ee7fedea8387e2ea82312f94ba4710e35799e7b
1 parent
99b8465e
CRM:【线索】使用BeanUtils替换mapstruct
Showing
3 changed files
with
6 additions
and
22 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java
| @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue; | @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; |
| 8 | -import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; | ||
| 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 10 | import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; | 10 | import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; |
| 11 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| @@ -65,7 +65,7 @@ public class CrmClueController { | @@ -65,7 +65,7 @@ public class CrmClueController { | ||
| 65 | @PreAuthorize("@ss.hasPermission('crm:clue:query')") | 65 | @PreAuthorize("@ss.hasPermission('crm:clue:query')") |
| 66 | public CommonResult<CrmClueRespVO> getClue(@RequestParam("id") Long id) { | 66 | public CommonResult<CrmClueRespVO> getClue(@RequestParam("id") Long id) { |
| 67 | CrmClueDO clue = clueService.getClue(id); | 67 | CrmClueDO clue = clueService.getClue(id); |
| 68 | - return success(CrmClueConvert.INSTANCE.convert(clue)); | 68 | + return success(BeanUtils.toBean(clue, CrmClueRespVO.class)); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | @GetMapping("/page") | 71 | @GetMapping("/page") |
| @@ -73,7 +73,7 @@ public class CrmClueController { | @@ -73,7 +73,7 @@ public class CrmClueController { | ||
| 73 | @PreAuthorize("@ss.hasPermission('crm:clue:query')") | 73 | @PreAuthorize("@ss.hasPermission('crm:clue:query')") |
| 74 | public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) { | 74 | public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) { |
| 75 | PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId()); | 75 | PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId()); |
| 76 | - return success(CrmClueConvert.INSTANCE.convertPage(pageResult)); | 76 | + return success(BeanUtils.toBean(pageResult, CrmClueRespVO.class)); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | @GetMapping("/export-excel") | 79 | @GetMapping("/export-excel") |
| @@ -84,7 +84,7 @@ public class CrmClueController { | @@ -84,7 +84,7 @@ public class CrmClueController { | ||
| 84 | pageReqVO.setPageSize(PAGE_SIZE_NONE); | 84 | pageReqVO.setPageSize(PAGE_SIZE_NONE); |
| 85 | List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList(); | 85 | List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList(); |
| 86 | // 导出 Excel | 86 | // 导出 Excel |
| 87 | - List<CrmClueExcelVO> datas = CrmClueConvert.INSTANCE.convertList02(list); | 87 | + List<CrmClueExcelVO> datas = BeanUtils.toBean(list, CrmClueExcelVO.class); |
| 88 | ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas); | 88 | ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas); |
| 89 | } | 89 | } |
| 90 | 90 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java
| 1 | package cn.iocoder.yudao.module.crm.convert.clue; | 1 | package cn.iocoder.yudao.module.crm.convert.clue; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExcelVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; | 3 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; |
| 8 | -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | ||
| 9 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | 4 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 10 | import org.mapstruct.Mapper; | 5 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.Mapping; | 6 | import org.mapstruct.Mapping; |
| 12 | import org.mapstruct.factory.Mappers; | 7 | import org.mapstruct.factory.Mappers; |
| 13 | 8 | ||
| 14 | -import java.util.List; | ||
| 15 | - | ||
| 16 | /** | 9 | /** |
| 17 | * 线索 Convert | 10 | * 线索 Convert |
| 18 | * | 11 | * |
| @@ -23,15 +16,6 @@ public interface CrmClueConvert { | @@ -23,15 +16,6 @@ public interface CrmClueConvert { | ||
| 23 | 16 | ||
| 24 | CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); | 17 | CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); |
| 25 | 18 | ||
| 26 | - // TODO @min:这几个 convert,都使用 BeanUtils 替代哈 | ||
| 27 | - CrmClueDO convert(CrmClueSaveReqVO bean); | ||
| 28 | - | ||
| 29 | - CrmClueRespVO convert(CrmClueDO bean); | ||
| 30 | - | ||
| 31 | - PageResult<CrmClueRespVO> convertPage(PageResult<CrmClueDO> page); | ||
| 32 | - | ||
| 33 | - List<CrmClueExcelVO> convertList02(List<CrmClueDO> list); | ||
| 34 | - | ||
| 35 | @Mapping(target = "bizId", source = "reqVO.id") | 19 | @Mapping(target = "bizId", source = "reqVO.id") |
| 36 | CrmPermissionTransferReqBO convert(CrmClueTransferReqVO reqVO, Long userId); | 20 | CrmPermissionTransferReqBO convert(CrmClueTransferReqVO reqVO, Long userId); |
| 37 | 21 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| @@ -60,7 +60,7 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -60,7 +60,7 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 60 | validateRelationDataExists(createReqVO); | 60 | validateRelationDataExists(createReqVO); |
| 61 | 61 | ||
| 62 | // 插入 | 62 | // 插入 |
| 63 | - CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); | 63 | + CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class); |
| 64 | clueMapper.insert(clue); | 64 | clueMapper.insert(clue); |
| 65 | // 返回 | 65 | // 返回 |
| 66 | return clue.getId(); | 66 | return clue.getId(); |
| @@ -75,7 +75,7 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -75,7 +75,7 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 75 | validateRelationDataExists(updateReqVO); | 75 | validateRelationDataExists(updateReqVO); |
| 76 | 76 | ||
| 77 | // 更新 | 77 | // 更新 |
| 78 | - CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); | 78 | + CrmClueDO updateObj = BeanUtils.toBean(updateReqVO, CrmClueDO.class); |
| 79 | clueMapper.updateById(updateObj); | 79 | clueMapper.updateById(updateObj); |
| 80 | } | 80 | } |
| 81 | 81 |