Commit 90f135ad95d9df036e8e5810e8f344f4bc6ccb9d
Merge branch 'feature/crm' of https://gitee.com/jiangwanwan/ruoyi-vue-pro into feature/crm
# Conflicts: # sql/mysql/crm.sql
Showing
37 changed files
with
1103 additions
and
28 deletions
sql/mysql/crm.sql
| 1 | +SET NAMES utf8mb4; | ... | ... |
sql/mysql/crm_data.sql
| ... | ... | @@ -18,3 +18,6 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st |
| 18 | 18 | INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0'); |
| 19 | 19 | INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0'); |
| 20 | 20 | INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); |
| 21 | + | |
| 22 | + | |
| 23 | +INSERT INTO `crm_customer_pool_config` (`id`, `enabled`, `contact_expire_days`, `deal_expire_days`, `notify_enabled`, `notify_days`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 1, 15, 30, 1, 3, '1', NOW(), '1', NOW(), b'0', 1); | |
| 21 | 24 | \ No newline at end of file | ... | ... |
sql/mysql/crm_menu.sql
| 1 | +-- ---------------------------- | |
| 2 | +-- 客户公海配置 | |
| 3 | +-- ---------------------------- | |
| 4 | +-- 菜单 SQL | |
| 5 | +INSERT INTO system_menu( | |
| 6 | + name, permission, type, sort, parent_id, | |
| 7 | + path, icon, component, status, component_name | |
| 8 | +) | |
| 9 | +VALUES ( | |
| 10 | + '客户公海配置', '', 2, 0, 2397, | |
| 11 | + 'customer-pool-config', 'ep:data-analysis', 'crm/customerPoolConf/index', 0, 'CustomerPoolConf' | |
| 12 | +); | |
| 13 | + | |
| 14 | +-- 按钮父菜单ID | |
| 15 | +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 | |
| 16 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 17 | + | |
| 18 | +-- 按钮 SQL | |
| 19 | +INSERT INTO system_menu( | |
| 20 | + name, permission, type, sort, parent_id, | |
| 21 | + path, icon, component, status | |
| 22 | +) | |
| 23 | +VALUES ( | |
| 24 | + '客户公海配置保存', 'crm:customer-pool-config:update', 3, 1, @parentId, | |
| 25 | + '', '', '', 0 | |
| 26 | +); | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | +-- ---------------------------- | |
| 32 | +-- 客户限制配置管理 | |
| 33 | +-- ---------------------------- | |
| 34 | +-- 菜单 SQL | |
| 35 | +INSERT INTO system_menu( | |
| 36 | + name, permission, type, sort, parent_id, | |
| 37 | + path, icon, component, status, component_name | |
| 38 | +) | |
| 39 | +VALUES ( | |
| 40 | + '客户限制配置管理', '', 2, 0, 2397, | |
| 41 | + 'customer-limit-config', '', 'crm/customerLimitConfig/index', 0, 'CrmCustomerLimitConfig' | |
| 42 | +); | |
| 43 | + | |
| 44 | +-- 按钮父菜单ID | |
| 45 | +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 | |
| 46 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 47 | + | |
| 48 | +-- 按钮 SQL | |
| 49 | +INSERT INTO system_menu( | |
| 50 | + name, permission, type, sort, parent_id, | |
| 51 | + path, icon, component, status | |
| 52 | +) | |
| 53 | +VALUES ( | |
| 54 | + '客户限制配置查询', 'crm:customer-limit-config:query', 3, 1, @parentId, | |
| 55 | + '', '', '', 0 | |
| 56 | +); | |
| 57 | +INSERT INTO system_menu( | |
| 58 | + name, permission, type, sort, parent_id, | |
| 59 | + path, icon, component, status | |
| 60 | +) | |
| 61 | +VALUES ( | |
| 62 | + '客户限制配置创建', 'crm:customer-limit-config:create', 3, 2, @parentId, | |
| 63 | + '', '', '', 0 | |
| 64 | +); | |
| 65 | +INSERT INTO system_menu( | |
| 66 | + name, permission, type, sort, parent_id, | |
| 67 | + path, icon, component, status | |
| 68 | +) | |
| 69 | +VALUES ( | |
| 70 | + '客户限制配置更新', 'crm:customer-limit-config:update', 3, 3, @parentId, | |
| 71 | + '', '', '', 0 | |
| 72 | +); | |
| 73 | +INSERT INTO system_menu( | |
| 74 | + name, permission, type, sort, parent_id, | |
| 75 | + path, icon, component, status | |
| 76 | +) | |
| 77 | +VALUES ( | |
| 78 | + '客户限制配置删除', 'crm:customer-limit-config:delete', 3, 4, @parentId, | |
| 79 | + '', '', '', 0 | |
| 80 | +); | |
| 81 | +INSERT INTO system_menu( | |
| 82 | + name, permission, type, sort, parent_id, | |
| 83 | + path, icon, component, status | |
| 84 | +) | |
| 85 | +VALUES ( | |
| 86 | + '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, @parentId, | |
| 87 | + '', '', '', 0 | |
| 88 | +); | ... | ... |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
| ... | ... | @@ -280,6 +280,15 @@ public class CollectionUtils { |
| 280 | 280 | return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | + public static <T, U, R> List<R> convertListByFlatMap(Collection<T> from, | |
| 284 | + Function<? super T, ? extends U> mapper, | |
| 285 | + Function<U, ? extends Stream<? extends R>> func) { | |
| 286 | + if (CollUtil.isEmpty(from)) { | |
| 287 | + return new ArrayList<>(); | |
| 288 | + } | |
| 289 | + return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); | |
| 290 | + } | |
| 291 | + | |
| 283 | 292 | public static <T, U> Set<U> convertSetByFlatMap(Collection<T> from, |
| 284 | 293 | Function<T, ? extends Stream<? extends U>> func) { |
| 285 | 294 | if (CollUtil.isEmpty(from)) { |
| ... | ... | @@ -288,4 +297,13 @@ public class CollectionUtils { |
| 288 | 297 | return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); |
| 289 | 298 | } |
| 290 | 299 | |
| 300 | + public static <T, U, R> Set<R> convertSetByFlatMap(Collection<T> from, | |
| 301 | + Function<? super T, ? extends U> mapper, | |
| 302 | + Function<U, ? extends Stream<? extends R>> func) { | |
| 303 | + if (CollUtil.isEmpty(from)) { | |
| 304 | + return new HashSet<>(); | |
| 305 | + } | |
| 306 | + return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); | |
| 307 | + } | |
| 308 | + | |
| 291 | 309 | } | ... | ... |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| ... | ... | @@ -34,6 +34,8 @@ public interface ErrorCodeConstants { |
| 34 | 34 | |
| 35 | 35 | // ========== 客户管理 1_020_006_000 ========== |
| 36 | 36 | ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); |
| 37 | + ErrorCode CUSTOMER_POOL_CONFIG_ERROR = new ErrorCode(1_020_006_001, "客户公海规则设置不正确"); | |
| 38 | + ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_006_002, "客户限制配置不存在"); | |
| 37 | 39 | |
| 38 | 40 | // ========== 权限管理 1_020_007_000 ========== |
| 39 | 41 | ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http deleted
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| ... | ... | @@ -5,6 +5,8 @@ import cn.hutool.core.util.NumberUtil; |
| 5 | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 9 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 8 | 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | 11 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 10 | 12 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| ... | ... | @@ -101,25 +103,10 @@ public class CrmCustomerController { |
| 101 | 103 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| 102 | 104 | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| 103 | 105 | PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); |
| 104 | - PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); | |
| 105 | - // TODO @wanwan: 可以参考 CollectionUtils.convertListByFlatMap(),目的是简洁 | |
| 106 | - Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); | |
| 106 | + Set<Long> userSet = CollectionUtils.convertSetByFlatMap(pageResult.getList(), i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())); | |
| 107 | 107 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); |
| 108 | 108 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); |
| 109 | - // TODO @wanwan:这块可以形成一个 convertPage 方法,default 实现; | |
| 110 | - pageVo.getList().forEach(customerRespVO -> { | |
| 111 | - customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); | |
| 112 | - customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); | |
| 113 | - // TODO @wanwan:可以使用 MapUtils.findAndThen | |
| 114 | - AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); | |
| 115 | - if (Objects.nonNull(ownerUser)) { | |
| 116 | - customerRespVO.setOwnerUserName(ownerUser.getNickname()); | |
| 117 | - DeptRespDTO dept = deptMap.get(ownerUser.getDeptId()); | |
| 118 | - if (Objects.nonNull(dept)) { | |
| 119 | - customerRespVO.setOwnerUserDept(dept.getName()); | |
| 120 | - } | |
| 121 | - } | |
| 122 | - }); | |
| 109 | + PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap); | |
| 123 | 110 | return success(pageVo); |
| 124 | 111 | } |
| 125 | 112 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigRespVO; | |
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; | |
| 10 | +import cn.iocoder.yudao.module.crm.convert.customerlimitconfig.CrmCustomerLimitConfigConvert; | |
| 11 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 12 | +import cn.iocoder.yudao.module.crm.service.customerlimitconfig.CrmCustomerLimitConfigService; | |
| 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 org.springframework.security.access.prepost.PreAuthorize; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | + | |
| 24 | +import javax.annotation.Resource; | |
| 25 | +import javax.validation.Valid; | |
| 26 | +import java.util.Collection; | |
| 27 | +import java.util.HashSet; | |
| 28 | +import java.util.Map; | |
| 29 | +import java.util.Set; | |
| 30 | +import java.util.stream.Collectors; | |
| 31 | + | |
| 32 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 33 | + | |
| 34 | +@Tag(name = "管理后台 - 客户限制配置") | |
| 35 | +@RestController | |
| 36 | +@RequestMapping("/crm/customer-limit-config") | |
| 37 | +@Validated | |
| 38 | +public class CrmCustomerLimitConfigController { | |
| 39 | + | |
| 40 | + @Resource | |
| 41 | + private CrmCustomerLimitConfigService customerLimitConfigService; | |
| 42 | + @Resource | |
| 43 | + private DeptApi deptApi; | |
| 44 | + @Resource | |
| 45 | + private AdminUserApi adminUserApi; | |
| 46 | + | |
| 47 | + @PostMapping("/create") | |
| 48 | + @Operation(summary = "创建客户限制配置") | |
| 49 | + @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')") | |
| 50 | + public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigCreateReqVO createReqVO) { | |
| 51 | + return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO)); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @PutMapping("/update") | |
| 55 | + @Operation(summary = "更新客户限制配置") | |
| 56 | + @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')") | |
| 57 | + public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigUpdateReqVO updateReqVO) { | |
| 58 | + customerLimitConfigService.updateCustomerLimitConfig(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:customer-limit-config:delete')") | |
| 66 | + public CommonResult<Boolean> deleteCustomerLimitConfig(@RequestParam("id") Long id) { | |
| 67 | + customerLimitConfigService.deleteCustomerLimitConfig(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:customer-limit-config:query')") | |
| 75 | + public CommonResult<CrmCustomerLimitConfigRespVO> getCustomerLimitConfig(@RequestParam("id") Long id) { | |
| 76 | + CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigService.getCustomerLimitConfig(id); | |
| 77 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(new HashSet<>(customerLimitConfig.getUserIds())); | |
| 78 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(new HashSet<>(customerLimitConfig.getDeptIds())); | |
| 79 | + return success(CrmCustomerLimitConfigConvert.INSTANCE.convert(customerLimitConfig, userMap, deptMap)); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @GetMapping("/page") | |
| 83 | + @Operation(summary = "获得客户限制配置分页") | |
| 84 | + @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") | |
| 85 | + public CommonResult<PageResult<CrmCustomerLimitConfigRespVO>> getCustomerLimitConfigPage(@Valid CrmCustomerLimitConfigPageReqVO pageVO) { | |
| 86 | + PageResult<CrmCustomerLimitConfigDO> pageResult = customerLimitConfigService.getCustomerLimitConfigPage(pageVO); | |
| 87 | + Set<Long> userIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream); | |
| 88 | + Set<Long> deptIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream); | |
| 89 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | |
| 90 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds); | |
| 91 | + return success(CrmCustomerLimitConfigConvert.INSTANCE.convertPage(pageResult, userMap, deptMap)); | |
| 92 | + } | |
| 93 | + | |
| 94 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigRespVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 8 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | + | |
| 15 | +import javax.annotation.Resource; | |
| 16 | +import javax.validation.Valid; | |
| 17 | + | |
| 18 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 19 | + | |
| 20 | +@Tag(name = "管理后台 - CRM 客户公海配置") | |
| 21 | +@RestController | |
| 22 | +@RequestMapping("/crm/customer-pool-config") | |
| 23 | +@Validated | |
| 24 | +public class CrmCustomerPoolConfigController { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private CrmCustomerPoolConfigService customerPoolConfigService; | |
| 28 | + | |
| 29 | + @GetMapping("/get") | |
| 30 | + @Operation(summary = "获取客户公海规则设置") | |
| 31 | + @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") | |
| 32 | + public CommonResult<CrmCustomerPoolConfigRespVO> getCustomerPoolConfig() { | |
| 33 | + CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig(); | |
| 34 | + return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig)); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @PutMapping("/update") | |
| 38 | + @Operation(summary = "更新客户公海规则设置") | |
| 39 | + @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')") | |
| 40 | + public CommonResult<Boolean> updateCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigUpdateReqVO updateReqVO) { | |
| 41 | + customerPoolConfigService.updateCustomerPoolConfig(updateReqVO); | |
| 42 | + return success(true); | |
| 43 | + } | |
| 44 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigBaseVO.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 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 11 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +public class CrmCustomerLimitConfigBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 17 | + @NotNull(message = "规则类型不能为空") | |
| 18 | + private Integer type; | |
| 19 | + | |
| 20 | + @Schema(description = "规则适用人群") | |
| 21 | + private List<Long> userIds; | |
| 22 | + | |
| 23 | + @Schema(description = "规则适用部门") | |
| 24 | + private List<Long> deptIds; | |
| 25 | + | |
| 26 | + @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") | |
| 27 | + @NotNull(message = "数量上限不能为空") | |
| 28 | + private Integer maxCount; | |
| 29 | + | |
| 30 | + @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") | |
| 31 | + private Boolean dealCountEnabled; | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigCreateReqVO.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 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 客户限制配置创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | |
| 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 CrmCustomerLimitConfigPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "规则类型", example = "1") | |
| 16 | + private Integer type; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigRespVO.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 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 客户限制配置 Response VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "规则适用人群名称") | |
| 21 | + private String userNames; | |
| 22 | + | |
| 23 | + @Schema(description = "规则适用部门名称") | |
| 24 | + private String deptNames; | |
| 25 | + | |
| 26 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 27 | + private LocalDateTime createTime; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigUpdateReqVO.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 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 客户限制配置更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class CrmCustomerLimitConfigUpdateReqVO extends CrmCustomerLimitConfigBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") | |
| 17 | + @NotNull(message = "编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigBaseVO.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 | +/** | |
| 9 | + * 客户公海配置 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +public class CrmCustomerPoolConfigBaseVO { | |
| 14 | + | |
| 15 | + @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 16 | + @NotNull(message = "是否启用客户公海不能为空") | |
| 17 | + private Boolean enabled; | |
| 18 | + | |
| 19 | + @Schema(description = "未跟进放入公海天数", example = "2") | |
| 20 | + private Integer contactExpireDays; | |
| 21 | + | |
| 22 | + @Schema(description = "未成交放入公海天数", example = "2") | |
| 23 | + private Integer dealExpireDays; | |
| 24 | + | |
| 25 | + @Schema(description = "是否开启提前提醒", example = "true") | |
| 26 | + private Boolean notifyEnabled; | |
| 27 | + | |
| 28 | + @Schema(description = "提前提醒天数", example = "2") | |
| 29 | + private Integer notifyDays; | |
| 30 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigRespVO.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 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - CRM 客户公海规则 Response VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigUpdateReqVO.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 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - CRM 客户更新 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class CrmCustomerPoolConfigUpdateReqVO extends CrmCustomerPoolConfigBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
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 cn.hutool.core.lang.tree.Node; | |
| 4 | +import cn.hutool.core.util.NumberUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 4 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 5 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 10 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 6 | 11 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmTransferPermissionReqBO; |
| 12 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 13 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 7 | 14 | import org.mapstruct.Mapper; |
| 8 | 15 | import org.mapstruct.Mapping; |
| 9 | 16 | import org.mapstruct.Mappings; |
| 10 | 17 | import org.mapstruct.factory.Mappers; |
| 11 | 18 | |
| 12 | 19 | import java.util.List; |
| 20 | +import java.util.Map; | |
| 21 | +import java.util.Objects; | |
| 22 | +import java.util.Optional; | |
| 13 | 23 | |
| 14 | 24 | /** |
| 15 | 25 | * 客户 Convert |
| ... | ... | @@ -29,6 +39,21 @@ public interface CrmCustomerConvert { |
| 29 | 39 | |
| 30 | 40 | PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); |
| 31 | 41 | |
| 42 | + default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | |
| 43 | + PageResult<CrmCustomerRespVO> result = convertPage(page); | |
| 44 | + result.getList().forEach(customerRespVO -> { | |
| 45 | + customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); | |
| 46 | + MapUtils.findAndThen(userMap, NumberUtil.parseLong(customerRespVO.getCreator()), creator -> | |
| 47 | + customerRespVO.setCreatorName(creator.getNickname())); | |
| 48 | + MapUtils.findAndThen(userMap, customerRespVO.getOwnerUserId(), ownerUser -> { | |
| 49 | + customerRespVO.setOwnerUserName(ownerUser.getNickname()); | |
| 50 | + MapUtils.findAndThen(deptMap, ownerUser.getDeptId(), dept -> | |
| 51 | + customerRespVO.setOwnerUserDept(dept.getName())); | |
| 52 | + }); | |
| 53 | + }); | |
| 54 | + return result; | |
| 55 | + } | |
| 56 | + | |
| 32 | 57 | List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); |
| 33 | 58 | |
| 34 | 59 | @Mappings({ |
| ... | ... | @@ -37,4 +62,7 @@ public interface CrmCustomerConvert { |
| 37 | 62 | }) |
| 38 | 63 | CrmTransferPermissionReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); |
| 39 | 64 | |
| 65 | + CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig); | |
| 66 | + | |
| 67 | + CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigUpdateReqVO updateReqVO); | |
| 40 | 68 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customerlimitconfig/CrmCustomerLimitConfigConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.convert.customerlimitconfig; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigRespVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 8 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 9 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 10 | +import org.mapstruct.Mapper; | |
| 11 | +import org.mapstruct.factory.Mappers; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | +import java.util.Objects; | |
| 16 | +import java.util.stream.Collectors; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 客户限制配置 Convert | |
| 20 | + * | |
| 21 | + * @author Wanwan | |
| 22 | + */ | |
| 23 | +@Mapper | |
| 24 | +public interface CrmCustomerLimitConfigConvert { | |
| 25 | + | |
| 26 | + CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); | |
| 27 | + | |
| 28 | + CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean); | |
| 29 | + | |
| 30 | + CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigUpdateReqVO bean); | |
| 31 | + | |
| 32 | + CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); | |
| 33 | + | |
| 34 | + List<CrmCustomerLimitConfigRespVO> convertList(List<CrmCustomerLimitConfigDO> list); | |
| 35 | + | |
| 36 | + PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> page); | |
| 37 | + | |
| 38 | + default PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> pageResult, | |
| 39 | + Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | |
| 40 | + PageResult<CrmCustomerLimitConfigRespVO> result = convertPage(pageResult); | |
| 41 | + result.getList().forEach(respVo -> fillNameField(userMap, deptMap, respVo)); | |
| 42 | + return result; | |
| 43 | + } | |
| 44 | + | |
| 45 | + default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO customerLimitConfig, | |
| 46 | + Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | |
| 47 | + CrmCustomerLimitConfigRespVO respVo = convert(customerLimitConfig); | |
| 48 | + fillNameField(userMap, deptMap, respVo); | |
| 49 | + return respVo; | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 填充名称字段 | |
| 54 | + * | |
| 55 | + * @param userMap 用户映射 | |
| 56 | + * @param deptMap 部门映射 | |
| 57 | + * @param respVo 响应实体 | |
| 58 | + */ | |
| 59 | + static void fillNameField(Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap, CrmCustomerLimitConfigRespVO respVo) { | |
| 60 | + respVo.setUserNames(respVo.getUserIds().stream().map(userMap::get) | |
| 61 | + .filter(Objects::nonNull).map(AdminUserRespDTO::getNickname).collect(Collectors.joining(","))); | |
| 62 | + respVo.setDeptNames(respVo.getDeptIds().stream().map(deptMap::get) | |
| 63 | + .filter(Objects::nonNull).map(DeptRespDTO::getName).collect(Collectors.joining(","))); | |
| 64 | + } | |
| 65 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
| ... | ... | @@ -15,7 +15,7 @@ import java.time.LocalDateTime; |
| 15 | 15 | * |
| 16 | 16 | * @author Wanwan |
| 17 | 17 | */ |
| 18 | -@TableName(value = "crm_customer", autoResultMap = true) | |
| 18 | +@TableName(value = "crm_customer") | |
| 19 | 19 | @KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 20 | 20 | @Data |
| 21 | 21 | @EqualsAndHashCode(callSuper = true) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.dataobject.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 客户公海配置 DO | |
| 11 | + * | |
| 12 | + * @author Wanwan | |
| 13 | + */ | |
| 14 | +@TableName(value = "crm_customer_pool_config") | |
| 15 | +@KeySequence("crm_customer_pool_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 16 | +@Data | |
| 17 | +@EqualsAndHashCode(callSuper = true) | |
| 18 | +@ToString(callSuper = true) | |
| 19 | +@Builder | |
| 20 | +@NoArgsConstructor | |
| 21 | +@AllArgsConstructor | |
| 22 | +public class CrmCustomerPoolConfigDO extends BaseDO { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 编号 | |
| 26 | + */ | |
| 27 | + @TableId | |
| 28 | + private Long id; | |
| 29 | + /** | |
| 30 | + * 是否启用客户公海 | |
| 31 | + */ | |
| 32 | + private Boolean enabled; | |
| 33 | + /** | |
| 34 | + * 未跟进放入公海天数 | |
| 35 | + */ | |
| 36 | + private Integer contactExpireDays; | |
| 37 | + /** | |
| 38 | + * 未成交放入公海天数 | |
| 39 | + */ | |
| 40 | + private Integer dealExpireDays; | |
| 41 | + /** | |
| 42 | + * 是否开启提前提醒 | |
| 43 | + */ | |
| 44 | + private Boolean notifyEnabled; | |
| 45 | + /** | |
| 46 | + * 提前提醒天数 | |
| 47 | + */ | |
| 48 | + private Integer notifyDays; | |
| 49 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customerlimitconfig/CrmCustomerLimitConfigDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 客户限制配置 DO | |
| 15 | + * | |
| 16 | + * @author Wanwan | |
| 17 | + */ | |
| 18 | +@TableName(value = "crm_customer_limit_config", autoResultMap = true) | |
| 19 | +@KeySequence("crm_customer_limit_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class CrmCustomerLimitConfigDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + /** | |
| 34 | + * 规则类型 | |
| 35 | + */ | |
| 36 | + private Integer type; | |
| 37 | + /** | |
| 38 | + * 规则适用人群 | |
| 39 | + */ | |
| 40 | + @TableField(typeHandler = LongListTypeHandler.class) | |
| 41 | + private List<Long> userIds; | |
| 42 | + /** | |
| 43 | + * 规则适用部门 | |
| 44 | + */ | |
| 45 | + @TableField(typeHandler = LongListTypeHandler.class) | |
| 46 | + private List<Long> deptIds; | |
| 47 | + /** | |
| 48 | + * 数量上限 | |
| 49 | + */ | |
| 50 | + private Integer maxCount; | |
| 51 | + /** | |
| 52 | + * 成交客户是否占有拥有客户数(当 type = 1 时) | |
| 53 | + */ | |
| 54 | + private Boolean dealCountEnabled; | |
| 55 | + | |
| 56 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 客户公海配置 Mapper | |
| 9 | + * | |
| 10 | + * @author Wanwan | |
| 11 | + */ | |
| 12 | +@Mapper | |
| 13 | +public interface CrmCustomerPoolConfigMapper extends BaseMapperX<CrmCustomerPoolConfigDO> { | |
| 14 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customerlimitconfig/CrmCustomerLimitConfigMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig; | |
| 2 | + | |
| 3 | +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.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 客户限制配置 Mapper | |
| 12 | + * | |
| 13 | + * @author Wanwan | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface CrmCustomerLimitConfigMapper extends BaseMapperX<CrmCustomerLimitConfigDO> { | |
| 17 | + | |
| 18 | + default PageResult<CrmCustomerLimitConfigDO> selectPage(CrmCustomerLimitConfigPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerLimitConfigDO>() | |
| 20 | + .eqIfPresent(CrmCustomerLimitConfigDO::getType, reqVO.getType()) | |
| 21 | + .orderByDesc(CrmCustomerLimitConfigDO::getId)); | |
| 22 | + } | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 5 | + | |
| 6 | +import javax.validation.Valid; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 客户公海配置 Service 接口 | |
| 10 | + * | |
| 11 | + * @author Wanwan | |
| 12 | + */ | |
| 13 | +public interface CrmCustomerPoolConfigService { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 获得客户公海配置 | |
| 17 | + * | |
| 18 | + * @return 客户公海配置 | |
| 19 | + */ | |
| 20 | + CrmCustomerPoolConfigDO getCustomerPoolConfig(); | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 保存客户公海配置 | |
| 24 | + * | |
| 25 | + * @param saveReqVO 更新信息 | |
| 26 | + */ | |
| 27 | + void updateCustomerPoolConfig(@Valid CrmCustomerPoolConfigUpdateReqVO saveReqVO); | |
| 28 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.customer; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.BooleanUtil; | |
| 4 | +import cn.hutool.core.util.ObjectUtil; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | |
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 9 | +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | +import java.util.Objects; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_POOL_CONFIG_ERROR; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * 客户公海配置 Service 实现类 | |
| 21 | + * | |
| 22 | + * @author Wanwan | |
| 23 | + */ | |
| 24 | +@Service | |
| 25 | +@Validated | |
| 26 | +public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { | |
| 27 | + @Resource | |
| 28 | + private CrmCustomerPoolConfigMapper customerPoolConfigMapper; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 获得客户公海配置 | |
| 32 | + * | |
| 33 | + * @return 客户公海配置 | |
| 34 | + */ | |
| 35 | + @Override | |
| 36 | + public CrmCustomerPoolConfigDO getCustomerPoolConfig() { | |
| 37 | + return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1")); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 保存客户公海配置 | |
| 42 | + * | |
| 43 | + * @param saveReqVO 更新信息 | |
| 44 | + */ | |
| 45 | + @Override | |
| 46 | + public void updateCustomerPoolConfig(CrmCustomerPoolConfigUpdateReqVO saveReqVO) { | |
| 47 | + if (BooleanUtil.isTrue(saveReqVO.getEnabled()) && (ObjectUtil.hasNull(saveReqVO.getContactExpireDays(), saveReqVO.getDealExpireDays()))) { | |
| 48 | + throw exception(CUSTOMER_POOL_CONFIG_ERROR); | |
| 49 | + } | |
| 50 | + if (BooleanUtil.isTrue(saveReqVO.getNotifyEnabled()) && (Objects.isNull(saveReqVO.getNotifyDays()))) { | |
| 51 | + throw exception(CUSTOMER_POOL_CONFIG_ERROR); | |
| 52 | + } | |
| 53 | + | |
| 54 | + // 存在,则进行更新 | |
| 55 | + CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); | |
| 56 | + if (Objects.nonNull(dbConfig)) { | |
| 57 | + customerPoolConfigMapper.updateById(CrmCustomerConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); | |
| 58 | + return; | |
| 59 | + } | |
| 60 | + // 不存在,则进行插入 | |
| 61 | + customerPoolConfigMapper.insert(CrmCustomerConvert.INSTANCE.convert(saveReqVO)); | |
| 62 | + } | |
| 63 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.hutool.core.collection.ListUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 7 | 5 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| ... | ... | @@ -12,13 +10,11 @@ import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; |
| 12 | 10 | import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; |
| 13 | 11 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 14 | 12 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 15 | -import cn.iocoder.yudao.module.system.api.dept.DeptApi; | |
| 16 | 13 | import org.springframework.stereotype.Service; |
| 17 | 14 | import org.springframework.transaction.annotation.Transactional; |
| 18 | 15 | import org.springframework.validation.annotation.Validated; |
| 19 | 16 | |
| 20 | 17 | import javax.annotation.Resource; |
| 21 | -import java.util.Collection; | |
| 22 | 18 | import java.util.List; |
| 23 | 19 | import java.util.Objects; |
| 24 | 20 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.customerlimitconfig; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 8 | + | |
| 9 | +import javax.validation.Valid; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 客户限制配置 Service 接口 | |
| 13 | + * | |
| 14 | + * @author Wanwan | |
| 15 | + */ | |
| 16 | +public interface CrmCustomerLimitConfigService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建客户限制配置 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigCreateReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新客户限制配置 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigUpdateReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除客户限制配置 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteCustomerLimitConfig(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获得客户限制配置 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 客户限制配置 | |
| 45 | + */ | |
| 46 | + CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得客户限制配置分页 | |
| 50 | + * | |
| 51 | + * @param pageReqVO 分页查询 | |
| 52 | + * @return 客户限制配置分页 | |
| 53 | + */ | |
| 54 | + PageResult<CrmCustomerLimitConfigDO> getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); | |
| 55 | + | |
| 56 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.customerlimitconfig; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.convert.customerlimitconfig.CrmCustomerLimitConfigConvert; | |
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 9 | +import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; | |
| 10 | +import cn.iocoder.yudao.module.system.api.dept.DeptApi; | |
| 11 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | + | |
| 15 | +import javax.annotation.Resource; | |
| 16 | + | |
| 17 | +import java.util.Collection; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 20 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 客户限制配置 Service 实现类 | |
| 24 | + * | |
| 25 | + * @author Wanwan | |
| 26 | + */ | |
| 27 | +@Service | |
| 28 | +@Validated | |
| 29 | +public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfigService { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private CrmCustomerLimitConfigMapper customerLimitConfigMapper; | |
| 33 | + @Resource | |
| 34 | + private DeptApi deptApi; | |
| 35 | + @Resource | |
| 36 | + private AdminUserApi adminUserApi; | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public Long createCustomerLimitConfig(CrmCustomerLimitConfigCreateReqVO createReqVO) { | |
| 40 | + validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); | |
| 41 | + // 插入 | |
| 42 | + CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); | |
| 43 | + customerLimitConfigMapper.insert(customerLimitConfig); | |
| 44 | + // 返回 | |
| 45 | + return customerLimitConfig.getId(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void updateCustomerLimitConfig(CrmCustomerLimitConfigUpdateReqVO updateReqVO) { | |
| 50 | + // 校验存在 | |
| 51 | + validateCustomerLimitConfigExists(updateReqVO.getId()); | |
| 52 | + validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); | |
| 53 | + // 更新 | |
| 54 | + CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); | |
| 55 | + customerLimitConfigMapper.updateById(updateObj); | |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public void deleteCustomerLimitConfig(Long id) { | |
| 60 | + // 校验存在 | |
| 61 | + validateCustomerLimitConfigExists(id); | |
| 62 | + // 删除 | |
| 63 | + customerLimitConfigMapper.deleteById(id); | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id) { | |
| 68 | + return customerLimitConfigMapper.selectById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public PageResult<CrmCustomerLimitConfigDO> getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO) { | |
| 73 | + return customerLimitConfigMapper.selectPage(pageReqVO); | |
| 74 | + } | |
| 75 | + | |
| 76 | + private void validateCustomerLimitConfigExists(Long id) { | |
| 77 | + if (customerLimitConfigMapper.selectById(id) == null) { | |
| 78 | + throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 校验入参的用户和部门 | |
| 84 | + * | |
| 85 | + * @param userIds 用户 ids | |
| 86 | + * @param deptIds 部门 ids | |
| 87 | + */ | |
| 88 | + private void validateUserAndDept(Collection<Long> userIds, Collection<Long> deptIds) { | |
| 89 | + deptApi.validateDeptList(deptIds); | |
| 90 | + adminUserApi.validateUserList(userIds); | |
| 91 | + } | |
| 92 | + | |
| 93 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customer/CrmCustomerPoolConfigMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper"> | |
| 4 | + | |
| 5 | + <!-- | |
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | |
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | |
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | |
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | |
| 10 | + --> | |
| 11 | + | |
| 12 | +</mapper> | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customerlimitconfig/CrmCustomerLimitConfigMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper"> | |
| 4 | + | |
| 5 | + <!-- | |
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | |
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | |
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | |
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | |
| 10 | + --> | |
| 11 | + | |
| 12 | +</mapper> | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.customerlimitconfig; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; | |
| 9 | +import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; | |
| 10 | +import org.junit.jupiter.api.Disabled; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 20 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | |
| 21 | +import static org.junit.jupiter.api.Assertions.*; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * {@link CrmCustomerLimitConfigServiceImpl} 的单元测试类 | |
| 25 | + * | |
| 26 | + * @author Wanwan | |
| 27 | + */ | |
| 28 | +@Import(CrmCustomerLimitConfigServiceImpl.class) | |
| 29 | +public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private CrmCustomerLimitConfigServiceImpl customerLimitConfigService; | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private CrmCustomerLimitConfigMapper customerLimitConfigMapper; | |
| 36 | + | |
| 37 | + @Test | |
| 38 | + public void testCreateCustomerLimitConfig_success() { | |
| 39 | + // 准备参数 | |
| 40 | + CrmCustomerLimitConfigCreateReqVO reqVO = randomPojo(CrmCustomerLimitConfigCreateReqVO.class); | |
| 41 | + | |
| 42 | + // 调用 | |
| 43 | + Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO); | |
| 44 | + // 断言 | |
| 45 | + assertNotNull(customerLimitConfigId); | |
| 46 | + // 校验记录的属性是否正确 | |
| 47 | + CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(customerLimitConfigId); | |
| 48 | + assertPojoEquals(reqVO, customerLimitConfig); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Test | |
| 52 | + public void testUpdateCustomerLimitConfig_success() { | |
| 53 | + // mock 数据 | |
| 54 | + CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); | |
| 55 | + customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 | |
| 56 | + // 准备参数 | |
| 57 | + CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class, o -> { | |
| 58 | + o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID | |
| 59 | + }); | |
| 60 | + | |
| 61 | + // 调用 | |
| 62 | + customerLimitConfigService.updateCustomerLimitConfig(reqVO); | |
| 63 | + // 校验是否更新正确 | |
| 64 | + CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | + assertPojoEquals(reqVO, customerLimitConfig); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Test | |
| 69 | + public void testUpdateCustomerLimitConfig_notExists() { | |
| 70 | + // 准备参数 | |
| 71 | + CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class); | |
| 72 | + | |
| 73 | + // 调用, 并断言异常 | |
| 74 | + assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Test | |
| 78 | + public void testDeleteCustomerLimitConfig_success() { | |
| 79 | + // mock 数据 | |
| 80 | + CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); | |
| 81 | + customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 | |
| 82 | + // 准备参数 | |
| 83 | + Long id = dbCustomerLimitConfig.getId(); | |
| 84 | + | |
| 85 | + // 调用 | |
| 86 | + customerLimitConfigService.deleteCustomerLimitConfig(id); | |
| 87 | + // 校验数据不存在了 | |
| 88 | + assertNull(customerLimitConfigMapper.selectById(id)); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @Test | |
| 92 | + public void testDeleteCustomerLimitConfig_notExists() { | |
| 93 | + // 准备参数 | |
| 94 | + Long id = randomLongId(); | |
| 95 | + | |
| 96 | + // 调用, 并断言异常 | |
| 97 | + assertServiceException(() -> customerLimitConfigService.deleteCustomerLimitConfig(id), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Test | |
| 101 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | + public void testGetCustomerLimitConfigPage() { | |
| 103 | + // mock 数据 | |
| 104 | + CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class, o -> { // 等会查询到 | |
| 105 | + }); | |
| 106 | + customerLimitConfigMapper.insert(dbCustomerLimitConfig); | |
| 107 | + // 准备参数 | |
| 108 | + CrmCustomerLimitConfigPageReqVO reqVO = new CrmCustomerLimitConfigPageReqVO(); | |
| 109 | + | |
| 110 | + // 调用 | |
| 111 | + PageResult<CrmCustomerLimitConfigDO> pageResult = customerLimitConfigService.getCustomerLimitConfigPage(reqVO); | |
| 112 | + // 断言 | |
| 113 | + assertEquals(1, pageResult.getTotal()); | |
| 114 | + assertEquals(1, pageResult.getList().size()); | |
| 115 | + assertPojoEquals(dbCustomerLimitConfig, pageResult.getList().get(0)); | |
| 116 | + } | |
| 117 | + | |
| 118 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -122,4 +122,20 @@ CREATE TABLE IF NOT EXISTS "crm_customer" ( |
| 122 | 122 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 123 | 123 | "tenant_id" bigint NOT NULL, |
| 124 | 124 | PRIMARY KEY ("id") |
| 125 | -) COMMENT '客户表'; | |
| 126 | 125 | \ No newline at end of file |
| 126 | +) COMMENT '客户表'; | |
| 127 | + | |
| 128 | +CREATE TABLE IF NOT EXISTS "crm_customer_limit_config" ( | |
| 129 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 130 | + "type" int NOT NULL, | |
| 131 | + "user_ids" varchar, | |
| 132 | + "dept_ids" varchar, | |
| 133 | + "max_count" int NOT NULL, | |
| 134 | + "deal_count_enabled" varchar, | |
| 135 | + "creator" varchar DEFAULT '', | |
| 136 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 137 | + "updater" varchar DEFAULT '', | |
| 138 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 139 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 140 | + "tenant_id" bigint NOT NULL, | |
| 141 | + PRIMARY KEY ("id") | |
| 142 | +) COMMENT '客户限制配置表'; | |
| 127 | 143 | \ No newline at end of file | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
| ... | ... | @@ -109,6 +109,28 @@ public class UserController { |
| 109 | 109 | return success(new PageResult<>(userList, pageResult.getTotal())); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | + @GetMapping("/all") | |
| 113 | + @Operation(summary = "查询所有用户列表") | |
| 114 | + public CommonResult<List<UserPageItemRespVO>> getAllUser() { | |
| 115 | + // 获得用户分页列表 | |
| 116 | + List<AdminUserDO> pageResult = userService.getUserList(); | |
| 117 | + if (CollUtil.isEmpty(pageResult)) { | |
| 118 | + return success(Collections.emptyList()); // 返回空 | |
| 119 | + } | |
| 120 | + | |
| 121 | + // 获得拼接需要的数据 | |
| 122 | + Collection<Long> deptIds = convertList(pageResult, AdminUserDO::getDeptId); | |
| 123 | + Map<Long, DeptDO> deptMap = deptService.getDeptMap(deptIds); | |
| 124 | + // 拼接结果返回 | |
| 125 | + List<UserPageItemRespVO> userList = new ArrayList<>(pageResult.size()); | |
| 126 | + pageResult.forEach(user -> { | |
| 127 | + UserPageItemRespVO respVO = UserConvert.INSTANCE.convert(user); | |
| 128 | + respVO.setDept(UserConvert.INSTANCE.convert(deptMap.get(user.getDeptId()))); | |
| 129 | + userList.add(respVO); | |
| 130 | + }); | |
| 131 | + return success(userList); | |
| 132 | + } | |
| 133 | + | |
| 112 | 134 | @GetMapping("/list-all-simple") |
| 113 | 135 | @Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项") |
| 114 | 136 | public CommonResult<List<UserSimpleRespVO>> getSimpleUserList() { | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
| ... | ... | @@ -444,6 +444,16 @@ public class AdminUserServiceImpl implements AdminUserService { |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | + * 获取所有用户列表 | |
| 448 | + * | |
| 449 | + * @return 用户列表 | |
| 450 | + */ | |
| 451 | + @Override | |
| 452 | + public List<AdminUserDO> getUserList() { | |
| 453 | + return userMapper.selectList(); | |
| 454 | + } | |
| 455 | + | |
| 456 | + /** | |
| 447 | 457 | * 对密码进行加密 |
| 448 | 458 | * |
| 449 | 459 | * @param password 密码 | ... | ... |