code review:客户逻辑

This commit is contained in:
YunaiV 2023-11-04 10:13:43 +08:00
parent 9ee6a27b86
commit ecf728966f
5 changed files with 15 additions and 9 deletions

View File

@ -33,6 +33,10 @@
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
</dependency>
<!-- Web 相关 --> <!-- Web 相关 -->
<dependency> <dependency>
@ -57,12 +61,6 @@
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency> </dependency>
<!-- 地址相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
</dependency>
<!-- Test 测试相关 --> <!-- Test 测试相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>

View File

@ -102,12 +102,15 @@ public class CrmCustomerController {
public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) {
PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO);
PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult);
// TODO @wanwan 可以参考 CollectionUtils.convertListByFlatMap()目的是简洁
Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet());
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet);
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet()));
// TODO @wanwan这块可以形成一个 convertPage 方法default 实现
pageVo.getList().forEach(customerRespVO -> { pageVo.getList().forEach(customerRespVO -> {
customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId()));
customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null));
// TODO @wanwan可以使用 MapUtils.findAndThen
AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId());
if (Objects.nonNull(ownerUser)) { if (Objects.nonNull(ownerUser)) {
customerRespVO.setOwnerUserName(ownerUser.getNickname()); customerRespVO.setOwnerUserName(ownerUser.getNickname());

View File

@ -30,10 +30,8 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO {
@Schema(description = "负责人的用户编号", example = "25682") @Schema(description = "负责人的用户编号", example = "25682")
private Long ownerUserId; private Long ownerUserId;
@Schema(description = "负责人名字", example = "25682") @Schema(description = "负责人名字", example = "25682")
private String ownerUserName; private String ownerUserName;
@Schema(description = "负责人部门") @Schema(description = "负责人部门")
private String ownerUserDept; private String ownerUserDept;
@ -52,7 +50,7 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO {
@Schema(description = "创建人") @Schema(description = "创建人")
private String creator; private String creator;
@Schema(description = "创建人名字") @Schema(description = "创建人名字")
private String creatorName; private String creatorName;
} }

View File

@ -98,8 +98,11 @@ public class CrmCustomerDO extends BaseDO {
private String remark; private String remark;
/** /**
* 负责人的用户编号 * 负责人的用户编号
*
* 关联 AdminUserDO id 字段
*/ */
private Long ownerUserId; private Long ownerUserId;
// TODO @puhui999这块抽到 permission
/** /**
* 只读权限的用户编号数组 * 只读权限的用户编号数组
*/ */

View File

@ -65,6 +65,10 @@ public class CrmPermissionAspect {
// TODO @puhui999一般核心的方法放到最前面private 放后面主要是主次要分出来哈 // TODO @puhui999一般核心的方法放到最前面private 放后面主要是主次要分出来哈
@Before("@annotation(crmPermission)") @Before("@annotation(crmPermission)")
public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) {
// TODO 芋艿临时方便大家调试
if (true) {
return;
}
try { try {
Long bizId = crmPermission.getIdFor().length > 0 ? getBizId(joinPoint, crmPermission) : (Long) joinPoint.getArgs()[0]; // 获取操作数据的编号 Long bizId = crmPermission.getIdFor().length > 0 ? getBizId(joinPoint, crmPermission) : (Long) joinPoint.getArgs()[0]; // 获取操作数据的编号
Integer bizType = crmPermission.bizType().getType(); // 模块类型 Integer bizType = crmPermission.bizType().getType(); // 模块类型