字典更新
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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<Long> 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<DictDto> dictDtos, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
// for (DictDto dictDTO : dictDtos) {
|
||||
// if(CollectionUtil.isNotEmpty(dictDTO.getDictDetails())){
|
||||
// for (DictDetailDto dictDetail : dictDTO.getDictDetails()) {
|
||||
// Map<String,Object> 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<String,Object> 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<String,Object> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
max(dict_id) as dict_id,
|
||||
code,
|
||||
name
|
||||
FROM
|
||||
|
||||
Reference in New Issue
Block a user