Commit 9b7f6cfbac8ec360dce98b2a88a355b137475182
1 parent
4ca1f72d
📖 CRM:线索的 code review
Showing
2 changed files
with
7 additions
and
6 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -14,8 +14,8 @@ public interface ErrorCodeConstants { | @@ -14,8 +14,8 @@ public interface ErrorCodeConstants { | ||
| 14 | 14 | ||
| 15 | // ========== 线索管理 1-020-001-000 ========== | 15 | // ========== 线索管理 1-020-001-000 ========== |
| 16 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); | 16 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); |
| 17 | - ErrorCode ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在"); | ||
| 18 | - ErrorCode ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化"); | 17 | + ErrorCode CLUE_ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在"); |
| 18 | + ErrorCode CLUE_ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化"); | ||
| 19 | 19 | ||
| 20 | // ========== 商机管理 1-020-002-000 ========== | 20 | // ========== 商机管理 1-020-002-000 ========== |
| 21 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); | 21 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| @@ -138,19 +138,20 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -138,19 +138,20 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 138 | Set<Long> clueIds = reqVO.getIds(); | 138 | Set<Long> clueIds = reqVO.getIds(); |
| 139 | List<CrmClueDO> clues = getClueList(clueIds, userId); | 139 | List<CrmClueDO> clues = getClueList(clueIds, userId); |
| 140 | if (CollUtil.isEmpty(clues) || ObjectUtil.notEqual(clues.size(), clueIds.size())) { | 140 | if (CollUtil.isEmpty(clues) || ObjectUtil.notEqual(clues.size(), clueIds.size())) { |
| 141 | - // 提示不存在的线索编号 | ||
| 142 | clueIds.removeAll(convertSet(clues, CrmClueDO::getId)); | 141 | clueIds.removeAll(convertSet(clues, CrmClueDO::getId)); |
| 143 | - throw exception(ANY_CLUE_NOT_EXISTS, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); | 142 | + // TODO @min:可以使用 StrUtil.join(",", clueIds) 简化这种常见操作 |
| 143 | + throw exception(CLUE_ANY_CLUE_NOT_EXISTS, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); | ||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | // 过滤出未转化的客户 | 146 | // 过滤出未转化的客户 |
| 147 | + // TODO @min:1)存在已经转化的,直接提示哈。避免操作的用户,以为都转化成功了;2)常见的过滤逻辑,可以使用 CollectionUtils.filterList() | ||
| 147 | List<CrmClueDO> unTransformClues = clues.stream() | 148 | List<CrmClueDO> unTransformClues = clues.stream() |
| 148 | .filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())).toList(); | 149 | .filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())).toList(); |
| 149 | // 传入的线索中包含已经转化的情况,抛出业务异常 | 150 | // 传入的线索中包含已经转化的情况,抛出业务异常 |
| 150 | if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) { | 151 | if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) { |
| 151 | - // 提示已经转化的线索编号 | 152 | + // TODO @min:可以使用 StrUtil.join(",", clueIds) 简化这种常见操作 |
| 152 | clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId)); | 153 | clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId)); |
| 153 | - throw exception(ANY_CLUE_ALREADY_TRANSLATED, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); | 154 | + throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | // 遍历线索(未转化的线索),创建对应的客户 | 157 | // 遍历线索(未转化的线索),创建对应的客户 |