code review:权限模块

This commit is contained in:
YunaiV 2023-11-18 23:45:24 +08:00
parent 716b081464
commit 86050d411b
23 changed files with 57 additions and 27 deletions

View File

@ -7,6 +7,7 @@ import lombok.Getter;
import java.util.Arrays; import java.util.Arrays;
// TODO @puhui999这个应该是 crm 全局的不仅仅属于 customer 客户哈
/** /**
* CRM 客户等级 * CRM 客户等级
* *

View File

@ -17,12 +17,13 @@ public class CrmBusinessTransferReqVO {
/** /**
* 新负责人的用户编号 * 新负责人的用户编号
*/ */
@NotNull(message = "新负责人的用户编号不能为空")
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "新负责人的用户编号不能为空")
private Long newOwnerUserId; private Long newOwnerUserId;
/** /**
* 老负责人加入团队后的权限级别如果 null 说明移除 * 老负责人加入团队后的权限级别如果 null 说明移除
*
* 关联 {@link CrmPermissionLevelEnum} * 关联 {@link CrmPermissionLevelEnum}
*/ */
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -17,12 +17,13 @@ public class CrmContactTransferReqVO {
/** /**
* 新负责人的用户编号 * 新负责人的用户编号
*/ */
@NotNull(message = "新负责人的用户编号不能为空")
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "新负责人的用户编号不能为空")
private Long newOwnerUserId; private Long newOwnerUserId;
/** /**
* 老负责人加入团队后的权限级别如果 null 说明移除 * 老负责人加入团队后的权限级别如果 null 说明移除
*
* 关联 {@link CrmPermissionLevelEnum} * 关联 {@link CrmPermissionLevelEnum}
*/ */
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -17,12 +17,13 @@ public class CrmContractTransferReqVO {
/** /**
* 新负责人的用户编号 * 新负责人的用户编号
*/ */
@NotNull(message = "新负责人的用户编号不能为空")
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "新负责人的用户编号不能为空")
private Long newOwnerUserId; private Long newOwnerUserId;
/** /**
* 老负责人加入团队后的权限级别如果 null 说明移除 * 老负责人加入团队后的权限级别如果 null 说明移除
*
* 关联 {@link CrmPermissionLevelEnum} * 关联 {@link CrmPermissionLevelEnum}
*/ */
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -106,6 +106,7 @@ public class CrmCustomerController {
return success(CrmCustomerConvert.INSTANCE.convert(customer, ownerMap, userMap, deptMap)); return success(CrmCustomerConvert.INSTANCE.convert(customer, ownerMap, userMap, deptMap));
} }
// TODO @puhui999可以在 CrmCustomerPageReqVO 里面加个 pool 参数 true 代表来自公海客户的分页
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得客户分页") @Operation(summary = "获得客户分页")
@PreAuthorize("@ss.hasPermission('crm:customer:query')") @PreAuthorize("@ss.hasPermission('crm:customer:query')")
@ -115,7 +116,7 @@ public class CrmCustomerController {
return success(PageResult.empty(pageResult.getTotal())); return success(PageResult.empty(pageResult.getTotal()));
} }
// 拼接数据 // 拼接数据
// TODO 芋艿需要 review // TODO @puhui999这块的拼接逻辑可以和 convertPage 合并
// Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( // Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
// convertSetByFlatMap(pageResult.getList(), user -> Stream.of(NumberUtil.parseLong(user.getCreator()), user.getOwnerUserId()))); // convertSetByFlatMap(pageResult.getList(), user -> Stream.of(NumberUtil.parseLong(user.getCreator()), user.getOwnerUserId())));
// Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( // Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
@ -123,6 +124,7 @@ public class CrmCustomerController {
return convertPage(customerService.getCustomerPage(pageVO, getLoginUserId())); return convertPage(customerService.getCustomerPage(pageVO, getLoginUserId()));
} }
// TODO @puhui999
@GetMapping("/pool-page") @GetMapping("/pool-page")
@Operation(summary = "获得公海客户分页") @Operation(summary = "获得公海客户分页")
@PreAuthorize("@ss.hasPermission('crm:customer:query')") @PreAuthorize("@ss.hasPermission('crm:customer:query')")

View File

@ -29,7 +29,9 @@ public class CrmCustomerPageReqVO extends PageParam {
private Integer source; private Integer source;
/** /**
* 场景类型关联 {@link CrmCustomerSceneEnum} * 场景类型
*
* 关联 {@link CrmCustomerSceneEnum}
*/ */
@Schema(description = "场景类型", example = "1") @Schema(description = "场景类型", example = "1")
private Integer sceneType; private Integer sceneType;

View File

@ -17,12 +17,13 @@ public class CrmCustomerTransferReqVO {
/** /**
* 新负责人的用户编号 * 新负责人的用户编号
*/ */
@NotNull(message = "新负责人的用户编号不能为空")
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "新负责人的用户编号不能为空")
private Long newOwnerUserId; private Long newOwnerUserId;
/** /**
* 老负责人加入团队后的权限级别如果 null 说明移除 * 老负责人加入团队后的权限级别如果 null 说明移除
*
* 关联 {@link CrmPermissionLevelEnum} * 关联 {@link CrmPermissionLevelEnum}
*/ */
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -55,16 +55,18 @@ public class CrmPermissionController {
@Resource @Resource
private PostApi postApi; private PostApi postApi;
// TODO @puhui999保持统一create 然后是 PostMapping
@PutMapping("/add") @PutMapping("/add")
@Operation(summary = "添加团队成员") @Operation(summary = "添加团队成员")
@PreAuthorize("@ss.hasPermission('crm:permission:create')") @PreAuthorize("@ss.hasPermission('crm:permission:create')")
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId" @CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId",
, level = CrmPermissionLevelEnum.OWNER) level = CrmPermissionLevelEnum.OWNER)
public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) { public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) {
permissionService.createPermission(CrmPermissionConvert.INSTANCE.convert(reqVO)); permissionService.createPermission(CrmPermissionConvert.INSTANCE.convert(reqVO));
return success(true); return success(true);
} }
// TODO @puhui999领取公海客户是不是放到客户那更合适哈
@PutMapping("/receive") @PutMapping("/receive")
@Operation(summary = "领取公海数据") @Operation(summary = "领取公海数据")
@PreAuthorize("@ss.hasPermission('crm:permission:update')") @PreAuthorize("@ss.hasPermission('crm:permission:update')")
@ -73,6 +75,7 @@ public class CrmPermissionController {
return success(true); return success(true);
} }
// TODO @puhui999是不是放到客户那更合适哈
@PutMapping("/put-pool") @PutMapping("/put-pool")
@Operation(summary = "数据放入公海") @Operation(summary = "数据放入公海")
@PreAuthorize("@ss.hasPermission('crm:permission:update')") @PreAuthorize("@ss.hasPermission('crm:permission:update')")
@ -93,6 +96,7 @@ public class CrmPermissionController {
return success(true); return success(true);
} }
// TODO @puhui999bizType bizId 是不是不用啦因为参数校验需要 bizType bizId可以先查询下在直接调用方法不一定都要注解哈
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "移除团队成员") @Operation(summary = "移除团队成员")
@Parameters({ @Parameters({
@ -110,9 +114,11 @@ public class CrmPermissionController {
return success(true); return success(true);
} }
// TODO @puhui999deleteSelfPermission尽量归成 crud 这样的操作哈
@DeleteMapping("/quit-team") @DeleteMapping("/quit-team")
@Operation(summary = "退出团队") @Operation(summary = "退出团队")
@Parameters({ @Parameters({
// TODO @puhui999这个可以拿出来不用包在 @Parameters 在只有一个参数时哈
@Parameter(name = "id", description = "团队成员编号", required = true, example = "1024") @Parameter(name = "id", description = "团队成员编号", required = true, example = "1024")
}) })
@PreAuthorize("@ss.hasPermission('crm:permission:delete')") @PreAuthorize("@ss.hasPermission('crm:permission:delete')")
@ -143,6 +149,7 @@ public class CrmPermissionController {
} }
// TODO @puhui999池子的逻辑 // TODO @puhui999池子的逻辑
// 判断是否是公海数据 // 判断是否是公海数据
// TODO @puhui999这段逻辑可以删除么
Predicate<CrmPermissionDO> filter = item -> ObjUtil.equal(item.getUserId(), CrmPermissionDO.POOL_USER_ID); Predicate<CrmPermissionDO> filter = item -> ObjUtil.equal(item.getUserId(), CrmPermissionDO.POOL_USER_ID);
if (anyMatch(permission, filter)) { if (anyMatch(permission, filter)) {
permission.removeIf(filter); // 排除 permission.removeIf(filter); // 排除
@ -151,6 +158,7 @@ public class CrmPermissionController {
// 拼接数据 // 拼接数据
List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId));
// TODO @puhui999CollectionUtils.convertSetByFlatMap() 看看可以不
Set<Long> postIds = userList.stream().flatMap(item -> item.getPostIds().stream()).collect(Collectors.toSet()); Set<Long> postIds = userList.stream().flatMap(item -> item.getPostIds().stream()).collect(Collectors.toSet());
Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds);
return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap));

View File

@ -21,13 +21,13 @@ public class CrmPermissionBaseVO {
@NotNull(message = "用户编号不能为空") @NotNull(message = "用户编号不能为空")
private Long userId; private Long userId;
@Schema(description = "Crm 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@InEnum(CrmBizTypeEnum.class) @InEnum(CrmBizTypeEnum.class)
@NotNull(message = "Crm 类型不能为空") @NotNull(message = "CRM 类型不能为空")
private Integer bizType; private Integer bizType;
@Schema(description = "Crm 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "Crm 类型数据编号不能为空") @NotNull(message = "CRM 类型数据编号不能为空")
private Long bizId; private Long bizId;
@Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -13,12 +13,12 @@ public class CrmPermissionRespVO extends CrmPermissionBaseVO {
@Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") @Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long id; private Long id;
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部")
private String deptName;
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
private String nickname; private String nickname;
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部")
private String deptName;
@Schema(description = "岗位名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[BOOS,经理]") @Schema(description = "岗位名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[BOOS,经理]")
private Set<String> postNames; private Set<String> postNames;

View File

@ -81,6 +81,7 @@ public interface CrmCustomerConvert {
PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page);
// TODO @puhui999两个 convertPage 的逻辑合并下
default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, CrmPermissionDO> ownerMap, default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, CrmPermissionDO> ownerMap,
Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
PageResult<CrmCustomerRespVO> result = convertPage(pageResult); PageResult<CrmCustomerRespVO> result = convertPage(pageResult);

View File

@ -56,6 +56,7 @@ public interface CrmPermissionConvert {
} }
default List<CrmPermissionDO> convertList(CrmPermissionUpdateReqVO updateReqVO) { default List<CrmPermissionDO> convertList(CrmPermissionUpdateReqVO updateReqVO) {
// TODO @puhui999CollectionUtils.convert
List<CrmPermissionDO> permissions = new ArrayList<>(); List<CrmPermissionDO> permissions = new ArrayList<>();
updateReqVO.getIds().forEach(id -> { updateReqVO.getIds().forEach(id -> {
permissions.add(new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel())); permissions.add(new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel()));

View File

@ -24,6 +24,7 @@ import lombok.*;
public class CrmPermissionDO extends BaseDO { public class CrmPermissionDO extends BaseDO {
// TODO puhui999是不是公海的数据就不插入了这样方便获取公海数据鸭 // TODO puhui999是不是公海的数据就不插入了这样方便获取公海数据鸭
// TODO @puhui999每个数据那的负责人我想了下还是存储的
/** /**
* 当数据变为公海数据时也就是数据团队成员中没有负责人的时候将原本的负责人 userId 设置为 POOL_USER_ID 方便查询公海数据 * 当数据变为公海数据时也就是数据团队成员中没有负责人的时候将原本的负责人 userId 设置为 POOL_USER_ID 方便查询公海数据
* 也就是说每条数据到最后都有一个负责人如果有人领取则 userId 为领取人 * 也就是说每条数据到最后都有一个负责人如果有人领取则 userId 为领取人

View File

@ -26,6 +26,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
.orderByDesc(CrmBusinessDO::getId)); .orderByDesc(CrmBusinessDO::getId));
} }
// TODO @puhui999selectList
default List<CrmBusinessDO> selectPage(CrmBusinessExportReqVO reqVO) { default List<CrmBusinessDO> selectPage(CrmBusinessExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CrmBusinessDO>() return selectList(new LambdaQueryWrapperX<CrmBusinessDO>()
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) .likeIfPresent(CrmBusinessDO::getName, reqVO.getName())

View File

@ -12,7 +12,7 @@ import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.METHOD;
/** /**
* Crm 数据操作权限校验 AOP 注解 * CRM 数据操作权限校验 AOP 注解
* *
* @author HUIHUI * @author HUIHUI
*/ */
@ -22,18 +22,19 @@ import static java.lang.annotation.ElementType.METHOD;
public @interface CrmPermission { public @interface CrmPermission {
/** /**
* crm 类型 * CRM 类型
*/ */
CrmBizTypeEnum bizType(); CrmBizTypeEnum bizType();
/** /**
* crm 类型扩展 * CRM 类型扩展通过 Spring EL 表达式获取到 {@link #bizType()}
* 用于 CrmPermissionController 团队权限校验 *
* 目的用于 CrmPermissionController 团队权限校验
*/ */
String bizTypeValue() default ""; String bizTypeValue() default "";
/** /**
* 数据编号通过 spring el 表达式获取 * 数据编号通过 Spring EL 表达式获取
* TODO 数据权限完成后去除 default "" * TODO 数据权限完成后去除 default ""
*/ */
String bizId() default ""; String bizId() default "";

View File

@ -108,6 +108,8 @@ public class CrmPermissionAspect {
throw exception(CRM_PERMISSION_DENIED, crmPermission.bizType().getName()); throw exception(CRM_PERMISSION_DENIED, crmPermission.bizType().getName());
} }
// TODO @puhui999这块看看能不能用 SpringExpressionUtils 工具类
private KeyValue<Long, Integer> getBizIdAndBizType(JoinPoint joinPoint, CrmPermission crmPermission) throws NoSuchMethodException { private KeyValue<Long, Integer> getBizIdAndBizType(JoinPoint joinPoint, CrmPermission crmPermission) throws NoSuchMethodException {
Method method = getMethod(joinPoint); Method method = getMethod(joinPoint);
// 1. 获取方法的参数值 // 1. 获取方法的参数值

View File

@ -4,6 +4,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser;
// TODO @puhui999SpringExpressionUtils
/** /**
* 注册 Spel 所需 Bean * 注册 Spel 所需 Bean
* *

View File

@ -17,6 +17,7 @@ import java.util.Arrays;
@Getter @Getter
public enum CrmBizTypeEnum implements IntArrayValuable { public enum CrmBizTypeEnum implements IntArrayValuable {
// TODO @puhui999如果类似 CrmBizPermission bizType 需要为空可以设置它是数组参考 Telephone payload
CRM_PERMISSION(0, "团队"), // CrmPermissionController 中使用 CRM_PERMISSION(0, "团队"), // CrmPermissionController 中使用
CRM_LEADS(1, "线索"), CRM_LEADS(1, "线索"),
CRM_CUSTOMER(2, "客户"), CRM_CUSTOMER(2, "客户"),

View File

@ -103,6 +103,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Override @Override
public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
// 1. 获取当前用户能看的分页数据 // 1. 获取当前用户能看的分页数据
// TODO @puhui999如果业务的数据量比较大in 太多可能有性能问题噢看看是不是搞成 join 连表了可以微信讨论下
List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId( List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId(
CrmBizTypeEnum.CRM_BUSINESS.getType(), userId); CrmBizTypeEnum.CRM_BUSINESS.getType(), userId);
Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId); Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId);

View File

@ -100,6 +100,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
return customerMapper.selectPage(pageReqVO, Collections.emptyList()); return customerMapper.selectPage(pageReqVO, Collections.emptyList());
} }
// 1.2 获取当前用户能看的分页数据 // 1.2 获取当前用户能看的分页数据
// TODO @puhui999如果业务的数据量比较大in 太多可能有性能问题噢看看是不是搞成 join 连表了可以微信讨论下
List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId( List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId(
CrmBizTypeEnum.CRM_CUSTOMER.getType(), userId); CrmBizTypeEnum.CRM_CUSTOMER.getType(), userId);
// 1.3 TODO 场景数据过滤 // 1.3 TODO 场景数据过滤

View File

@ -24,8 +24,9 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum.isOwner; import static cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum.isOwner;
// TODO @puhui999尽量规避用团队这个词哈这个只是我们给前端展示用的
/** /**
* crm 数据权限 Service 接口实现类 * CRM 数据权限 Service 接口实现类
* *
* @author HUIHUI * @author HUIHUI
*/ */
@ -117,6 +118,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
// 1.2 校验新负责人是否存在 // 1.2 校验新负责人是否存在
adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId()));
// TODO @puhui9992. 2.1 合并成 22.2 单独成 3说白了就是 2. 修改新负责人的权限3. 修改老负责人的权限这样整体注释会简洁一点也清晰一点
// 2. 权限转移 // 2. 权限转移
List<CrmPermissionDO> permissions = crmPermissionMapper.selectByBizTypeAndBizId( List<CrmPermissionDO> permissions = crmPermissionMapper.selectByBizTypeAndBizId(
transferReqBO.getBizType(), transferReqBO.getBizId()); // 获取所有团队成员 transferReqBO.getBizType(), transferReqBO.getBizId()); // 获取所有团队成员
@ -127,7 +129,6 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
crmPermissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType()) crmPermissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType())
.setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId()) .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId())
.setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
} else { // 存在则修改权限级别 } else { // 存在则修改权限级别
crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()) crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId())
.setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
@ -138,7 +139,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
.setLevel(transferReqBO.getOldOwnerPermissionLevel())); // 设置加入团队后的级别 .setLevel(transferReqBO.getOldOwnerPermissionLevel())); // 设置加入团队后的级别
return; return;
} }
crmPermissionMapper.deleteById(oldPermission.getId()); // 移除 crmPermissionMapper.deleteById(oldPermission.getId());
} }
@Override @Override
@ -164,7 +165,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
if (permission == null) { // 不存在则模块数据也不存在 if (permission == null) { // 不存在则模块数据也不存在
throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType)); throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType));
} }
// 更新
crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()).setUserId(CrmPermissionDO.POOL_USER_ID)); crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()).setUserId(CrmPermissionDO.POOL_USER_ID));
} }

View File

@ -22,7 +22,7 @@ public class CrmPermissionTransferReqBO {
private Long userId; private Long userId;
/** /**
* Crm 类型 * CRM 类型
*/ */
@NotNull(message = "Crm 类型不能为空") @NotNull(message = "Crm 类型不能为空")
@InEnum(CrmBizTypeEnum.class) @InEnum(CrmBizTypeEnum.class)
@ -30,7 +30,7 @@ public class CrmPermissionTransferReqBO {
/** /**
* 数据编号 * 数据编号
*/ */
@NotNull(message = "Crm 数据编号不能为空") @NotNull(message = "CRM 数据编号不能为空")
private Long bizId; private Long bizId;
/** /**
@ -41,6 +41,7 @@ public class CrmPermissionTransferReqBO {
/** /**
* 老负责人加入团队后的权限级别如果 null 说明移除 * 老负责人加入团队后的权限级别如果 null 说明移除
*
* 关联 {@link CrmPermissionLevelEnum} * 关联 {@link CrmPermissionLevelEnum}
*/ */
private Integer oldOwnerPermissionLevel; private Integer oldOwnerPermissionLevel;

View File

@ -17,7 +17,7 @@ public class CrmPermissionUpdateReqBO {
/** /**
* 数据权限编号 * 数据权限编号
*/ */
@NotNull(message = "Crm 数据权限编号不能为空") @NotNull(message = "数据权限编号不能为空")
private Long id; private Long id;
/** /**