|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.convert.customer;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
|
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
@@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import org.mapstruct.Mapper;
|
|
|
import org.mapstruct.factory.Mappers;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -21,34 +23,20 @@ public interface CrmCustomerLimitConfigConvert {
|
|
|
|
|
|
CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class);
|
|
|
|
|
|
- CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean);
|
|
|
-
|
|
|
- PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> page);
|
|
|
-
|
|
|
- default PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> pageResult,
|
|
|
- Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
|
|
- PageResult<CrmCustomerLimitConfigRespVO> result = convertPage(pageResult);
|
|
|
- result.getList().forEach(respVo -> fillNameField(userMap, deptMap, respVo));
|
|
|
- return result;
|
|
|
+ default PageResult<CrmCustomerLimitConfigRespVO> convertPage(
|
|
|
+ PageResult<CrmCustomerLimitConfigDO> pageResult,
|
|
|
+ Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
|
|
+ List<CrmCustomerLimitConfigRespVO> list = CollectionUtils.convertList(pageResult.getList(),
|
|
|
+ limitConfig -> convert(limitConfig, userMap, deptMap));
|
|
|
+ return new PageResult<>(list, pageResult.getTotal());
|
|
|
}
|
|
|
|
|
|
- default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO customerLimitConfig,
|
|
|
+ default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO limitConfig,
|
|
|
Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
|
|
- CrmCustomerLimitConfigRespVO respVo = convert(customerLimitConfig);
|
|
|
- fillNameField(userMap, deptMap, respVo);
|
|
|
- return respVo;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 填充名称字段
|
|
|
- *
|
|
|
- * @param userMap 用户映射
|
|
|
- * @param deptMap 部门映射
|
|
|
- * @param respVo 响应实体
|
|
|
- */
|
|
|
- static void fillNameField(Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap, CrmCustomerLimitConfigRespVO respVo) {
|
|
|
- respVo.setUsers(CollectionUtils.convertList(respVo.getUserIds(), userMap::get));
|
|
|
- respVo.setDepts(CollectionUtils.convertList(respVo.getDeptIds(), deptMap::get));
|
|
|
+ CrmCustomerLimitConfigRespVO limitConfigVO = BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class);
|
|
|
+ limitConfigVO.setUsers(CollectionUtils.convertList(limitConfigVO.getUserIds(), userMap::get));
|
|
|
+ limitConfigVO.setDepts(CollectionUtils.convertList(limitConfigVO.getDeptIds(), deptMap::get));
|
|
|
+ return limitConfigVO;
|
|
|
}
|
|
|
|
|
|
}
|