|
@@ -142,9 +142,13 @@ public class PlatformBusinessSectionServiceImpl extends ServiceImpl<StoreDiction
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 生成 dict_id:查询同级(相同 parent_id)的最大 dict_id,然后 +1
|
|
|
|
|
- String maxDictId = getMaxDictIdByParentId(parentId);
|
|
|
|
|
- int nextDictId = (maxDictId == null ? 0 : Integer.parseInt(maxDictId)) + 1;
|
|
|
|
|
|
|
+ // 生成 dict_id:根据 typeName 查询最大 dict_id,然后 +1
|
|
|
|
|
+ String typeName = storeDictionary.getTypeName();
|
|
|
|
|
+ if (StringUtils.isBlank(typeName)) {
|
|
|
|
|
+ throw new IllegalArgumentException("typeName不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ String maxDictId = getMaxDictIdByTypeName(typeName);
|
|
|
|
|
+ int nextDictId = (maxDictId == null ? 1 : Integer.parseInt(maxDictId)) + 1;
|
|
|
storeDictionary.setDictId(String.valueOf(nextDictId));
|
|
storeDictionary.setDictId(String.valueOf(nextDictId));
|
|
|
|
|
|
|
|
// 生成 sort_id
|
|
// 生成 sort_id
|
|
@@ -347,23 +351,16 @@ public class PlatformBusinessSectionServiceImpl extends ServiceImpl<StoreDiction
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据 parent_id 获取同级最大 dict_id
|
|
|
|
|
|
|
+ * 根据 typeName 获取最大 dict_id
|
|
|
*
|
|
*
|
|
|
- * @param parentId 父节点ID
|
|
|
|
|
|
|
+ * @param typeName 类型名称
|
|
|
* @return 最大 dict_id,如果不存在则返回 null
|
|
* @return 最大 dict_id,如果不存在则返回 null
|
|
|
*/
|
|
*/
|
|
|
- private String getMaxDictIdByParentId(Integer parentId) {
|
|
|
|
|
|
|
+ private String getMaxDictIdByTypeName(String typeName) {
|
|
|
LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(StoreDictionary::getTypeName, "business_section","business_type","business_classify");;
|
|
|
|
|
|
|
+ queryWrapper.eq(StoreDictionary::getTypeName, typeName);
|
|
|
queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
|
|
queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
|
|
|
|
|
|
|
|
- if (parentId == null || parentId == 0) {
|
|
|
|
|
- queryWrapper.and(wrapper -> wrapper.isNull(StoreDictionary::getParentId)
|
|
|
|
|
- .or().eq(StoreDictionary::getParentId, 0));
|
|
|
|
|
- } else {
|
|
|
|
|
- queryWrapper.eq(StoreDictionary::getParentId, parentId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
queryWrapper.orderByDesc(StoreDictionary::getDictId);
|
|
queryWrapper.orderByDesc(StoreDictionary::getDictId);
|
|
|
queryWrapper.last("LIMIT 1");
|
|
queryWrapper.last("LIMIT 1");
|
|
|
|
|
|
|
@@ -835,7 +832,7 @@ public class PlatformBusinessSectionServiceImpl extends ServiceImpl<StoreDiction
|
|
|
newDict.setCreatedTime(new Date());
|
|
newDict.setCreatedTime(new Date());
|
|
|
|
|
|
|
|
// 生成 dict_id
|
|
// 生成 dict_id
|
|
|
- String maxDictId = getMaxDictIdByParentId(newDict.getParentId());
|
|
|
|
|
|
|
+ String maxDictId = getMaxDictIdByTypeName(newDict.getTypeName());
|
|
|
newDict.setDictId(String.valueOf(maxDictId == null ? 1 : Integer.parseInt(maxDictId) + 1));
|
|
newDict.setDictId(String.valueOf(maxDictId == null ? 1 : Integer.parseInt(maxDictId) + 1));
|
|
|
|
|
|
|
|
// 生成 sort_id
|
|
// 生成 sort_id
|