Commit f76a7cd94125022cf422e3e150f349e5cd4eb8e9
1 parent
e01dda9b
✨ CRM:重构商机状态的代码实现,不调整表结构
Showing
28 changed files
with
380 additions
and
749 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -22,8 +22,6 @@ public interface ErrorCodeConstants { | @@ -22,8 +22,6 @@ public interface ErrorCodeConstants { | ||
| 22 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); | 22 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); |
| 23 | ErrorCode BUSINESS_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); | 23 | ErrorCode BUSINESS_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); |
| 24 | 24 | ||
| 25 | - // TODO @lilleo:商机状态、商机类型,都单独错误码段 | ||
| 26 | - | ||
| 27 | // ========== 联系人管理 1-020-003-000 ========== | 25 | // ========== 联系人管理 1-020-003-000 ========== |
| 28 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | 26 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); |
| 29 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode(1_020_003_001, "联系人商机关联不存在"); | 27 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode(1_020_003_001, "联系人商机关联不存在"); |
| @@ -77,12 +75,11 @@ public interface ErrorCodeConstants { | @@ -77,12 +75,11 @@ public interface ErrorCodeConstants { | ||
| 77 | ErrorCode PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_020_009_004, "父分类不能是二级分类"); | 75 | ErrorCode PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_020_009_004, "父分类不能是二级分类"); |
| 78 | ErrorCode product_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_020_009_005, "存在子分类,无法删除"); | 76 | ErrorCode product_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_020_009_005, "存在子分类,无法删除"); |
| 79 | 77 | ||
| 80 | - // ========== 商机状态类型 1_020_010_000 ========== | ||
| 81 | - ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态类型不存在"); | ||
| 82 | - ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态类型名称已存在"); | ||
| 83 | - | ||
| 84 | - // ========== 商机状态 1_020_011_000 ========== | ||
| 85 | - ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_011_000, "商机状态不存在"); | 78 | + // ========== 商机状态 1_020_010_000 ========== |
| 79 | + ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态组不存在"); | ||
| 80 | + ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态组的名称已存在"); | ||
| 81 | + ErrorCode BUSINESS_STATUS_UPDATE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行更新"); | ||
| 82 | + ErrorCode BUSINESS_STATUS_DELETE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行删除"); | ||
| 86 | 83 | ||
| 87 | // ========== 客户公海规则设置 1_020_012_000 ========== | 84 | // ========== 客户公海规则设置 1_020_012_000 ========== |
| 88 | ErrorCode CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED = new ErrorCode(1_020_012_000, "客户公海配置不存在或未启用"); | 85 | ErrorCode CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED = new ErrorCode(1_020_012_000, "客户公海配置不存在或未启用"); |
| @@ -92,6 +89,4 @@ public interface ErrorCodeConstants { | @@ -92,6 +89,4 @@ public interface ErrorCodeConstants { | ||
| 92 | ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在"); | 89 | ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在"); |
| 93 | ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限"); | 90 | ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限"); |
| 94 | 91 | ||
| 95 | - // ========== 待办消息 1_020_014_000 ========== | ||
| 96 | - | ||
| 97 | } | 92 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http deleted
| 1 | -### 请求 /transfer | ||
| 2 | -PUT {{baseUrl}}/crm/business/transfer | ||
| 3 | -Content-Type: application/json | ||
| 4 | -Authorization: Bearer {{token}} | ||
| 5 | -tenant-id: {{adminTenentId}} | ||
| 6 | - | ||
| 7 | -{ | ||
| 8 | - "id": 1, | ||
| 9 | - "ownerUserId": 2, | ||
| 10 | - "transferType": 2, | ||
| 11 | - "permissionType": 2 | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -### 请求 /update | ||
| 15 | -PUT {{baseUrl}}/crm/business/update | ||
| 16 | -Content-Type: application/json | ||
| 17 | -Authorization: Bearer {{token}} | ||
| 18 | -tenant-id: {{adminTenentId}} | ||
| 19 | - | ||
| 20 | -{ | ||
| 21 | - "id": 1, | ||
| 22 | - "name": "2", | ||
| 23 | - "statusTypeId": 2, | ||
| 24 | - "statusId": 2, | ||
| 25 | - "customerId": 1 | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -### 请求 /get | ||
| 29 | -GET {{baseUrl}}/crm/business/get?id=1024 | ||
| 30 | -Content-Type: application/json | ||
| 31 | -Authorization: Bearer {{token}} | ||
| 32 | -tenant-id: {{adminTenentId}} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -20,7 +20,6 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | @@ -20,7 +20,6 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 20 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | 20 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| 21 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | 21 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 22 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; | 22 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; |
| 23 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService; | ||
| 24 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 23 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 25 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | 24 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; |
| 26 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 25 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| @@ -62,7 +61,7 @@ public class CrmBusinessController { | @@ -62,7 +61,7 @@ public class CrmBusinessController { | ||
| 62 | @Resource | 61 | @Resource |
| 63 | private CrmCustomerService customerService; | 62 | private CrmCustomerService customerService; |
| 64 | @Resource | 63 | @Resource |
| 65 | - private CrmBusinessStatusTypeService businessStatusTypeService; | 64 | + private CrmBusinessStatusService businessStatusTypeService; |
| 66 | @Resource | 65 | @Resource |
| 67 | private CrmBusinessStatusService businessStatusService; | 66 | private CrmBusinessStatusService businessStatusService; |
| 68 | @Resource | 67 | @Resource |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.business; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | ||
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 11 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 12 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; | ||
| 13 | +import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||
| 14 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||
| 15 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 16 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 17 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 18 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 19 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 20 | +import jakarta.annotation.Resource; | ||
| 21 | +import jakarta.validation.Valid; | ||
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 23 | +import org.springframework.validation.annotation.Validated; | ||
| 24 | +import org.springframework.web.bind.annotation.*; | ||
| 25 | + | ||
| 26 | +import java.util.Collection; | ||
| 27 | +import java.util.List; | ||
| 28 | +import java.util.Map; | ||
| 29 | + | ||
| 30 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 31 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | ||
| 32 | + | ||
| 33 | +@Tag(name = "管理后台 - CRM 商机状态") | ||
| 34 | +@RestController | ||
| 35 | +@RequestMapping("/crm/business-status") | ||
| 36 | +@Validated | ||
| 37 | +public class CrmBusinessStatusController { | ||
| 38 | + | ||
| 39 | + @Resource | ||
| 40 | + private CrmBusinessStatusService businessStatusTypeService; | ||
| 41 | + | ||
| 42 | + @Resource | ||
| 43 | + private AdminUserApi adminUserApi; | ||
| 44 | + @Resource | ||
| 45 | + private DeptApi deptApi; | ||
| 46 | + | ||
| 47 | + @PostMapping("/create") | ||
| 48 | + @Operation(summary = "创建商机状态") | ||
| 49 | + @PreAuthorize("@ss.hasPermission('crm:business-status:create')") | ||
| 50 | + public CommonResult<Long> createBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO createReqVO) { | ||
| 51 | + return success(businessStatusTypeService.createBusinessStatus(createReqVO)); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @PutMapping("/update") | ||
| 55 | + @Operation(summary = "更新商机状态") | ||
| 56 | + @PreAuthorize("@ss.hasPermission('crm:business-status:update')") | ||
| 57 | + public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO updateReqVO) { | ||
| 58 | + businessStatusTypeService.updateBusinessStatus(updateReqVO); | ||
| 59 | + return success(true); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @DeleteMapping("/delete") | ||
| 63 | + @Operation(summary = "删除商机状态") | ||
| 64 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 65 | + @PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')") | ||
| 66 | + public CommonResult<Boolean> deleteBusinessStatusType(@RequestParam("id") Long id) { | ||
| 67 | + businessStatusTypeService.deleteBusinessStatusType(id); | ||
| 68 | + return success(true); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @GetMapping("/get") | ||
| 72 | + @Operation(summary = "获得商机状态") | ||
| 73 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 74 | + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") | ||
| 75 | + public CommonResult<CrmBusinessStatusRespVO> getBusinessStatusType(@RequestParam("id") Long id) { | ||
| 76 | + CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id); | ||
| 77 | + if (statusType == null) { | ||
| 78 | + return success(null); | ||
| 79 | + } | ||
| 80 | + List<CrmBusinessStatusDO> statuses = businessStatusTypeService.getBusinessStatusListByTypeId(id); | ||
| 81 | + return success(BeanUtils.toBean(statusType, CrmBusinessStatusRespVO.class, | ||
| 82 | + statusTypeVO -> statusTypeVO.setStatuses(BeanUtils.toBean(statuses, CrmBusinessStatusRespVO.Status.class)))); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @GetMapping("/page") | ||
| 86 | + @Operation(summary = "获得商机状态分页") | ||
| 87 | + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") | ||
| 88 | + public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusTypePage(@Valid PageParam pageReqVO) { | ||
| 89 | + // 1. 查询数据 | ||
| 90 | + PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); | ||
| 91 | + // 2. 拼接数据 | ||
| 92 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||
| 93 | + convertSet(pageResult.getList(), statusType -> Long.parseLong(statusType.getCreator()))); | ||
| 94 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( | ||
| 95 | + convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds, Collection::stream)); | ||
| 96 | + return success(BeanUtils.toBean(pageResult, CrmBusinessStatusRespVO.class, statusTypeVO -> { | ||
| 97 | + statusTypeVO.setCreator(userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())).getNickname()); | ||
| 98 | + statusTypeVO.setDeptNames(convertList(statusTypeVO.getDeptIds(), | ||
| 99 | + deptId -> deptMap.containsKey(deptId) ? deptMap.get(deptId).getName() : null)); | ||
| 100 | + })); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @GetMapping("/type-simple-list") | ||
| 104 | + @Operation(summary = "获得商机状态列表") | ||
| 105 | + public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusTypeSimpleList() { | ||
| 106 | + List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(); | ||
| 107 | + return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.class)); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @GetMapping("/status-simple-list") | ||
| 111 | + @Operation(summary = "获得商机状态列表") | ||
| 112 | + @Parameter(name = "typeId", description = "商机状态组", required = true, example = "1024") | ||
| 113 | + public CommonResult<List<CrmBusinessStatusRespVO.Status>> getBusinessStatusSimpleList(@RequestParam("typeId") Long typeId) { | ||
| 114 | + List<CrmBusinessStatusDO> list = businessStatusTypeService.getBusinessStatusListByTypeId(typeId); | ||
| 115 | + return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.Status.class)); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 8 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 9 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 10 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 11 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; | ||
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; | ||
| 13 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | ||
| 15 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO; | ||
| 16 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; | ||
| 17 | -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessStatusConvert; | ||
| 18 | -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessStatusTypeConvert; | ||
| 19 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 20 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 21 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; | ||
| 22 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService; | ||
| 23 | -import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||
| 24 | -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||
| 25 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 26 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 27 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 28 | -import jakarta.annotation.Resource; | ||
| 29 | -import jakarta.servlet.http.HttpServletResponse; | ||
| 30 | -import jakarta.validation.Valid; | ||
| 31 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 32 | -import org.springframework.validation.annotation.Validated; | ||
| 33 | -import org.springframework.web.bind.annotation.*; | ||
| 34 | - | ||
| 35 | -import java.io.IOException; | ||
| 36 | -import java.util.Collection; | ||
| 37 | -import java.util.List; | ||
| 38 | -import java.util.Set; | ||
| 39 | - | ||
| 40 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 41 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 42 | - | ||
| 43 | -@Tag(name = "管理后台 - CRM 商机状态类型") | ||
| 44 | -@RestController | ||
| 45 | -@RequestMapping("/crm/business-status-type") | ||
| 46 | -@Validated | ||
| 47 | -public class CrmBusinessStatusTypeController { | ||
| 48 | - | ||
| 49 | - @Resource | ||
| 50 | - private CrmBusinessStatusTypeService businessStatusTypeService; | ||
| 51 | - | ||
| 52 | - @Resource | ||
| 53 | - private CrmBusinessStatusService businessStatusService; | ||
| 54 | - | ||
| 55 | - @Resource | ||
| 56 | - private DeptApi deptApi; | ||
| 57 | - | ||
| 58 | - @PostMapping("/create") | ||
| 59 | - @Operation(summary = "创建商机状态类型") | ||
| 60 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:create')") | ||
| 61 | - public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) { | ||
| 62 | - return success(businessStatusTypeService.createBusinessStatusType(createReqVO)); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @PutMapping("/update") | ||
| 66 | - @Operation(summary = "更新商机状态类型") | ||
| 67 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')") | ||
| 68 | - public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO updateReqVO) { | ||
| 69 | - businessStatusTypeService.updateBusinessStatusType(updateReqVO); | ||
| 70 | - return success(true); | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - @DeleteMapping("/delete") | ||
| 74 | - @Operation(summary = "删除商机状态类型") | ||
| 75 | - @Parameter(name = "id", description = "编号", required = true) | ||
| 76 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')") | ||
| 77 | - public CommonResult<Boolean> deleteBusinessStatusType(@RequestParam("id") Long id) { | ||
| 78 | - businessStatusTypeService.deleteBusinessStatusType(id); | ||
| 79 | - return success(true); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - @GetMapping("/get") | ||
| 83 | - @Operation(summary = "获得商机状态类型") | ||
| 84 | - @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 85 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") | ||
| 86 | - public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) { | ||
| 87 | - CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id); | ||
| 88 | - // 处理状态回显 | ||
| 89 | - // TODO @lzxhqs:可以在 businessStatusService 加个 getBusinessStatusListByTypeId 方法,直接返回 List<CrmBusinessStatusDO> 哈,常用的,尽量封装个简单易懂的方法,不用追求绝对通用哈; | ||
| 90 | - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); | ||
| 91 | - queryVO.setTypeId(id); | ||
| 92 | - List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO); | ||
| 93 | - return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(statusType, statusList)); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - @GetMapping("/page") | ||
| 97 | - @Operation(summary = "获得商机状态类型分页") | ||
| 98 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") | ||
| 99 | - public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) { | ||
| 100 | - PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); | ||
| 101 | - // 处理部门回显 | ||
| 102 | - Set<Long> deptIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds,Collection::stream); | ||
| 103 | - List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds); | ||
| 104 | - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList)); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - @GetMapping("/export-excel") | ||
| 108 | - @Operation(summary = "导出商机状态类型 Excel") | ||
| 109 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:export')") | ||
| 110 | - @OperateLog(type = EXPORT) | ||
| 111 | - public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypePageReqVO pageReqVO, | ||
| 112 | - HttpServletResponse response) throws IOException { | ||
| 113 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 114 | - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList(); | ||
| 115 | - // 导出 Excel | ||
| 116 | - ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeRespVO.class, | ||
| 117 | - BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class)); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - @GetMapping("/get-simple-list") | ||
| 121 | - @Operation(summary = "获得商机状态类型列表") | ||
| 122 | - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") | ||
| 123 | - public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() { | ||
| 124 | - CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO(); | ||
| 125 | - queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 126 | - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.selectList(queryVO); | ||
| 127 | - return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class)); | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - // TODO @ljlleo 这个接口,是不是可以和 getBusinessStatusTypeList 合并成一个? | ||
| 131 | - @GetMapping("/get-status-list") | ||
| 132 | - @Operation(summary = "获得商机状态列表") | ||
| 133 | - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") | ||
| 134 | - public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) { | ||
| 135 | - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); | ||
| 136 | - queryVO.setTypeId(typeId); | ||
| 137 | - List<CrmBusinessStatusDO> list = businessStatusService.selectList(queryVO); | ||
| 138 | - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java
| @@ -52,10 +52,10 @@ public class CrmBusinessRespVO { | @@ -52,10 +52,10 @@ public class CrmBusinessRespVO { | ||
| 52 | @ExcelProperty("负责人部门") | 52 | @ExcelProperty("负责人部门") |
| 53 | private String ownerUserDeptName; | 53 | private String ownerUserDeptName; |
| 54 | 54 | ||
| 55 | - @Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") | 55 | + @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") |
| 56 | private Long statusTypeId; | 56 | private Long statusTypeId; |
| 57 | - @Schema(description = "状态类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") | ||
| 58 | - @ExcelProperty("商机状态类型") | 57 | + @Schema(description = "商机状组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") |
| 58 | + @ExcelProperty("商机状态组") | ||
| 59 | private String statusTypeName; | 59 | private String statusTypeName; |
| 60 | 60 | ||
| 61 | @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | 61 | @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java
| @@ -43,9 +43,9 @@ public class CrmBusinessSaveReqVO { | @@ -43,9 +43,9 @@ public class CrmBusinessSaveReqVO { | ||
| 43 | @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) | 43 | @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) |
| 44 | private Long ownerUserId; | 44 | private Long ownerUserId; |
| 45 | 45 | ||
| 46 | - @Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") | ||
| 47 | - @DiffLogField(name = "商机状态") | ||
| 48 | - @NotNull(message = "商机状态类型不能为空") | 46 | + @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") |
| 47 | + @DiffLogField(name = "商机状态组") | ||
| 48 | + @NotNull(message = "商机状态组不能为空") | ||
| 49 | private Long statusTypeId; | 49 | private Long statusTypeId; |
| 50 | 50 | ||
| 51 | @Schema(description = "预计成交日期") | 51 | @Schema(description = "预计成交日期") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - 商机状态分页 Request VO") | ||
| 10 | -@Data | ||
| 11 | -@EqualsAndHashCode(callSuper = true) | ||
| 12 | -@ToString(callSuper = true) | ||
| 13 | -public class CrmBusinessStatusPageReqVO extends PageParam { | ||
| 14 | - | ||
| 15 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusQueryVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.ToString; | ||
| 6 | - | ||
| 7 | -import java.util.Collection; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - 商机状态 Query VO") | ||
| 10 | -@Data | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class CrmBusinessStatusQueryVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "主键集合") | ||
| 15 | - private Collection<Long> idList; | ||
| 16 | - | ||
| 17 | - @Schema(description = "状态类型编号") | ||
| 18 | - private Long typeId; | ||
| 19 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; |
| 2 | 2 | ||
| 3 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.Data; | 4 | import lombok.Data; |
| 7 | 5 | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 8 | @Schema(description = "管理后台 - 商机状态 Response VO") | 10 | @Schema(description = "管理后台 - 商机状态 Response VO") |
| 9 | @Data | 11 | @Data |
| 10 | -@ExcelIgnoreUnannotated | ||
| 11 | public class CrmBusinessStatusRespVO { | 12 | public class CrmBusinessStatusRespVO { |
| 12 | 13 | ||
| 13 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899") | ||
| 14 | - @ExcelProperty("主键") | 14 | + @Schema(description = "状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") |
| 15 | private Long id; | 15 | private Long id; |
| 16 | 16 | ||
| 17 | - @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139") | ||
| 18 | - @ExcelProperty("状态类型编号") | ||
| 19 | - private Long typeId; | ||
| 20 | - | ||
| 21 | - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 22 | - @ExcelProperty("状态名") | 17 | + @Schema(description = "状态组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") |
| 23 | private String name; | 18 | private String name; |
| 24 | 19 | ||
| 25 | - @Schema(description = "赢单率") | ||
| 26 | - @ExcelProperty("赢单率") | ||
| 27 | - private String percent; | 20 | + @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| 21 | + private List<Long> deptIds; | ||
| 22 | + @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 23 | + private List<String> deptNames; | ||
| 24 | + | ||
| 25 | + @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 26 | + private String creator; | ||
| 27 | + | ||
| 28 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | + private LocalDateTime createTime; | ||
| 30 | + | ||
| 31 | + @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 32 | + private List<Status> statuses; | ||
| 33 | + | ||
| 34 | + @Data | ||
| 35 | + public static class Status { | ||
| 36 | + | ||
| 37 | + @Schema(description = "状态编号", example = "23899") | ||
| 38 | + private Long id; | ||
| 39 | + | ||
| 40 | + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 41 | + private String name; | ||
| 42 | + | ||
| 43 | + @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") | ||
| 44 | + private BigDecimal percent; | ||
| 45 | + | ||
| 46 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 47 | + private Integer sort; | ||
| 28 | 48 | ||
| 29 | - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 30 | - @ExcelProperty("排序") | ||
| 31 | - private Integer sort; | 49 | + } |
| 32 | 50 | ||
| 33 | } | 51 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 7 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | +import lombok.Data; | ||
| 8 | 7 | ||
| 9 | -@Schema(description = "管理后台 - 商机状态新增/修改 Request VO") | 8 | +import java.math.BigDecimal; |
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 商机状态组新增/修改 Request VO") | ||
| 10 | @Data | 12 | @Data |
| 11 | public class CrmBusinessStatusSaveReqVO { | 13 | public class CrmBusinessStatusSaveReqVO { |
| 12 | 14 | ||
| 13 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899") | 15 | + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") |
| 14 | private Long id; | 16 | private Long id; |
| 15 | 17 | ||
| 16 | - @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139") | ||
| 17 | - @NotNull(message = "状态类型编号不能为空") | ||
| 18 | - private Long typeId; | ||
| 19 | - | ||
| 20 | - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 21 | - @NotEmpty(message = "状态名不能为空") | 18 | + @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") |
| 19 | + @NotEmpty(message = "状态类型名不能为空") | ||
| 22 | private String name; | 20 | private String name; |
| 23 | 21 | ||
| 24 | - // TODO @lzxhqs::percent 应该是 Integer; | ||
| 25 | - @Schema(description = "赢单率") | ||
| 26 | - private String percent; | 22 | + @Schema(description = "使用的部门编号") |
| 23 | + private List<Long> deptIds; | ||
| 24 | + | ||
| 25 | + @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 26 | + @NotEmpty(message = "商机状态集合不能为空") | ||
| 27 | + private List<Status> statuses; | ||
| 28 | + | ||
| 29 | + @Data | ||
| 30 | + public static class Status { | ||
| 31 | + | ||
| 32 | + @Schema(description = "状态编号", example = "23899") | ||
| 33 | + private Long id; | ||
| 34 | + | ||
| 35 | + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 36 | + @NotEmpty(message = "状态名不能为空") | ||
| 37 | + private String name; | ||
| 38 | + | ||
| 39 | + @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") | ||
| 40 | + @NotNull(message = "赢单率不能为空") | ||
| 41 | + private BigDecimal percent; | ||
| 42 | + | ||
| 43 | + @Schema(description = "排序", hidden = true, example = "1") | ||
| 44 | + private Integer sort; | ||
| 27 | 45 | ||
| 28 | - // TODO @lzxhqs:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了; | ||
| 29 | - @Schema(description = "排序") | ||
| 30 | - private Integer sort; | 46 | + } |
| 31 | 47 | ||
| 32 | } | 48 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypePageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - 商机状态类型分页 Request VO") | ||
| 10 | -@Data | ||
| 11 | -@EqualsAndHashCode(callSuper = true) | ||
| 12 | -@ToString(callSuper = true) | ||
| 13 | -public class CrmBusinessStatusTypePageReqVO extends PageParam { | ||
| 14 | - | ||
| 15 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeQueryVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.ToString; | ||
| 6 | - | ||
| 7 | -import java.util.Collection; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - 商机状态类型 Query VO") | ||
| 10 | -@Data | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class CrmBusinessStatusTypeQueryVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "主键集合") | ||
| 15 | - private Collection<Long> idList; | ||
| 16 | - | ||
| 17 | - @Schema(description = "状态") | ||
| 18 | - private Integer status; | ||
| 19 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 4 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 5 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 6 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | -import lombok.Data; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -@Schema(description = "管理后台 - 商机状态类型 Response VO") | ||
| 13 | -@Data | ||
| 14 | -@ExcelIgnoreUnannotated | ||
| 15 | -public class CrmBusinessStatusTypeRespVO { | ||
| 16 | - | ||
| 17 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") | ||
| 18 | - @ExcelProperty("主键") | ||
| 19 | - private Long id; | ||
| 20 | - | ||
| 21 | - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 22 | - @ExcelProperty("状态类型名") | ||
| 23 | - private String name; | ||
| 24 | - | ||
| 25 | - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 26 | - @ExcelProperty("使用的部门编号") | ||
| 27 | - private List<Long> deptIds; | ||
| 28 | - @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | - @ExcelProperty("使用的部门名称") | ||
| 30 | - private List<String> deptNames; | ||
| 31 | - | ||
| 32 | - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | - @ExcelProperty("创建人") | ||
| 34 | - private String creator; | ||
| 35 | - | ||
| 36 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 37 | - @ExcelProperty("创建时间") | ||
| 38 | - private LocalDateTime createTime; | ||
| 39 | - | ||
| 40 | - // TODO @ljlleo 字段后缀改成 statuses,保持和 deptIds 风格一致;CrmBusinessStatusDO 改成 VO 哈;一般不使用 do 直接返回 | ||
| 41 | - @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 42 | - private List<CrmBusinessStatusDO> statusList; | ||
| 43 | - | ||
| 44 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeSaveReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; | ||
| 4 | -import com.google.common.collect.Lists; | ||
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | -import lombok.Data; | ||
| 7 | - | ||
| 8 | -import jakarta.validation.constraints.NotEmpty; | ||
| 9 | -import java.util.List; | ||
| 10 | - | ||
| 11 | -@Schema(description = "管理后台 - 商机状态类型新增/修改 Request VO") | ||
| 12 | -@Data | ||
| 13 | -public class CrmBusinessStatusTypeSaveReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") | ||
| 16 | - private Long id; | ||
| 17 | - | ||
| 18 | - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 19 | - @NotEmpty(message = "状态类型名不能为空") | ||
| 20 | - private String name; | ||
| 21 | - | ||
| 22 | - // TODO @lzxhqs: VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢 | ||
| 23 | - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | - private List<Long> deptIds = Lists.newArrayList(); | ||
| 25 | - | ||
| 26 | - @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 27 | - private List<CrmBusinessStatusSaveReqVO> statusList; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessStatusConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.business; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 6 | -import org.mapstruct.Mapper; | ||
| 7 | -import org.mapstruct.factory.Mappers; | ||
| 8 | - | ||
| 9 | -import java.util.List; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 商机状态 Convert | ||
| 13 | - * | ||
| 14 | - * @author ljlleo | ||
| 15 | - */ | ||
| 16 | -@Mapper | ||
| 17 | -public interface CrmBusinessStatusConvert { | ||
| 18 | - | ||
| 19 | - CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class); | ||
| 20 | - | ||
| 21 | - List<CrmBusinessStatusRespVO> convertList(List<CrmBusinessStatusDO> list); | ||
| 22 | - | ||
| 23 | - PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page); | ||
| 24 | - | ||
| 25 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessStatusTypeConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.business; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 7 | -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||
| 8 | -import org.mapstruct.Mapper; | ||
| 9 | -import org.mapstruct.factory.Mappers; | ||
| 10 | - | ||
| 11 | -import java.util.List; | ||
| 12 | -import java.util.Map; | ||
| 13 | - | ||
| 14 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 15 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 16 | - | ||
| 17 | -// TODO @lzxhqs:看看是不是用 BeanUtils 替代了 | ||
| 18 | -/** | ||
| 19 | - * 商机状态类型 Convert | ||
| 20 | - * | ||
| 21 | - * @author ljlleo | ||
| 22 | - */ | ||
| 23 | -@Mapper | ||
| 24 | -public interface CrmBusinessStatusTypeConvert { | ||
| 25 | - | ||
| 26 | - CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class); | ||
| 27 | - | ||
| 28 | - CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean); | ||
| 29 | - | ||
| 30 | - PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page); | ||
| 31 | - | ||
| 32 | - default PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page, List<DeptRespDTO> deptList) { | ||
| 33 | - PageResult<CrmBusinessStatusTypeRespVO> pageResult = convertPage(page); | ||
| 34 | - // 拼接关联字段 | ||
| 35 | - Map<Long, String> deptMap = convertMap(deptList, DeptRespDTO::getId, DeptRespDTO::getName); | ||
| 36 | - pageResult.getList().forEach(type -> type.setDeptNames(convertList(type.getDeptIds(), deptMap::get))); | ||
| 37 | - return pageResult; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) { | ||
| 41 | - return convert(bean).setStatusList(statusList); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java
| @@ -63,7 +63,7 @@ public class CrmBusinessDO extends BaseDO { | @@ -63,7 +63,7 @@ public class CrmBusinessDO extends BaseDO { | ||
| 63 | private Long ownerUserId; | 63 | private Long ownerUserId; |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 66 | - * 商机状态类型编号 | 66 | + * 商机状态组编号 |
| 67 | * | 67 | * |
| 68 | * 关联 {@link CrmBusinessStatusTypeDO#getId()} | 68 | * 关联 {@link CrmBusinessStatusTypeDO#getId()} |
| 69 | */ | 69 | */ |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java
| 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.business; | 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.business; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | 4 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 6 | import com.baomidou.mybatisplus.annotation.KeySequence; | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| @@ -12,7 +11,7 @@ import lombok.*; | @@ -12,7 +11,7 @@ import lombok.*; | ||
| 12 | import java.util.List; | 11 | import java.util.List; |
| 13 | 12 | ||
| 14 | /** | 13 | /** |
| 15 | - * 商机状态类型 DO | 14 | + * 商机状态组 DO |
| 16 | * | 15 | * |
| 17 | * @author ljlleo | 16 | * @author ljlleo |
| 18 | */ | 17 | */ |
| @@ -35,17 +34,11 @@ public class CrmBusinessStatusTypeDO extends BaseDO { | @@ -35,17 +34,11 @@ public class CrmBusinessStatusTypeDO extends BaseDO { | ||
| 35 | * 状态类型名 | 34 | * 状态类型名 |
| 36 | */ | 35 | */ |
| 37 | private String name; | 36 | private String name; |
| 37 | + | ||
| 38 | /** | 38 | /** |
| 39 | * 使用的部门编号 | 39 | * 使用的部门编号 |
| 40 | */ | 40 | */ |
| 41 | @TableField(typeHandler = LongListTypeHandler.class) | 41 | @TableField(typeHandler = LongListTypeHandler.class) |
| 42 | private List<Long> deptIds; | 42 | private List<Long> deptIds; |
| 43 | - /** | ||
| 44 | - * 开启状态 | ||
| 45 | - * | ||
| 46 | - * TODO 改成 Integer,关联 CommonStatus | ||
| 47 | - * 枚举 {@link CommonStatusEnum} | ||
| 48 | - */ | ||
| 49 | - private Boolean status; | ||
| 50 | 43 | ||
| 51 | } | 44 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| @@ -63,4 +63,8 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | @@ -63,4 +63,8 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | ||
| 63 | return selectJoinList(CrmBusinessDO.class, query); | 63 | return selectJoinList(CrmBusinessDO.class, query); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | + default Long selectCountByStatusTypeId(Long statusTypeId) { | ||
| 67 | + return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); | ||
| 68 | + } | ||
| 69 | + | ||
| 66 | } | 70 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java
| 1 | package cn.iocoder.yudao.module.crm.dal.mysql.business; | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.business; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | 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.business.vo.status.CrmBusinessStatusPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; | ||
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 5 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 6 | ||
| @@ -18,20 +14,12 @@ import java.util.List; | @@ -18,20 +14,12 @@ import java.util.List; | ||
| 18 | @Mapper | 14 | @Mapper |
| 19 | public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO> { | 15 | public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO> { |
| 20 | 16 | ||
| 21 | - default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) { | ||
| 22 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>() | ||
| 23 | - .orderByDesc(CrmBusinessStatusDO::getId)); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) { | ||
| 27 | - return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>() | ||
| 28 | - .eqIfPresent(CrmBusinessStatusDO::getTypeId, queryVO.getTypeId()) | ||
| 29 | - .inIfPresent(CrmBusinessStatusDO::getId, queryVO.getIdList()) | ||
| 30 | - .orderByDesc(CrmBusinessStatusDO::getId)); | 17 | + default int deleteByTypeId(Long typeId) { |
| 18 | + return delete(CrmBusinessStatusDO::getTypeId, typeId); | ||
| 31 | } | 19 | } |
| 32 | 20 | ||
| 33 | - default int delete(Long typeId) { | ||
| 34 | - return delete(CrmBusinessStatusDO::getTypeId, typeId); | 21 | + default List<CrmBusinessStatusDO> selectListByTypeId(Long typeId) { |
| 22 | + return selectList(CrmBusinessStatusDO::getTypeId, typeId); | ||
| 35 | } | 23 | } |
| 36 | 24 | ||
| 37 | } | 25 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java
| 1 | package cn.iocoder.yudao.module.crm.dal.mysql.business; | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.business; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | ||
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | /** | 10 | /** |
| 14 | - * 商机状态类型 Mapper | 11 | + * 商机状态组 Mapper |
| 15 | * | 12 | * |
| 16 | * @author ljlleo | 13 | * @author ljlleo |
| 17 | */ | 14 | */ |
| 18 | @Mapper | 15 | @Mapper |
| 19 | public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStatusTypeDO> { | 16 | public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStatusTypeDO> { |
| 20 | 17 | ||
| 21 | - default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) { | 18 | + default PageResult<CrmBusinessStatusTypeDO> selectPage(PageParam reqVO) { |
| 22 | return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>() | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>() |
| 23 | .orderByDesc(CrmBusinessStatusTypeDO::getId)); | 20 | .orderByDesc(CrmBusinessStatusTypeDO::getId)); |
| 24 | } | 21 | } |
| 25 | 22 | ||
| 26 | - default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) { | ||
| 27 | - return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>() | ||
| 28 | - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus()) | ||
| 29 | - .inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList())); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - // TODO @lzxhqs:这个可以改成 selectByName。业务上基于在判断 id 匹配;这样更通用一些;mapper 尽量通用,不关注或者特别关联业务; | ||
| 33 | - /** | ||
| 34 | - * 根据ID和name查询 | ||
| 35 | - * | ||
| 36 | - * @param id 商机状态类型id | ||
| 37 | - * @param name 状态类型名 | ||
| 38 | - * @return result | ||
| 39 | - */ | ||
| 40 | - default CrmBusinessStatusTypeDO selectByIdAndName(Long id, String name) { | ||
| 41 | - return selectOne(CrmBusinessStatusTypeDO::getId, id, CrmBusinessStatusTypeDO::getName, name); | 23 | + default CrmBusinessStatusTypeDO selectByName(String name) { |
| 24 | + return selectOne(CrmBusinessStatusTypeDO::getName, name); | ||
| 42 | } | 25 | } |
| 43 | 26 | ||
| 44 | } | 27 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| @@ -138,4 +138,12 @@ public interface CrmBusinessService { | @@ -138,4 +138,12 @@ public interface CrmBusinessService { | ||
| 138 | */ | 138 | */ |
| 139 | Long getBusinessCountByCustomerId(Long customerId); | 139 | Long getBusinessCountByCustomerId(Long customerId); |
| 140 | 140 | ||
| 141 | + /** | ||
| 142 | + * 获得使用指定商机状态组的商机数量 | ||
| 143 | + * | ||
| 144 | + * @param statusTypeId 商机状态组编号 | ||
| 145 | + * @return 数量 | ||
| 146 | + */ | ||
| 147 | + Long getBusinessCountByStatusTypeId(Long statusTypeId); | ||
| 148 | + | ||
| 141 | } | 149 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -295,4 +295,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -295,4 +295,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 295 | return businessMapper.selectCount(CrmBusinessDO::getCustomerId, customerId); | 295 | return businessMapper.selectCount(CrmBusinessDO::getCustomerId, customerId); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | + @Override | ||
| 299 | + public Long getBusinessCountByStatusTypeId(Long statusTypeId) { | ||
| 300 | + return businessMapper.selectCountByStatusTypeId(statusTypeId); | ||
| 301 | + } | ||
| 302 | + | ||
| 298 | } | 303 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java
| 1 | package cn.iocoder.yudao.module.crm.service.business; | 1 | package cn.iocoder.yudao.module.crm.service.business; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 8 | import jakarta.validation.Valid; | 8 | import jakarta.validation.Valid; |
| 9 | 9 | ||
| 10 | import java.util.Collection; | 10 | import java.util.Collection; |
| @@ -40,33 +40,56 @@ public interface CrmBusinessStatusService { | @@ -40,33 +40,56 @@ public interface CrmBusinessStatusService { | ||
| 40 | * | 40 | * |
| 41 | * @param id 编号 | 41 | * @param id 编号 |
| 42 | */ | 42 | */ |
| 43 | - void deleteBusinessStatus(Long id); | 43 | + void deleteBusinessStatusType(Long id); |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | - * 获得商机状态 | 46 | + * 获得商机状态组 |
| 47 | * | 47 | * |
| 48 | * @param id 编号 | 48 | * @param id 编号 |
| 49 | - * @return 商机状态 | 49 | + * @return 商机状态组 |
| 50 | */ | 50 | */ |
| 51 | - CrmBusinessStatusDO getBusinessStatus(Long id); | 51 | + CrmBusinessStatusTypeDO getBusinessStatusType(Long id); |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | - * 获得商机状态分页 | 54 | + * 获得商机状态组列表 |
| 55 | + * | ||
| 56 | + * @return 商机状态组列表 | ||
| 57 | + */ | ||
| 58 | + List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(); | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 获得商机状态组分页 | ||
| 55 | * | 62 | * |
| 56 | * @param pageReqVO 分页查询 | 63 | * @param pageReqVO 分页查询 |
| 57 | - * @return 商机状态分页 | 64 | + * @return 商机状态组分页 |
| 65 | + */ | ||
| 66 | + PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(PageParam pageReqVO); | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * 获得商机状态组列表 | ||
| 70 | + * | ||
| 71 | + * @param ids 编号数组 | ||
| 72 | + * @return 商机状态组列表 | ||
| 73 | + */ | ||
| 74 | + List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids); | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 获得商机状态组 Map | ||
| 78 | + * | ||
| 79 | + * @param ids 编号数组 | ||
| 80 | + * @return 商机状态组 Map | ||
| 58 | */ | 81 | */ |
| 59 | - PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); | 82 | + default Map<Long, CrmBusinessStatusTypeDO> getBusinessStatusTypeMap(Collection<Long> ids) { |
| 83 | + return convertMap(getBusinessStatusTypeList(ids), CrmBusinessStatusTypeDO::getId); | ||
| 84 | + } | ||
| 60 | 85 | ||
| 61 | - // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。 | ||
| 62 | - // TODO @ljlleo 方法名用 getBusinessStatusList | ||
| 63 | /** | 86 | /** |
| 64 | - * 获得商机状态分页 | 87 | + * 获得指定类型的商机状态列表 |
| 65 | * | 88 | * |
| 66 | - * @param queryVO 查询参数 | ||
| 67 | - * @return 商机状态分页 | 89 | + * @param typeId 商机状态组编号 |
| 90 | + * @return 商机状态列表 | ||
| 68 | */ | 91 | */ |
| 69 | - List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO); | 92 | + List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Long typeId); |
| 70 | 93 | ||
| 71 | /** | 94 | /** |
| 72 | * 获得商机状态列表 | 95 | * 获得商机状态列表 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java
| 1 | package cn.iocoder.yudao.module.crm.service.business; | 1 | package cn.iocoder.yudao.module.crm.service.business; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; | ||
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 10 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; | 10 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; |
| 11 | +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; | ||
| 12 | +import jakarta.annotation.Resource; | ||
| 13 | +import org.springframework.context.annotation.Lazy; | ||
| 11 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 15 | +import org.springframework.transaction.annotation.Transactional; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 13 | 17 | ||
| 14 | -import jakarta.annotation.Resource; | ||
| 15 | - | ||
| 16 | import java.util.Collection; | 18 | import java.util.Collection; |
| 17 | import java.util.Collections; | 19 | import java.util.Collections; |
| 20 | +import java.util.Comparator; | ||
| 18 | import java.util.List; | 21 | import java.util.List; |
| 19 | 22 | ||
| 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS; | 24 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 25 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; | ||
| 26 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||
| 22 | 27 | ||
| 23 | /** | 28 | /** |
| 24 | * 商机状态 Service 实现类 | 29 | * 商机状态 Service 实现类 |
| @@ -30,54 +35,134 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STAT | @@ -30,54 +35,134 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STAT | ||
| 30 | public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { | 35 | public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { |
| 31 | 36 | ||
| 32 | @Resource | 37 | @Resource |
| 38 | + private CrmBusinessStatusTypeMapper businessStatusTypeMapper; | ||
| 39 | + @Resource | ||
| 33 | private CrmBusinessStatusMapper businessStatusMapper; | 40 | private CrmBusinessStatusMapper businessStatusMapper; |
| 34 | 41 | ||
| 42 | + @Resource | ||
| 43 | + @Lazy // 延迟加载,避免循环依赖 | ||
| 44 | + private CrmBusinessService businessService; | ||
| 45 | + | ||
| 35 | @Override | 46 | @Override |
| 47 | + @Transactional(rollbackFor = Exception.class) | ||
| 36 | public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) { | 48 | public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) { |
| 37 | - // 插入 | ||
| 38 | - CrmBusinessStatusDO businessStatus = BeanUtils.toBean(createReqVO, CrmBusinessStatusDO.class); | ||
| 39 | - businessStatusMapper.insert(businessStatus); | ||
| 40 | - // 返回 | ||
| 41 | - return businessStatus.getId(); | 49 | + // 1.1 检验名称是否存在 |
| 50 | + validateBusinessStatusTypeNameUnique(createReqVO.getName(), null); | ||
| 51 | + // 1.2 设置状态的排序 | ||
| 52 | + int sort = 0; | ||
| 53 | + for (CrmBusinessStatusSaveReqVO.Status status : createReqVO.getStatuses()) { | ||
| 54 | + status.setSort(sort++); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + // 2.1 插入类型 | ||
| 58 | + CrmBusinessStatusTypeDO statusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class); | ||
| 59 | + businessStatusTypeMapper.insert(statusType); | ||
| 60 | + // 2.2 插入状态 | ||
| 61 | + List<CrmBusinessStatusDO> statuses = BeanUtils.toBean(createReqVO.getStatuses(), CrmBusinessStatusDO.class, | ||
| 62 | + status -> status.setTypeId(statusType.getId())); | ||
| 63 | + businessStatusMapper.insertBatch(statuses); | ||
| 64 | + return statusType.getId(); | ||
| 42 | } | 65 | } |
| 43 | 66 | ||
| 44 | @Override | 67 | @Override |
| 68 | + @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) { | 69 | public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) { |
| 46 | - // 校验存在 | ||
| 47 | - validateBusinessStatusExists(updateReqVO.getId()); | ||
| 48 | - // 更新 | ||
| 49 | - CrmBusinessStatusDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusDO.class); | ||
| 50 | - businessStatusMapper.updateById(updateObj); | 70 | + // 1.1 校验存在 |
| 71 | + validateBusinessStatusTypeNameUnique(updateReqVO.getId()); | ||
| 72 | + // 1.2 校验名称是否存在 | ||
| 73 | + validateBusinessStatusTypeNameUnique(updateReqVO.getName(), updateReqVO.getId()); | ||
| 74 | + // 1.3 设置状态的排序 | ||
| 75 | + int sort = 0; | ||
| 76 | + for (CrmBusinessStatusSaveReqVO.Status status : updateReqVO.getStatuses()) { | ||
| 77 | + status.setSort(sort++); | ||
| 78 | + } | ||
| 79 | + // 1.4 已经使用,无法更新 | ||
| 80 | + if (businessService.getBusinessCountByStatusTypeId(updateReqVO.getId()) > 0) { | ||
| 81 | + throw exception(BUSINESS_STATUS_UPDATE_FAIL_USED); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + // 2.1 更新类型 | ||
| 85 | + CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class); | ||
| 86 | + businessStatusTypeMapper.updateById(updateObj); | ||
| 87 | + // 2.2 更新状态 | ||
| 88 | + updateBusinessStatus(updateReqVO.getId(), BeanUtils.toBean(updateReqVO.getStatuses(), CrmBusinessStatusDO.class)); | ||
| 51 | } | 89 | } |
| 52 | 90 | ||
| 53 | - @Override | ||
| 54 | - public void deleteBusinessStatus(Long id) { | ||
| 55 | - // 校验存在 | ||
| 56 | - validateBusinessStatusExists(id); | ||
| 57 | - // TODO @ljlleo 这里可以考虑,如果有商机在使用,不允许删除 | ||
| 58 | - // 删除 | ||
| 59 | - businessStatusMapper.deleteById(id); | 91 | + private void updateBusinessStatus(Long id, List<CrmBusinessStatusDO> newList) { |
| 92 | + List<CrmBusinessStatusDO> oldList = businessStatusMapper.selectListByTypeId(id); | ||
| 93 | + List<List<CrmBusinessStatusDO>> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 | ||
| 94 | + (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); | ||
| 95 | + if (CollUtil.isNotEmpty(diffList.get(0))) { | ||
| 96 | + diffList.get(0).forEach(o -> o.setTypeId(id)); | ||
| 97 | + businessStatusMapper.insertBatch(diffList.get(0)); | ||
| 98 | + } | ||
| 99 | + if (CollUtil.isNotEmpty(diffList.get(1))) { | ||
| 100 | + businessStatusMapper.updateBatch(diffList.get(1)); | ||
| 101 | + } | ||
| 102 | + if (CollUtil.isNotEmpty(diffList.get(2))) { | ||
| 103 | + businessStatusMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessStatusDO::getId)); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + private void validateBusinessStatusTypeNameUnique(Long id) { | ||
| 108 | + if (businessStatusTypeMapper.selectById(id) == null) { | ||
| 109 | + throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + private void validateBusinessStatusTypeNameUnique(String name, Long id) { | ||
| 114 | + CrmBusinessStatusTypeDO statusType = businessStatusTypeMapper.selectByName(name); | ||
| 115 | + if (statusType == null | ||
| 116 | + || statusType.getId().equals(id)) { | ||
| 117 | + return; | ||
| 118 | + } | ||
| 119 | + throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); | ||
| 60 | } | 120 | } |
| 61 | 121 | ||
| 62 | - private void validateBusinessStatusExists(Long id) { | ||
| 63 | - if (businessStatusMapper.selectById(id) == null) { | ||
| 64 | - throw exception(BUSINESS_STATUS_NOT_EXISTS); | 122 | + @Override |
| 123 | + @Transactional(rollbackFor = Exception.class) | ||
| 124 | + public void deleteBusinessStatusType(Long id) { | ||
| 125 | + // 1.1 校验存在 | ||
| 126 | + validateBusinessStatusTypeNameUnique(id); | ||
| 127 | + // 1.2 已经使用,无法更新 | ||
| 128 | + if (businessService.getBusinessCountByStatusTypeId(id) > 0) { | ||
| 129 | + throw exception(BUSINESS_STATUS_DELETE_FAIL_USED); | ||
| 65 | } | 130 | } |
| 131 | + | ||
| 132 | + // 2.1 删除类型 | ||
| 133 | + businessStatusTypeMapper.deleteById(id); | ||
| 134 | + // 2.2 删除状态 | ||
| 135 | + businessStatusMapper.deleteByTypeId(id); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + @Override | ||
| 139 | + public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { | ||
| 140 | + return businessStatusTypeMapper.selectById(id); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + @Override | ||
| 144 | + public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList() { | ||
| 145 | + return businessStatusTypeMapper.selectList(); | ||
| 66 | } | 146 | } |
| 67 | 147 | ||
| 68 | @Override | 148 | @Override |
| 69 | - public CrmBusinessStatusDO getBusinessStatus(Long id) { | ||
| 70 | - return businessStatusMapper.selectById(id); | 149 | + public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(PageParam pageReqVO) { |
| 150 | + return null; | ||
| 71 | } | 151 | } |
| 72 | 152 | ||
| 73 | @Override | 153 | @Override |
| 74 | - public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { | ||
| 75 | - return businessStatusMapper.selectPage(pageReqVO); | 154 | + public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) { |
| 155 | + if (CollUtil.isEmpty(ids)) { | ||
| 156 | + return Collections.emptyList(); | ||
| 157 | + } | ||
| 158 | + return businessStatusTypeMapper.selectBatchIds(ids); | ||
| 76 | } | 159 | } |
| 77 | 160 | ||
| 78 | @Override | 161 | @Override |
| 79 | - public List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) { | ||
| 80 | - return businessStatusMapper.selectList(queryVO); | 162 | + public List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Long typeId) { |
| 163 | + List<CrmBusinessStatusDO> list = businessStatusMapper.selectListByTypeId(typeId); | ||
| 164 | + list.sort(Comparator.comparingInt(CrmBusinessStatusDO::getSort)); | ||
| 165 | + return list; | ||
| 81 | } | 166 | } |
| 82 | 167 | ||
| 83 | @Override | 168 | @Override |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 8 | -import jakarta.validation.Valid; | ||
| 9 | - | ||
| 10 | -import java.util.Collection; | ||
| 11 | -import java.util.List; | ||
| 12 | -import java.util.Map; | ||
| 13 | - | ||
| 14 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 15 | - | ||
| 16 | -/** | ||
| 17 | - * 商机状态类型 Service 接口 | ||
| 18 | - * | ||
| 19 | - * @author ljlleo | ||
| 20 | - */ | ||
| 21 | -public interface CrmBusinessStatusTypeService { | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * 创建商机状态类型 | ||
| 25 | - * | ||
| 26 | - * @param createReqVO 创建信息 | ||
| 27 | - * @return 编号 | ||
| 28 | - */ | ||
| 29 | - Long createBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO createReqVO); | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 更新商机状态类型 | ||
| 33 | - * | ||
| 34 | - * @param updateReqVO 更新信息 | ||
| 35 | - */ | ||
| 36 | - void updateBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO updateReqVO); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 删除商机状态类型 | ||
| 40 | - * | ||
| 41 | - * @param id 编号 | ||
| 42 | - */ | ||
| 43 | - void deleteBusinessStatusType(Long id); | ||
| 44 | - | ||
| 45 | - /** | ||
| 46 | - * 获得商机状态类型 | ||
| 47 | - * | ||
| 48 | - * @param id 编号 | ||
| 49 | - * @return 商机状态类型 | ||
| 50 | - */ | ||
| 51 | - CrmBusinessStatusTypeDO getBusinessStatusType(Long id); | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 获得商机状态类型分页 | ||
| 55 | - * | ||
| 56 | - * @param pageReqVO 分页查询 | ||
| 57 | - * @return 商机状态类型分页 | ||
| 58 | - */ | ||
| 59 | - PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); | ||
| 60 | - | ||
| 61 | - // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。 | ||
| 62 | - /** | ||
| 63 | - * 获得商机状态类型列表 | ||
| 64 | - * | ||
| 65 | - * @param queryVO 查询参数 | ||
| 66 | - * @return 商机状态类型列表 | ||
| 67 | - */ | ||
| 68 | - List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO); | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * 获得商机状态类型列表 | ||
| 72 | - * | ||
| 73 | - * @param ids 编号数组 | ||
| 74 | - * @return 商机状态类型列表 | ||
| 75 | - */ | ||
| 76 | - List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids); | ||
| 77 | - | ||
| 78 | - /** | ||
| 79 | - * 获得商机状态类型 Map | ||
| 80 | - * | ||
| 81 | - * @param ids 编号数组 | ||
| 82 | - * @return 商机状态类型 Map | ||
| 83 | - */ | ||
| 84 | - default Map<Long, CrmBusinessStatusTypeDO> getBusinessStatusTypeMap(Collection<Long> ids) { | ||
| 85 | - return convertMap(getBusinessStatusTypeList(ids), CrmBusinessStatusTypeDO::getId); | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | ||
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 10 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | ||
| 11 | -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; | ||
| 12 | -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; | ||
| 13 | -import jakarta.annotation.Resource; | ||
| 14 | -import org.springframework.stereotype.Service; | ||
| 15 | -import org.springframework.transaction.annotation.Transactional; | ||
| 16 | -import org.springframework.validation.annotation.Validated; | ||
| 17 | - | ||
| 18 | -import java.util.Collection; | ||
| 19 | -import java.util.Collections; | ||
| 20 | -import java.util.List; | ||
| 21 | - | ||
| 22 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 23 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NAME_EXISTS; | ||
| 24 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; | ||
| 25 | - | ||
| 26 | -/** | ||
| 27 | - * 商机状态类型 Service 实现类 | ||
| 28 | - * | ||
| 29 | - * @author ljlleo | ||
| 30 | - */ | ||
| 31 | -@Service | ||
| 32 | -@Validated | ||
| 33 | -public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService { | ||
| 34 | - | ||
| 35 | - @Resource | ||
| 36 | - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; | ||
| 37 | - | ||
| 38 | - @Resource | ||
| 39 | - private CrmBusinessStatusMapper businessStatusMapper; | ||
| 40 | - | ||
| 41 | - @Override | ||
| 42 | - @Transactional(rollbackFor = Exception.class) | ||
| 43 | - public Long createBusinessStatusType(CrmBusinessStatusTypeSaveReqVO createReqVO) { | ||
| 44 | - //检验名称是否存在 | ||
| 45 | - validateBusinessStatusTypeExists(createReqVO.getName(), null); | ||
| 46 | - // 插入类型 | ||
| 47 | - CrmBusinessStatusTypeDO businessStatusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class); | ||
| 48 | - businessStatusTypeMapper.insert(businessStatusType); | ||
| 49 | - // 插入状态 | ||
| 50 | - if (CollUtil.isNotEmpty(createReqVO.getStatusList())) { | ||
| 51 | - createReqVO.getStatusList().forEach(status -> status.setTypeId(businessStatusType.getId())); | ||
| 52 | - businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class)); | ||
| 53 | - } | ||
| 54 | - return businessStatusType.getId(); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - @Override | ||
| 58 | - @Transactional(rollbackFor = Exception.class) | ||
| 59 | - public void updateBusinessStatusType(CrmBusinessStatusTypeSaveReqVO updateReqVO) { | ||
| 60 | - // 校验存在 | ||
| 61 | - validateBusinessStatusTypeExists(updateReqVO.getId()); | ||
| 62 | - // 校验名称是否存在 | ||
| 63 | - validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId()); | ||
| 64 | - // 更新类型 | ||
| 65 | - CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class); | ||
| 66 | - businessStatusTypeMapper.updateById(updateObj); | ||
| 67 | - // 更新状态(删除 + 更新) | ||
| 68 | - // TODO @ljlleo 可以参考 DeliveryExpressTemplateServiceImpl 的 updateExpressTemplateFree 方法;主要没变化的,还是不删除了哈。 | ||
| 69 | - businessStatusMapper.delete(updateReqVO.getId()); | ||
| 70 | - updateReqVO.getStatusList().forEach(status -> status.setTypeId(updateReqVO.getId())); | ||
| 71 | - businessStatusMapper.insertBatch(BeanUtils.toBean(updateReqVO.getStatusList(), CrmBusinessStatusDO.class)); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - @Override | ||
| 75 | - @Transactional(rollbackFor = Exception.class) | ||
| 76 | - public void deleteBusinessStatusType(Long id) { | ||
| 77 | - // TODO 待添加被引用校验 | ||
| 78 | - //... | ||
| 79 | - | ||
| 80 | - // 校验存在 | ||
| 81 | - validateBusinessStatusTypeExists(id); | ||
| 82 | - // 删除类型 | ||
| 83 | - businessStatusTypeMapper.deleteById(id); | ||
| 84 | - // 删除状态 | ||
| 85 | - businessStatusMapper.delete(id); | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - private void validateBusinessStatusTypeExists(Long id) { | ||
| 89 | - if (businessStatusTypeMapper.selectById(id) == null) { | ||
| 90 | - throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); | ||
| 91 | - } | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - // TODO @ljlleo 这个方法,这个参考 validateDeptNameUnique 实现。 | ||
| 95 | - private void validateBusinessStatusTypeExists(String name, Long id) { | ||
| 96 | - CrmBusinessStatusTypeDO businessStatusTypeDO = businessStatusTypeMapper.selectByIdAndName(id, name); | ||
| 97 | - if (businessStatusTypeDO != null) { | ||
| 98 | - throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); | ||
| 99 | - } | ||
| 100 | -// LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>(); | ||
| 101 | -// if(null != id) { | ||
| 102 | -// wrapper.ne(CrmBusinessStatusTypeDO::getId, id); | ||
| 103 | -// } | ||
| 104 | -// long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name)); | ||
| 105 | -// if (cnt > 0) { | ||
| 106 | -// throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); | ||
| 107 | -// } | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - @Override | ||
| 111 | - public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { | ||
| 112 | - return businessStatusTypeMapper.selectById(id); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - @Override | ||
| 116 | - public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) { | ||
| 117 | - return businessStatusTypeMapper.selectPage(pageReqVO); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - @Override | ||
| 121 | - public List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) { | ||
| 122 | - return businessStatusTypeMapper.selectList(queryVO); | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - @Override | ||
| 126 | - public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) { | ||
| 127 | - if (CollUtil.isEmpty(ids)) { | ||
| 128 | - return Collections.emptyList(); | ||
| 129 | - } | ||
| 130 | - return businessStatusTypeMapper.selectBatchIds(ids); | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | -} |