|
@@ -39,6 +39,7 @@ import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.StringPool;
|
|
|
+import org.springblade.modules.system.pojo.dto.DictBizDTO;
|
|
|
import org.springblade.modules.system.pojo.entity.DictBiz;
|
|
|
import org.springblade.modules.system.mapper.DictBizMapper;
|
|
|
import org.springblade.modules.system.service.IDictBizService;
|
|
@@ -49,6 +50,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
|
|
|
|
@@ -125,4 +127,33 @@ public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBiz> impl
|
|
|
List<DictBiz> list = this.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().ne(DictBiz::getId, parentId).eq(DictBiz::getCode, parentDict.getCode()).orderByAsc(DictBiz::getSort));
|
|
|
return DictBizWrapper.build().listNodeVO(list);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveDict(DictBizDTO dto) {
|
|
|
+ Integer type = dto.getType();
|
|
|
+ if (type == null){
|
|
|
+ throw new ServiceException("请传入类型");
|
|
|
+ }
|
|
|
+ //获取字典名称,直接清空对应字典数据
|
|
|
+ String dictName = type == 1 ? "projectStage" : (type == 2 ? "projectType" : "workFocusStage");
|
|
|
+ this.remove(new LambdaQueryWrapper<DictBiz>()
|
|
|
+ .eq(DictBiz::getDictKey,dictName));
|
|
|
+ //如果数组没有值,则直接跳过
|
|
|
+ List<String> list = dto.getList();
|
|
|
+ if (list == null || list.size() == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int i = 1;
|
|
|
+ List<DictBiz> adds = new ArrayList<>();
|
|
|
+ for (String s : list) {
|
|
|
+ DictBiz biz = new DictBiz();
|
|
|
+ biz.setParentId(1L);
|
|
|
+ biz.setCode(dictName);
|
|
|
+ biz.setDictKey(i+"");
|
|
|
+ biz.setDictValue(s);
|
|
|
+ biz.setSort(i++);
|
|
|
+ adds.add(biz);
|
|
|
+ }
|
|
|
+ this.saveBatch(adds);
|
|
|
+ }
|
|
|
}
|