Commit ecf728966fb4ac33eb0f570e01e5824462793fed
1 parent
9ee6a27b
code review:客户逻辑
Showing
5 changed files
with
15 additions
and
9 deletions
yudao-module-crm/yudao-module-crm-biz/pom.xml
| @@ -33,6 +33,10 @@ | @@ -33,6 +33,10 @@ | ||
| 33 | <groupId>cn.iocoder.boot</groupId> | 33 | <groupId>cn.iocoder.boot</groupId> |
| 34 | <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> | 34 | <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> |
| 35 | </dependency> | 35 | </dependency> |
| 36 | + <dependency> | ||
| 37 | + <groupId>cn.iocoder.boot</groupId> | ||
| 38 | + <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | ||
| 39 | + </dependency> | ||
| 36 | 40 | ||
| 37 | <!-- Web 相关 --> | 41 | <!-- Web 相关 --> |
| 38 | <dependency> | 42 | <dependency> |
| @@ -57,12 +61,6 @@ | @@ -57,12 +61,6 @@ | ||
| 57 | <artifactId>yudao-spring-boot-starter-excel</artifactId> | 61 | <artifactId>yudao-spring-boot-starter-excel</artifactId> |
| 58 | </dependency> | 62 | </dependency> |
| 59 | 63 | ||
| 60 | - <!-- 地址相关 --> | ||
| 61 | - <dependency> | ||
| 62 | - <groupId>cn.iocoder.boot</groupId> | ||
| 63 | - <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | ||
| 64 | - </dependency> | ||
| 65 | - | ||
| 66 | <!-- Test 测试相关 --> | 64 | <!-- Test 测试相关 --> |
| 67 | <dependency> | 65 | <dependency> |
| 68 | <groupId>cn.iocoder.boot</groupId> | 66 | <groupId>cn.iocoder.boot</groupId> |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -102,12 +102,15 @@ public class CrmCustomerController { | @@ -102,12 +102,15 @@ public class CrmCustomerController { | ||
| 102 | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { | 102 | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| 103 | PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); | 103 | PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); |
| 104 | PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); | 104 | PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); |
| 105 | + // TODO @wanwan: 可以参考 CollectionUtils.convertListByFlatMap(),目的是简洁 | ||
| 105 | Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); | 106 | Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); |
| 106 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); | 107 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); |
| 107 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); | 108 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); |
| 109 | + // TODO @wanwan:这块可以形成一个 convertPage 方法,default 实现; | ||
| 108 | pageVo.getList().forEach(customerRespVO -> { | 110 | pageVo.getList().forEach(customerRespVO -> { |
| 109 | customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); | 111 | customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); |
| 110 | customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); | 112 | customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); |
| 113 | + // TODO @wanwan:可以使用 MapUtils.findAndThen | ||
| 111 | AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); | 114 | AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); |
| 112 | if (Objects.nonNull(ownerUser)) { | 115 | if (Objects.nonNull(ownerUser)) { |
| 113 | customerRespVO.setOwnerUserName(ownerUser.getNickname()); | 116 | customerRespVO.setOwnerUserName(ownerUser.getNickname()); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java
| @@ -30,10 +30,8 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { | @@ -30,10 +30,8 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { | ||
| 30 | 30 | ||
| 31 | @Schema(description = "负责人的用户编号", example = "25682") | 31 | @Schema(description = "负责人的用户编号", example = "25682") |
| 32 | private Long ownerUserId; | 32 | private Long ownerUserId; |
| 33 | - | ||
| 34 | @Schema(description = "负责人名字", example = "25682") | 33 | @Schema(description = "负责人名字", example = "25682") |
| 35 | private String ownerUserName; | 34 | private String ownerUserName; |
| 36 | - | ||
| 37 | @Schema(description = "负责人部门") | 35 | @Schema(description = "负责人部门") |
| 38 | private String ownerUserDept; | 36 | private String ownerUserDept; |
| 39 | 37 | ||
| @@ -52,7 +50,7 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { | @@ -52,7 +50,7 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { | ||
| 52 | 50 | ||
| 53 | @Schema(description = "创建人") | 51 | @Schema(description = "创建人") |
| 54 | private String creator; | 52 | private String creator; |
| 55 | - | ||
| 56 | @Schema(description = "创建人名字") | 53 | @Schema(description = "创建人名字") |
| 57 | private String creatorName; | 54 | private String creatorName; |
| 55 | + | ||
| 58 | } | 56 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
| @@ -98,8 +98,11 @@ public class CrmCustomerDO extends BaseDO { | @@ -98,8 +98,11 @@ public class CrmCustomerDO extends BaseDO { | ||
| 98 | private String remark; | 98 | private String remark; |
| 99 | /** | 99 | /** |
| 100 | * 负责人的用户编号 | 100 | * 负责人的用户编号 |
| 101 | + * | ||
| 102 | + * 关联 AdminUserDO 的 id 字段 | ||
| 101 | */ | 103 | */ |
| 102 | private Long ownerUserId; | 104 | private Long ownerUserId; |
| 105 | + // TODO @puhui999:这块抽到 permission 里; | ||
| 103 | /** | 106 | /** |
| 104 | * 只读权限的用户编号数组 | 107 | * 只读权限的用户编号数组 |
| 105 | */ | 108 | */ |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java
| @@ -65,6 +65,10 @@ public class CrmPermissionAspect { | @@ -65,6 +65,10 @@ public class CrmPermissionAspect { | ||
| 65 | // TODO @puhui999:一般核心的方法,放到最前面,private 放后面。主要是,主次要分出来哈; | 65 | // TODO @puhui999:一般核心的方法,放到最前面,private 放后面。主要是,主次要分出来哈; |
| 66 | @Before("@annotation(crmPermission)") | 66 | @Before("@annotation(crmPermission)") |
| 67 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { | 67 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { |
| 68 | + // TODO 芋艿:临时,方便大家调试 | ||
| 69 | + if (true) { | ||
| 70 | + return; | ||
| 71 | + } | ||
| 68 | try { | 72 | try { |
| 69 | Long bizId = crmPermission.getIdFor().length > 0 ? getBizId(joinPoint, crmPermission) : (Long) joinPoint.getArgs()[0]; // 获取操作数据的编号 | 73 | Long bizId = crmPermission.getIdFor().length > 0 ? getBizId(joinPoint, crmPermission) : (Long) joinPoint.getArgs()[0]; // 获取操作数据的编号 |
| 70 | Integer bizType = crmPermission.bizType().getType(); // 模块类型 | 74 | Integer bizType = crmPermission.bizType().getType(); // 模块类型 |