Commit 322411304ce6587c8fc69429a98fe4449fce11e2
1 parent
5b295d56
feat: CRM 客户限制
Showing
1 changed file
with
21 additions
and
0 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImpl.java
| ... | ... | @@ -7,11 +7,15 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimit |
| 7 | 7 | import cn.iocoder.yudao.module.crm.convert.customerlimitconfig.CrmCustomerLimitConfigConvert; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; |
| 9 | 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; | |
| 10 | 12 | import org.springframework.stereotype.Service; |
| 11 | 13 | import org.springframework.validation.annotation.Validated; |
| 12 | 14 | |
| 13 | 15 | import javax.annotation.Resource; |
| 14 | 16 | |
| 17 | +import java.util.Collection; | |
| 18 | + | |
| 15 | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 16 | 20 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; |
| 17 | 21 | |
| ... | ... | @@ -26,9 +30,14 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig |
| 26 | 30 | |
| 27 | 31 | @Resource |
| 28 | 32 | private CrmCustomerLimitConfigMapper customerLimitConfigMapper; |
| 33 | + @Resource | |
| 34 | + private DeptApi deptApi; | |
| 35 | + @Resource | |
| 36 | + private AdminUserApi adminUserApi; | |
| 29 | 37 | |
| 30 | 38 | @Override |
| 31 | 39 | public Long createCustomerLimitConfig(CrmCustomerLimitConfigCreateReqVO createReqVO) { |
| 40 | + validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); | |
| 32 | 41 | // 插入 |
| 33 | 42 | CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); |
| 34 | 43 | customerLimitConfigMapper.insert(customerLimitConfig); |
| ... | ... | @@ -40,6 +49,7 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig |
| 40 | 49 | public void updateCustomerLimitConfig(CrmCustomerLimitConfigUpdateReqVO updateReqVO) { |
| 41 | 50 | // 校验存在 |
| 42 | 51 | validateCustomerLimitConfigExists(updateReqVO.getId()); |
| 52 | + validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); | |
| 43 | 53 | // 更新 |
| 44 | 54 | CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); |
| 45 | 55 | customerLimitConfigMapper.updateById(updateObj); |
| ... | ... | @@ -69,4 +79,15 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig |
| 69 | 79 | } |
| 70 | 80 | } |
| 71 | 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 | + | |
| 72 | 93 | } | ... | ... |