Commit c2fd8179891a061e2b9080ec1198871d145571f5
1 parent
e6eaa3a2
完善 CRM-客户 数据权限校验
Showing
23 changed files
with
129 additions
and
70 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| ... | ... | @@ -92,7 +92,7 @@ public class CrmBusinessController { |
| 92 | 92 | @Operation(summary = "商机转移") |
| 93 | 93 | @PreAuthorize("@ss.hasPermission('crm:business:update')") |
| 94 | 94 | public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferBusinessReqVO reqVO) { |
| 95 | - businessService.businessTransfer(reqVO, getLoginUserId()); | |
| 95 | + businessService.transferBusiness(reqVO, getLoginUserId()); | |
| 96 | 96 | return success(true); |
| 97 | 97 | } |
| 98 | 98 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java
| ... | ... | @@ -100,8 +100,8 @@ public class ContactController { |
| 100 | 100 | @PutMapping("/transfer") |
| 101 | 101 | @Operation(summary = "联系人转移") |
| 102 | 102 | @PreAuthorize("@ss.hasPermission('crm:contact:update')") |
| 103 | - public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) { | |
| 104 | - contactService.contactTransfer(reqVO, getLoginUserId()); | |
| 103 | + public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferContactReqVO reqVO) { | |
| 104 | + contactService.transferContact(reqVO, getLoginUserId()); | |
| 105 | 105 | return success(true); |
| 106 | 106 | } |
| 107 | 107 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java
| ... | ... | @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; |
| 7 | 7 | |
| 8 | 8 | @Schema(description = "管理后台 - 联系人转移 Request VO") |
| 9 | 9 | @Data |
| 10 | -public class CrmContactTransferReqVO { | |
| 10 | +public class CrmTransferContactReqVO { | |
| 11 | 11 | |
| 12 | 12 | @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 13 | 13 | @NotNull(message = "联系人编号不能为空") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java
| ... | ... | @@ -90,8 +90,8 @@ public class ContractController { |
| 90 | 90 | @PutMapping("/transfer") |
| 91 | 91 | @Operation(summary = "合同转移") |
| 92 | 92 | @PreAuthorize("@ss.hasPermission('crm:contract:update')") |
| 93 | - public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) { | |
| 94 | - contractService.contractTransfer(reqVO, getLoginUserId()); | |
| 93 | + public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferContractReqVO reqVO) { | |
| 94 | + contractService.transferContract(reqVO, getLoginUserId()); | |
| 95 | 95 | return success(true); |
| 96 | 96 | } |
| 97 | 97 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java
| ... | ... | @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; |
| 7 | 7 | |
| 8 | 8 | @Schema(description = "管理后台 - 合同转移 Request VO") |
| 9 | 9 | @Data |
| 10 | -public class CrmContractTransferReqVO { | |
| 10 | +public class CrmTransferContractReqVO { | |
| 11 | 11 | |
| 12 | 12 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 13 | 13 | @NotNull(message = "合同编号不能为空") |
| ... | ... | @@ -17,4 +17,12 @@ public class CrmContractTransferReqVO { |
| 17 | 17 | @NotNull(message = "新负责人的用户编号不能为空") |
| 18 | 18 | private Long ownerUserId; |
| 19 | 19 | |
| 20 | + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 21 | + @NotNull(message = "原负责人移除方式不能为空") | |
| 22 | + private Integer transferType; | |
| 23 | + | |
| 24 | + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 25 | + @NotNull(message = "权限类型不能为空") | |
| 26 | + private Integer permissionType; | |
| 27 | + | |
| 20 | 28 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| ... | ... | @@ -23,6 +23,7 @@ import java.util.List; |
| 23 | 23 | |
| 24 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | 25 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 26 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 26 | 27 | |
| 27 | 28 | @Tag(name = "管理后台 - 客户") |
| 28 | 29 | @RestController |
| ... | ... | @@ -37,7 +38,7 @@ public class CrmCustomerController { |
| 37 | 38 | @Operation(summary = "创建客户") |
| 38 | 39 | @PreAuthorize("@ss.hasPermission('crm:customer:create')") |
| 39 | 40 | public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) { |
| 40 | - return success(customerService.createCustomer(createReqVO)); | |
| 41 | + return success(customerService.createCustomer(createReqVO, getLoginUserId())); | |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | @PutMapping("/update") |
| ... | ... | @@ -86,4 +87,12 @@ public class CrmCustomerController { |
| 86 | 87 | ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas); |
| 87 | 88 | } |
| 88 | 89 | |
| 90 | + @PutMapping("/transfer") | |
| 91 | + @Operation(summary = "客户转移") | |
| 92 | + @PreAuthorize("@ss.hasPermission('crm:customer:update')") | |
| 93 | + public CommonResult<Boolean> transfer(@Valid @RequestBody CrmTransferCustomerReqVO reqVO) { | |
| 94 | + customerService.transferCustomer(reqVO, getLoginUserId()); | |
| 95 | + return success(true); | |
| 96 | + } | |
| 97 | + | |
| 89 | 98 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 客户转移 Request VO") | |
| 9 | +@Data | |
| 10 | +public class CrmTransferCustomerReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 13 | + @NotNull(message = "客户编号不能为空") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 17 | + @NotNull(message = "新负责人的用户编号不能为空") | |
| 18 | + private Long ownerUserId; | |
| 19 | + | |
| 20 | + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 21 | + @NotNull(message = "原负责人移除方式不能为空") | |
| 22 | + private Integer transferType; | |
| 23 | + | |
| 24 | + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 25 | + @NotNull(message = "权限类型不能为空") | |
| 26 | + private Integer permissionType; | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
| ... | ... | @@ -37,6 +37,6 @@ public interface ContactConvert { |
| 37 | 37 | @Mapping(target = "userId", source = "userId"), |
| 38 | 38 | @Mapping(target = "crmDataId", source = "reqVO.id") |
| 39 | 39 | }) |
| 40 | - TransferCrmPermissionBO convert(CrmContactTransferReqVO reqVO, Long userId); | |
| 40 | + TransferCrmPermissionBO convert(CrmTransferContactReqVO reqVO, Long userId); | |
| 41 | 41 | |
| 42 | 42 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java
| ... | ... | @@ -37,6 +37,6 @@ public interface ContractConvert { |
| 37 | 37 | @Mapping(target = "userId", source = "userId"), |
| 38 | 38 | @Mapping(target = "crmDataId", source = "reqVO.id") |
| 39 | 39 | }) |
| 40 | - TransferCrmPermissionBO convert(CrmContractTransferReqVO reqVO, Long userId); | |
| 40 | + TransferCrmPermissionBO convert(CrmTransferContractReqVO reqVO, Long userId); | |
| 41 | 41 | |
| 42 | 42 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.customer; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | - | |
| 7 | -import org.mapstruct.Mapper; | |
| 8 | -import org.mapstruct.factory.Mappers; | |
| 9 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 10 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 6 | +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; | |
| 7 | +import org.mapstruct.Mapper; | |
| 8 | +import org.mapstruct.Mapping; | |
| 9 | +import org.mapstruct.Mappings; | |
| 10 | +import org.mapstruct.factory.Mappers; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 11 | 13 | |
| 12 | 14 | /** |
| 13 | 15 | * 客户 Convert |
| ... | ... | @@ -29,4 +31,10 @@ public interface CrmCustomerConvert { |
| 29 | 31 | |
| 30 | 32 | List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); |
| 31 | 33 | |
| 34 | + @Mappings({ | |
| 35 | + @Mapping(target = "userId", source = "userId"), | |
| 36 | + @Mapping(target = "crmDataId", source = "reqVO.id") | |
| 37 | + }) | |
| 38 | + TransferCrmPermissionBO convert(CrmTransferCustomerReqVO reqVO, Long userId); | |
| 39 | + | |
| 32 | 40 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.clue; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * 线索 Mapper |
| ... | ... | @@ -35,7 +36,6 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { |
| 35 | 36 | .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) |
| 36 | 37 | .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) |
| 37 | 38 | .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) |
| 38 | - .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) | |
| 39 | 39 | .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) |
| 40 | 40 | .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) |
| 41 | 41 | .orderByDesc(CrmClueDO::getId)); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.contact; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * crm联系人 Mapper |
| ... | ... | @@ -28,7 +29,6 @@ public interface ContactMapper extends BaseMapperX<ContactDO> { |
| 28 | 29 | .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) |
| 29 | 30 | .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) |
| 30 | 31 | .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) |
| 31 | - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | |
| 32 | 32 | .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) |
| 33 | 33 | .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) |
| 34 | 34 | .orderByDesc(ContactDO::getId)); |
| ... | ... | @@ -45,7 +45,6 @@ public interface ContactMapper extends BaseMapperX<ContactDO> { |
| 45 | 45 | .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) |
| 46 | 46 | .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) |
| 47 | 47 | .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) |
| 48 | - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | |
| 49 | 48 | .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) |
| 50 | 49 | .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) |
| 51 | 50 | .orderByDesc(ContactDO::getId)); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -12,7 +12,6 @@ import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; |
| 12 | 12 | import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; |
| 13 | 13 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 14 | 14 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; |
| 15 | -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 16 | 15 | import org.springframework.stereotype.Service; |
| 17 | 16 | import org.springframework.transaction.annotation.Transactional; |
| 18 | 17 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -37,8 +36,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 37 | 36 | private CrmBusinessMapper businessMapper; |
| 38 | 37 | |
| 39 | 38 | @Resource |
| 40 | - private AdminUserApi adminUserApi; | |
| 41 | - @Resource | |
| 42 | 39 | private CrmPermissionService crmPermissionService; |
| 43 | 40 | |
| 44 | 41 | @Override |
| ... | ... | @@ -111,7 +108,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 111 | 108 | |
| 112 | 109 | @Override |
| 113 | 110 | @Transactional(rollbackFor = Exception.class) |
| 114 | - public void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId) { | |
| 111 | + public void transferBusiness(CrmTransferBusinessReqVO reqVO, Long userId) { | |
| 115 | 112 | // 1 校验商机是否存在 |
| 116 | 113 | validateBusinessExists(reqVO.getId()); |
| 117 | 114 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
| ... | ... | @@ -109,7 +109,7 @@ public class ContactServiceImpl implements ContactService { |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | @Override |
| 112 | - public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { | |
| 112 | + public void transferContact(CrmTransferContactReqVO reqVO, Long userId) { | |
| 113 | 113 | // 1 校验联系人是否存在 |
| 114 | 114 | validateContactExists(reqVO.getId()); |
| 115 | 115 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java
| ... | ... | @@ -107,7 +107,7 @@ public class ContractServiceImpl implements ContractService { |
| 107 | 107 | |
| 108 | 108 | @Override |
| 109 | 109 | @Transactional(rollbackFor = Exception.class) |
| 110 | - public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { | |
| 110 | + public void transferContract(CrmTransferContractReqVO reqVO, Long userId) { | |
| 111 | 111 | // 1 校验合同是否存在 |
| 112 | 112 | validateContractExists(reqVO.getId()); |
| 113 | 113 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | |
| 8 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | 6 | |
| 10 | 7 | import javax.validation.Valid; |
| ... | ... | @@ -22,9 +19,10 @@ public interface CrmCustomerService { |
| 22 | 19 | * 创建客户 |
| 23 | 20 | * |
| 24 | 21 | * @param createReqVO 创建信息 |
| 22 | + * @param userId 用户编号 | |
| 25 | 23 | * @return 编号 |
| 26 | 24 | */ |
| 27 | - Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO); | |
| 25 | + Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO, Long userId); | |
| 28 | 26 | |
| 29 | 27 | /** |
| 30 | 28 | * 更新客户 |
| ... | ... | @@ -80,4 +78,12 @@ public interface CrmCustomerService { |
| 80 | 78 | */ |
| 81 | 79 | CrmCustomerDO validateCustomer(Long customerId); |
| 82 | 80 | |
| 81 | + /** | |
| 82 | + * 客户转移 | |
| 83 | + * | |
| 84 | + * @param reqVO 请求 | |
| 85 | + * @param userId 用户编号 | |
| 86 | + */ | |
| 87 | + void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId); | |
| 88 | + | |
| 83 | 89 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -3,15 +3,18 @@ package cn.iocoder.yudao.module.crm.service.customer; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; | |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | |
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | |
| 10 | 7 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 11 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 12 | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; |
| 10 | +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | |
| 11 | +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; | |
| 12 | +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; | |
| 13 | +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | |
| 14 | +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; | |
| 13 | 15 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 14 | 16 | import org.springframework.stereotype.Service; |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | 18 | import org.springframework.validation.annotation.Validated; |
| 16 | 19 | |
| 17 | 20 | import javax.annotation.Resource; |
| ... | ... | @@ -35,17 +38,26 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 35 | 38 | private CrmCustomerMapper customerMapper; |
| 36 | 39 | @Resource |
| 37 | 40 | private DeptApi deptApi; // TODO @wanwan:拼接数据,可以放到 controller;所以这里的引入,可以考虑放到 controller 哈; |
| 41 | + @Resource | |
| 42 | + private CrmPermissionService crmPermissionService; | |
| 38 | 43 | |
| 39 | 44 | @Override |
| 40 | - public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { | |
| 45 | + public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) { | |
| 41 | 46 | // 插入 |
| 42 | 47 | CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO); |
| 43 | 48 | customerMapper.insert(customer); |
| 49 | + | |
| 50 | + // 创建数据权限 | |
| 51 | + crmPermissionService.createCrmPermission(new CrmPermissionCreateBO().setCrmType(CrmEnum.CRM_CUSTOMER.getType()) | |
| 52 | + .setCrmDataId(customer.getId()).setOwnerUserId(userId)); // 设置当前操作的人为负责人 | |
| 53 | + | |
| 44 | 54 | // 返回 |
| 45 | 55 | return customer.getId(); |
| 46 | 56 | } |
| 47 | 57 | |
| 48 | 58 | @Override |
| 59 | + @Transactional(rollbackFor = Exception.class) | |
| 60 | + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.UPDATE) | |
| 49 | 61 | public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { |
| 50 | 62 | // 校验存在 |
| 51 | 63 | validateCustomerExists(updateReqVO.getId()); |
| ... | ... | @@ -57,6 +69,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 57 | 69 | } |
| 58 | 70 | |
| 59 | 71 | @Override |
| 72 | + @Transactional(rollbackFor = Exception.class) | |
| 73 | + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.DELETE) | |
| 60 | 74 | public void deleteCustomer(Long id) { |
| 61 | 75 | // 校验存在 |
| 62 | 76 | validateCustomerExists(id); |
| ... | ... | @@ -73,6 +87,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 73 | 87 | } |
| 74 | 88 | |
| 75 | 89 | @Override |
| 90 | + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.READ) | |
| 76 | 91 | public CrmCustomerDO getCustomer(Long id) { |
| 77 | 92 | return customerMapper.selectById(id); |
| 78 | 93 | } |
| ... | ... | @@ -112,4 +127,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 112 | 127 | return customer; |
| 113 | 128 | } |
| 114 | 129 | |
| 130 | + @Override | |
| 131 | + @Transactional(rollbackFor = Exception.class) | |
| 132 | + public void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId) { | |
| 133 | + // 1 校验合同是否存在 | |
| 134 | + validateCustomer(reqVO.getId()); | |
| 135 | + | |
| 136 | + // 2. 数据权限转移 | |
| 137 | + crmPermissionService.transferCrmPermission( | |
| 138 | + CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setCrmType(CrmEnum.CRM_CUSTOMER.getType())); | |
| 139 | + } | |
| 140 | + | |
| 115 | 141 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java
| ... | ... | @@ -115,10 +115,7 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { |
| 115 | 115 | o.setDiscountPercent(null); |
| 116 | 116 | o.setProductPrice(null); |
| 117 | 117 | o.setRemark(null); |
| 118 | - o.setOwnerUserId(null); | |
| 119 | 118 | o.setCreateTime(null); |
| 120 | - o.setRoUserIds(null); | |
| 121 | - o.setRwUserIds(null); | |
| 122 | 119 | o.setEndStatus(null); |
| 123 | 120 | o.setEndRemark(null); |
| 124 | 121 | o.setContactLastTime(null); |
| ... | ... | @@ -145,14 +142,8 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { |
| 145 | 142 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); |
| 146 | 143 | // 测试 remark 不匹配 |
| 147 | 144 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); |
| 148 | - // 测试 ownerUserId 不匹配 | |
| 149 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); | |
| 150 | 145 | // 测试 createTime 不匹配 |
| 151 | 146 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); |
| 152 | - // 测试 roUserIds 不匹配 | |
| 153 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); | |
| 154 | - // 测试 rwUserIds 不匹配 | |
| 155 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); | |
| 156 | 147 | // 测试 endStatus 不匹配 |
| 157 | 148 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); |
| 158 | 149 | // 测试 endRemark 不匹配 |
| ... | ... | @@ -205,10 +196,7 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { |
| 205 | 196 | o.setDiscountPercent(null); |
| 206 | 197 | o.setProductPrice(null); |
| 207 | 198 | o.setRemark(null); |
| 208 | - o.setOwnerUserId(null); | |
| 209 | 199 | o.setCreateTime(null); |
| 210 | - o.setRoUserIds(null); | |
| 211 | - o.setRwUserIds(null); | |
| 212 | 200 | o.setEndStatus(null); |
| 213 | 201 | o.setEndRemark(null); |
| 214 | 202 | o.setContactLastTime(null); |
| ... | ... | @@ -235,14 +223,8 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { |
| 235 | 223 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); |
| 236 | 224 | // 测试 remark 不匹配 |
| 237 | 225 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); |
| 238 | - // 测试 ownerUserId 不匹配 | |
| 239 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); | |
| 240 | 226 | // 测试 createTime 不匹配 |
| 241 | 227 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); |
| 242 | - // 测试 roUserIds 不匹配 | |
| 243 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); | |
| 244 | - // 测试 rwUserIds 不匹配 | |
| 245 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); | |
| 246 | 228 | // 测试 endStatus 不匹配 |
| 247 | 229 | businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); |
| 248 | 230 | // 测试 endRemark 不匹配 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java
| ... | ... | @@ -115,7 +115,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { |
| 115 | 115 | o.setTelephone(null); |
| 116 | 116 | o.setMobile(null); |
| 117 | 117 | o.setAddress(null); |
| 118 | - o.setOwnerUserId(null); | |
| 119 | 118 | o.setContactLastTime(null); |
| 120 | 119 | o.setCreateTime(null); |
| 121 | 120 | }); |
| ... | ... | @@ -136,8 +135,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { |
| 136 | 135 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); |
| 137 | 136 | // 测试 address 不匹配 |
| 138 | 137 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); |
| 139 | - // 测试 ownerUserId 不匹配 | |
| 140 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); | |
| 141 | 138 | // 测试 contactLastTime 不匹配 |
| 142 | 139 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); |
| 143 | 140 | // 测试 createTime 不匹配 |
| ... | ... | @@ -169,7 +166,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { |
| 169 | 166 | o.setTelephone(null); |
| 170 | 167 | o.setMobile(null); |
| 171 | 168 | o.setAddress(null); |
| 172 | - o.setOwnerUserId(null); | |
| 173 | 169 | o.setContactLastTime(null); |
| 174 | 170 | o.setCreateTime(null); |
| 175 | 171 | }); |
| ... | ... | @@ -190,8 +186,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { |
| 190 | 186 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); |
| 191 | 187 | // 测试 address 不匹配 |
| 192 | 188 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); |
| 193 | - // 测试 ownerUserId 不匹配 | |
| 194 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); | |
| 195 | 189 | // 测试 contactLastTime 不匹配 |
| 196 | 190 | clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); |
| 197 | 191 | // 测试 createTime 不匹配 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java
| ... | ... | @@ -16,6 +16,7 @@ import javax.annotation.Resource; |
| 16 | 16 | import java.util.List; |
| 17 | 17 | |
| 18 | 18 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 19 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 19 | 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 20 | 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 21 | 22 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| ... | ... | @@ -24,6 +25,7 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_ |
| 24 | 25 | import static org.junit.jupiter.api.Assertions.*; |
| 25 | 26 | |
| 26 | 27 | // TODO 芋艿:单测后续补 |
| 28 | + | |
| 27 | 29 | /** |
| 28 | 30 | * {@link CrmCustomerServiceImpl} 的单元测试类 |
| 29 | 31 | * |
| ... | ... | @@ -44,7 +46,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { |
| 44 | 46 | CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class); |
| 45 | 47 | |
| 46 | 48 | // 调用 |
| 47 | - Long customerId = customerService.createCustomer(reqVO); | |
| 49 | + Long customerId = customerService.createCustomer(reqVO, getLoginUserId()); | |
| 48 | 50 | // 断言 |
| 49 | 51 | assertNotNull(customerId); |
| 50 | 52 | // 校验记录的属性是否正确 | ... | ... |