|
@@ -2,15 +2,19 @@ package org.jeecg.modules.system.controller;
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CacheConstant;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.system.vo.DictModel;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
@@ -19,6 +23,7 @@ import org.jeecg.common.util.SqlInjectionUtil;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.system.entity.SysDict;
|
|
|
import org.jeecg.modules.system.entity.SysDictItem;
|
|
|
+import org.jeecg.modules.system.entity.dto.DictModelDTO;
|
|
|
import org.jeecg.modules.system.model.SysDictTree;
|
|
|
import org.jeecg.modules.system.model.TreeSelectModel;
|
|
|
import org.jeecg.modules.system.service.ISysDictItemService;
|
|
@@ -33,6 +38,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -515,4 +521,54 @@ public class SysDictController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取字典数据
|
|
|
+ * @param dictCode 字典code
|
|
|
+ * @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getDictItems/getDictList", method = RequestMethod.POST)
|
|
|
+ public Result<DictModelDTO> getDictList(@RequestBody List<String> dictCode) {
|
|
|
+ log.info(" dictCode : "+ dictCode);
|
|
|
+ Result<DictModelDTO> result = new Result<DictModelDTO>();
|
|
|
+ List<DictModel> ls = null;
|
|
|
+ try {
|
|
|
+ if(CollectionUtils.isEmpty(dictCode)){
|
|
|
+ result.error500("dictCode的值不能为空");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<SysDict> sysDictList = sysDictService.list(new LambdaQueryWrapper<SysDict>().in(SysDict::getDictCode, dictCode));
|
|
|
+ if(CollectionUtils.isEmpty(sysDictList)){
|
|
|
+ result.error500("没查到相关数据");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<String> ids = sysDictList.stream().map(t -> t.getId()).collect(Collectors.toList());
|
|
|
+ Map<String, String> idMap = sysDictList.stream().collect(Collectors.toMap(t -> t.getId(), t-> t.getDictCode()));
|
|
|
+ Map<String, List<DictModel>> map = Maps.newHashMap();
|
|
|
+ for(String id : ids){
|
|
|
+ List<SysDictItem> sysDictItems = sysDictItemService.list(new LambdaQueryWrapper<SysDictItem>().eq(SysDictItem::getDictId, id));
|
|
|
+ List<DictModel> dictModels = new ArrayList<DictModel>();
|
|
|
+// sysDictItem.parallelStream().reduce((a, b) -> new DictModel(a.getItemValue(), a.getItemText())).ifPresent(dictModels::add);
|
|
|
+ for(SysDictItem sysDictItem : sysDictItems){
|
|
|
+ dictModels.add(new DictModel(sysDictItem.getItemValue(), sysDictItem.getItemText()));
|
|
|
+ }
|
|
|
+ map.put(idMap.get(id), dictModels);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(new DictModelDTO(map));
|
|
|
+ log.info(result.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ result.error500(e.getMessage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|