mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
完善 review 提到的问题
This commit is contained in:
parent
a385a37c4a
commit
91dd61edc0
@ -91,9 +91,10 @@ public class CrmBusinessController {
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "商机转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferBusinessReqVO reqVO) {
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) {
|
||||
businessService.transferBusiness(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 商机转移 Request VO")
|
||||
@Data
|
||||
public class CrmTransferBusinessReqVO {
|
||||
public class CrmBusinessTransferReqVO {
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
@ -18,7 +18,7 @@ public class CrmTransferBusinessReqVO {
|
||||
* 新负责人的用户编号
|
||||
*/
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private Long newOwnerUserId;
|
||||
|
||||
/**
|
@ -100,7 +100,7 @@ public class ContactController {
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "联系人转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferContactReqVO reqVO) {
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {
|
||||
contactService.transferContact(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人转移 Request VO")
|
||||
@Data
|
||||
public class CrmContactTransferReqVO {
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 新负责人的用户编号
|
||||
*/
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private Long newOwnerUserId;
|
||||
|
||||
/**
|
||||
* 老负责人是否加入团队,是/否
|
||||
*/
|
||||
@Schema(description = "老负责人是否加入团队", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
@NotNull(message = "老负责人是否加入团队不能为空")
|
||||
private Boolean joinTeam;
|
||||
|
||||
/**
|
||||
* 老负责人加入团队后的权限级别。如果 {@link #joinTeam} 为 false, permissionLevel 为 null
|
||||
* 关联 {@link CrmPermissionLevelEnum}
|
||||
*/
|
||||
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer permissionLevel;
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人转移 Request VO")
|
||||
@Data
|
||||
public class CrmTransferContactReqVO {
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "原负责人移除方式不能为空")
|
||||
private Integer transferType;
|
||||
|
||||
@Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "权限类型不能为空")
|
||||
private Integer permissionType;
|
||||
|
||||
}
|
@ -90,7 +90,7 @@ public class ContractController {
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "合同转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferContractReqVO reqVO) {
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) {
|
||||
contractService.transferContract(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 合同转移 Request VO")
|
||||
@Data
|
||||
public class CrmContractTransferReqVO {
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 新负责人的用户编号
|
||||
*/
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private Long newOwnerUserId;
|
||||
|
||||
/**
|
||||
* 老负责人是否加入团队,是/否
|
||||
*/
|
||||
@Schema(description = "老负责人是否加入团队", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
@NotNull(message = "老负责人是否加入团队不能为空")
|
||||
private Boolean joinTeam;
|
||||
|
||||
/**
|
||||
* 老负责人加入团队后的权限级别。如果 {@link #joinTeam} 为 false, permissionLevel 为 null
|
||||
* 关联 {@link CrmPermissionLevelEnum}
|
||||
*/
|
||||
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer permissionLevel;
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
// TODO @puhui999:CrmContractTransferReqVO,模块名字要放前面;看看还有没其它类似的
|
||||
@Schema(description = "管理后台 - CRM 合同转移 Request VO")
|
||||
@Data
|
||||
public class CrmTransferContractReqVO {
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "合同编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "原负责人移除方式不能为空")
|
||||
private Integer transferType;
|
||||
|
||||
@Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "权限类型不能为空")
|
||||
private Integer permissionType;
|
||||
|
||||
}
|
@ -90,7 +90,7 @@ public class CrmCustomerController {
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "客户转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferCustomerReqVO reqVO) {
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
|
||||
customerService.transferCustomer(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户转移 Request VO")
|
||||
@Data
|
||||
public class CrmCustomerTransferReqVO {
|
||||
|
||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 新负责人的用户编号
|
||||
*/
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private Long newOwnerUserId;
|
||||
|
||||
/**
|
||||
* 老负责人是否加入团队,是/否
|
||||
*/
|
||||
@Schema(description = "老负责人是否加入团队", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
@NotNull(message = "老负责人是否加入团队不能为空")
|
||||
private Boolean joinTeam;
|
||||
|
||||
/**
|
||||
* 老负责人加入团队后的权限级别。如果 {@link #joinTeam} 为 false, permissionLevel 为 null
|
||||
* 关联 {@link CrmPermissionLevelEnum}
|
||||
*/
|
||||
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer permissionLevel;
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户转移 Request VO")
|
||||
@Data
|
||||
public class CrmTransferCustomerReqVO {
|
||||
|
||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "客户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "原负责人移除方式不能为空")
|
||||
private Integer transferType;
|
||||
|
||||
@Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "权限类型不能为空")
|
||||
private Integer permissionType;
|
||||
|
||||
}
|
@ -35,6 +35,6 @@ public interface CrmBusinessConvert {
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
})
|
||||
CrmTransferPermissionReqBO convert(CrmTransferBusinessReqVO reqVO, Long userId);
|
||||
CrmTransferPermissionReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ public interface ContactConvert {
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
})
|
||||
CrmTransferPermissionReqBO convert(CrmTransferContactReqVO reqVO, Long userId);
|
||||
CrmTransferPermissionReqBO convert(CrmContactTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ public interface ContractConvert {
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
})
|
||||
CrmTransferPermissionReqBO convert(CrmTransferContractReqVO reqVO, Long userId);
|
||||
CrmTransferPermissionReqBO convert(CrmContractTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ public interface CrmCustomerConvert {
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
})
|
||||
CrmTransferPermissionReqBO convert(CrmTransferCustomerReqVO reqVO, Long userId);
|
||||
CrmTransferPermissionReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ public class CrmPermissionDO extends BaseDO {
|
||||
private Long userId;
|
||||
/**
|
||||
* 权限级别,关联 {@link CrmPermissionLevelEnum}
|
||||
* 如果为公海数据的话会干掉此数据的负责人,领取人则上位负责人
|
||||
* 例:客户放入公海后会干掉团队成员中的负责人,而其他团队成员则不受影响
|
||||
*/
|
||||
private Integer permissionLevel;
|
||||
|
||||
|
@ -44,4 +44,17 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> {
|
||||
.eq(CrmPermissionDO::getBizId, bizId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据权限列表通过 数据类型 x 用户编号。如果
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param userId
|
||||
* @return Crm 数据权限列表
|
||||
*/
|
||||
default List<CrmPermissionDO> selectByBizTypeAndUserId(Integer bizType, Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmPermissionDO>()
|
||||
.eq(CrmPermissionDO::getBizType, bizType)
|
||||
.eq(CrmPermissionDO::getUserId, userId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ public class CrmPermissionAspect {
|
||||
return;
|
||||
}
|
||||
if (isRead(permissionLevel)) { // 读权限
|
||||
// 如果没有数据权限或没有负责人则表示此记录为公海数据所有人都有只读权限
|
||||
if (!CollUtil.anyMatch(bizPermissions, item -> isOwner(item.getPermissionLevel()))) {
|
||||
// 如果没有数据权限或没有负责人则表示此记录为公海数据所有人都有只读权限可以领取成为负责人(团队成员领取的)
|
||||
if (CollUtil.isEmpty(bizPermissions) || !CollUtil.anyMatch(bizPermissions, item -> isOwner(item.getPermissionLevel()))) {
|
||||
return;
|
||||
}
|
||||
if (isRead(userPermission.getPermissionLevel())) { // 校验当前用户是否有读权限
|
||||
|
@ -76,6 +76,6 @@ public interface CrmBusinessService {
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void transferBusiness(CrmTransferBusinessReqVO reqVO, Long userId);
|
||||
void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferBusiness(CrmTransferBusinessReqVO reqVO, Long userId) {
|
||||
public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||
// 1 校验商机是否存在
|
||||
validateBusinessExists(reqVO.getId());
|
||||
|
||||
|
@ -76,6 +76,6 @@ public interface ContactService {
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void transferContact(CrmTransferContactReqVO reqVO, Long userId);
|
||||
void transferContact(CrmContactTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class ContactServiceImpl implements ContactService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferContact(CrmTransferContactReqVO reqVO, Long userId) {
|
||||
public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {
|
||||
// 1 校验联系人是否存在
|
||||
validateContactExists(reqVO.getId());
|
||||
|
||||
|
@ -76,6 +76,6 @@ public interface ContractService {
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void transferContract(CrmTransferContractReqVO reqVO, Long userId);
|
||||
void transferContract(CrmContractTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferContract(CrmTransferContractReqVO reqVO, Long userId) {
|
||||
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
||||
// 1 校验合同是否存在
|
||||
validateContractExists(reqVO.getId());
|
||||
|
||||
|
@ -84,6 +84,6 @@ public interface CrmCustomerService {
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId);
|
||||
void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId) {
|
||||
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验合同是否存在
|
||||
validateCustomer(reqVO.getId());
|
||||
|
||||
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface CrmPermissionService {
|
||||
|
||||
// TODO @puhui999:方法名上,不用 Crm
|
||||
/**
|
||||
* 创建数据权限
|
||||
*
|
||||
@ -59,6 +58,15 @@ public interface CrmPermissionService {
|
||||
*/
|
||||
List<CrmPermissionDO> getPermissionByBizTypeAndBizId(Integer bizType, Long bizId);
|
||||
|
||||
/**
|
||||
* 获取数据权限列表,通过 数据类型 x 用户编号
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param userId 用户编号
|
||||
* @return Crm 数据权限列表
|
||||
*/
|
||||
List<CrmPermissionDO> getPermissionByBizTypeAndUserId(Integer bizType, Long userId);
|
||||
|
||||
/**
|
||||
* 数据权限转移
|
||||
*
|
||||
|
@ -73,6 +73,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||
return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmPermissionDO> getPermissionByBizTypeAndUserId(Integer bizType, Long userId) {
|
||||
return crmPermissionMapper.selectByBizTypeAndUserId(bizType, userId);
|
||||
}
|
||||
|
||||
private void validateCrmPermissionExists(Long id) {
|
||||
if (crmPermissionMapper.selectById(id) == null) {
|
||||
throw exception(CRM_PERMISSION_NOT_EXISTS);
|
||||
|
Loading…
Reference in New Issue
Block a user