From bb69a505d9ac5d8482fbe1088ade34020845df20 Mon Sep 17 00:00:00 2001 From: liyd <1419499670@qq.com> Date: Thu, 1 Dec 2022 20:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DictDetailServiceImpl.java | 2 +- .../system/service/impl/DictServiceImpl.java | 84 +++++++++---------- .../modules/system/service/wql/SYS_DICT.wql | 1 + 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java index 4ae7bd3..c3ff78f 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java @@ -136,7 +136,7 @@ public class DictDetailServiceImpl implements DictDetailService { if (dictDto == null) { throw new BadRequestException("被删除或无权限,操作失败!"); } - // 清理缓存 +// // 清理缓存 delCaches(dictDto); WQLObject dictTab = WQLObject.getWQLObject("sys_dict"); JSONObject json = JSONObject.parseObject(JSON.toJSONString(dictDto)); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java index 3b375f9..101f4e4 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java @@ -27,6 +27,7 @@ import org.nl.modules.common.utils.FileUtil; import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.system.service.DictService; +import org.nl.modules.system.service.dto.DictDetailDto; import org.nl.modules.system.service.dto.DictDto; import org.nl.modules.system.service.dto.DictQueryCriteria; import org.nl.modules.wql.WQL; @@ -39,10 +40,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Zheng Jie @@ -50,7 +48,7 @@ import java.util.Set; */ @Service @RequiredArgsConstructor -@CacheConfig(cacheNames = "dict") +//@CacheConfig(cacheNames = "dict") public class DictServiceImpl implements DictService { private final RedisUtils redisUtils; @@ -97,62 +95,55 @@ public class DictServiceImpl implements DictService { @Override @Transactional(rollbackFor = Exception.class) public void update(DictDto dto) { - DictDto entity = this.findById(dto.getDict_id()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - // 清除缓存 - this.delCaches(dto); - + WQLObject wo = WQLObject.getWQLObject("sys_dict"); Long currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); - - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_optid(currentUserId); - dto.setUpdate_optname(nickName); - - WQLObject wo = WQLObject.getWQLObject("sys_dict"); - JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); - wo.update(json); + JSONObject otherObj = wo.query("dict_id = '" + dto.getDict_id() + "'").uniqueResult(0); + JSONArray dictArray = wo.query("code = '" + otherObj.getString("code") + "'").getResultJSONArray(0); + for (int i = 0; i < dictArray.size(); i++) { + JSONObject dictObj = dictArray.getJSONObject(i); + dictObj.put("code", dto.getCode()); + dictObj.put("name", dto.getName()); + dictObj.put("update_time", DateUtil.now()); + dictObj.put("update_optid", currentUserId); + dictObj.put("update_optname", nickName); + wo.update(dictObj); + } } @Override @Transactional(rollbackFor = Exception.class) public void delete(Set ids) { WQLObject wo = WQLObject.getWQLObject("sys_dict"); - for (Long dict_id : ids) { - // 清理缓存 - DictDto dictDto = this.findById(dict_id); - delCaches(dictDto); + for (Long id : ids) { + JSONObject object = wo.query("dict_id = '" + id + "'").uniqueResult(0); // 删除数据 - wo.delete("code = '" + dictDto.getCode() + "'"); + wo.delete("code = '" + object.getString("code") + "'"); } } @Override public void download(List dictDtos, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); -// for (DictDto dictDTO : dictDtos) { -// if(CollectionUtil.isNotEmpty(dictDTO.getDictDetails())){ -// for (DictDetailDto dictDetail : dictDTO.getDictDetails()) { -// Map map = new LinkedHashMap<>(); -// map.put("字典名称", dictDTO.getName()); -// map.put("字典描述", dictDTO.getDescription()); -// map.put("字典标签", dictDetail.getLabel()); -// map.put("字典值", dictDetail.getValue()); -// map.put("创建日期", dictDetail.getCreate_time()); -// list.add(map); -// } -// } else { -// Map map = new LinkedHashMap<>(); -// map.put("字典名称", dictDTO.getName()); -// map.put("字典描述", dictDTO.getDescription()); -// map.put("字典标签", null); -// map.put("字典值", null); -// map.put("创建日期", dictDTO.getCreate_time()); -// list.add(map); -// } -// } + WQLObject wo = WQLObject.getWQLObject("sys_dict"); + for (DictDto dictDTO : dictDtos) { + JSONArray jsonArray = wo.query("code = '" + dictDTO.getDictCode() + "'").getResultJSONArray(0); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + Map map = new LinkedHashMap<>(); + map.put("字典名称", jsonObject.getString("name")); + map.put("字典描述", jsonObject.getString("code")); + map.put("字典标签", jsonObject.getString("label")); + map.put("字典值", jsonObject.getString("value")); + map.put("排序", jsonObject.getString("dict_sort")); + map.put("类型", jsonObject.getString("dict_type")); + map.put("参数1", jsonObject.getString("para1")); + map.put("参数2", jsonObject.getString("para2")); + map.put("参数3", jsonObject.getString("para3")); + map.put("创建日期", jsonObject.getString("create_time")); + list.add(map); + } + } FileUtil.downloadExcel(list, response); } @@ -170,4 +161,5 @@ public class DictServiceImpl implements DictService { final DictDto obj = json.toJavaObject(DictDto.class); return obj; } + } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/wql/SYS_DICT.wql b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/wql/SYS_DICT.wql index 9aaaf1f..b58fb01 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/wql/SYS_DICT.wql +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/wql/SYS_DICT.wql @@ -43,6 +43,7 @@ IF 输入.flag = "1" PAGEQUERY SELECT + max(dict_id) as dict_id, code, name FROM