mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
code review:crm 客户转移
This commit is contained in:
parent
f73b857551
commit
67ac11b56c
@ -11,7 +11,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 合同管理 1-020-000-000 ==========
|
||||
ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在");
|
||||
ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限");
|
||||
ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “合同操作失败,原因:没有权限”
|
||||
ErrorCode CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_000_002, "合同转移失败,原因:负责人不存在");
|
||||
|
||||
// ========== 线索管理 1-020-001-000 ==========
|
||||
@ -19,7 +19,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 商机管理 1-020-002-000 ==========
|
||||
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
|
||||
ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限");
|
||||
ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “商机操作失败,原因:没有权限”
|
||||
ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在");
|
||||
|
||||
// TODO @lilleo:商机状态、商机类型,都单独错误码段
|
||||
@ -29,7 +29,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 联系人管理 1-020-003-000 ==========
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||
ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限");
|
||||
ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “联系人操作失败,原因:没有权限”
|
||||
ErrorCode CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_003_002, "联系人转移失败,原因:负责人不存在");
|
||||
|
||||
// TODO @liuhongfeng:错误码分段;
|
||||
|
@ -5,21 +5,12 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 商机创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO {
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
|
||||
// TODO @ljileo:新建的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public class CrmBusinessTransferReqVO {
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 商机更新 Request VO")
|
||||
@Data
|
||||
@ -18,13 +17,6 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO {
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
|
||||
// TODO @ljileo:修改的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - crm联系人更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -16,10 +14,4 @@ public class ContactUpdateReqVO extends ContactBaseVO {
|
||||
@Schema(description = "主键", example = "23210")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public class CrmContactTransferReqVO {
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
||||
|
@ -95,5 +95,4 @@ public class ContractController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,18 +5,10 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 合同创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ContractCreateReqVO extends ContractBaseVO {
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 合同更新 Request VO")
|
||||
@Data
|
||||
@ -18,10 +17,4 @@ public class ContractUpdateReqVO extends ContractBaseVO {
|
||||
@NotNull(message = "合同编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public class CrmContractTransferReqVO {
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
||||
|
@ -32,8 +32,10 @@ public interface CrmBusinessConvert {
|
||||
|
||||
default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = business.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 TODO puhui999:是不是直接 rwUserIds.remove(userId)
|
||||
// TODO @puhui999:ownerUserId 不用添加到进去,它就是 ownerUserId 就够;因为一共有 3 个角色:负责人、读写、只读;
|
||||
rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人
|
||||
// TODO @puhui999:对原负责人,加个类似的处理:移除、转化为团队成员(只读、读写)
|
||||
return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人
|
||||
.setRwUserIds(rwUserIds);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public interface ContactConvert {
|
||||
|
||||
List<ContactExcelVO> convertList02(List<ContactDO> list);
|
||||
|
||||
// TODO @puhui999:参考 CrmBusinessConvert 的修改建议
|
||||
default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = contact.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
|
@ -32,6 +32,7 @@ public interface ContractConvert {
|
||||
|
||||
List<ContractExcelVO> convertList02(List<ContractDO> list);
|
||||
|
||||
// TODO @puhui999:参考 CrmBusinessConvert 的修改建议
|
||||
default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = contract.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.framework.utils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
// TODO @puhui999:改成 CrmPermissionUtils;
|
||||
/**
|
||||
* 数据读写权限校验工具类
|
||||
*
|
||||
@ -9,6 +10,8 @@ import java.util.Collection;
|
||||
*/
|
||||
public class AuthUtil {
|
||||
|
||||
// TODO @puhui999:负责人是单独的字段哈;
|
||||
// TODO @puhui999:额外校验,如果是管理员,可以查看所有;看着要做成有状态的了,可能要搞个 CrmPermissionService 咧;
|
||||
/**
|
||||
* 判断当前数据对用户来说是否是只读的
|
||||
*
|
||||
@ -17,6 +20,7 @@ public class AuthUtil {
|
||||
* @return boolean 是/否
|
||||
*/
|
||||
public static boolean isReadOnly(Collection<Long> roUserIds, Long userId) {
|
||||
// TODO @puhui999:从代码角度来说,最好使用 CollUtil.contains
|
||||
return roUserIds.contains(userId);
|
||||
}
|
||||
|
||||
|
@ -92,26 +92,27 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
return businessMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
// TODO @puhui999:动名词哈。transferBusiness
|
||||
@Override
|
||||
public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验商机是否存在
|
||||
// 1.1 校验商机是否存在
|
||||
CrmBusinessDO business = validateBusinessExists(reqVO.getId());
|
||||
// 1.2. 校验用户是否拥有读写权限
|
||||
// 1.2 校验用户是否拥有读写权限
|
||||
if (!isReadAndWrite(business.getRwUserIds(), userId)) {
|
||||
throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED);
|
||||
}
|
||||
// 2. 校验新负责人是否存在
|
||||
// TODO @puhui999:如果已经是该负责人,抛个业务异常;
|
||||
// 1.3 校验新负责人是否存在
|
||||
AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId());
|
||||
if (user == null) {
|
||||
throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 3. 更新新的负责人
|
||||
// 2. 更新新的负责人
|
||||
CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId);
|
||||
businessMapper.updateById(updateBusiness);
|
||||
|
||||
// 4. TODO 记录商机转移日志
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public class ContactServiceImpl implements ContactService {
|
||||
return contactMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
// TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议
|
||||
@Override
|
||||
public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验联系人是否存在
|
||||
|
@ -92,6 +92,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
return contractMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
// TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议
|
||||
@Override
|
||||
public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验合同是否存在
|
||||
|
Loading…
Reference in New Issue
Block a user