数据字典列表增加查询条件和标签内容区分
This commit is contained in:
+3
-2
@@ -4,8 +4,9 @@ package com.jero.modules.enums;
|
||||
public enum FixedFieldEnum {
|
||||
NON_FIXED_FIELD_ENUM("非固定字段","0"),
|
||||
FIXED_FIELD_ENUM("固定字段","1"),
|
||||
CONFIGURABLE_FIELD("字段固定,内部可配","2");
|
||||
|
||||
CONFIGURABLE_FIELD("字段固定,内部可配","2"),
|
||||
SYS_DICT_SYSTEM("系统数据字典标志值","0"),
|
||||
;
|
||||
String name;
|
||||
String value;
|
||||
|
||||
|
||||
+51
-21
@@ -81,6 +81,7 @@ public class SysDictController {
|
||||
Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
|
||||
queryWrapper.eq("del_flag",CommonConstant.DEL_FLAG_0);
|
||||
queryWrapper.eq("is_tag_dict",FixedFieldEnum.SYS_DICT_SYSTEM.getValue());
|
||||
Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
|
||||
IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
|
||||
log.debug("查询当前页:"+pageList.getCurrent());
|
||||
@@ -384,21 +385,25 @@ public class SysDictController {
|
||||
@RequiresPermissions("dict:add")
|
||||
public Result<SysDict> add(@RequestBody SysDict sysDict) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
//校验--不能重复数据
|
||||
QueryWrapper<SysDict> queryWrapper = new QueryWrapper<>();
|
||||
//查询同一模块下,同名数据
|
||||
queryWrapper.eq("dict_name",sysDict.getDictName());
|
||||
List<SysDict> existDictList = this.sysDictService.list(queryWrapper);
|
||||
try {
|
||||
Integer count = sysDictService.queryExitData(sysDict);
|
||||
Integer countDictName=sysDictService.queryExitDictName(sysDict);
|
||||
System.out.println("count="+count);
|
||||
if (countDictName > 0) {
|
||||
result.error500("标签名称不能重复");
|
||||
}else{
|
||||
//判断逻辑删除
|
||||
if (count > 0) {
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
} else {
|
||||
if(ObjectUtils.isNotEmpty(sysDict.getIsTagDict()) && sysDict.getIsTagDict() == 1){
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(sysDict.getDictName());
|
||||
sysDict.setDictCode(pinYin.replace(" ","_"));
|
||||
}
|
||||
if(!existDictList.isEmpty()) {
|
||||
SysDict sysDictDB = existDictList.get(0);
|
||||
//存在重复同名标签内容,且已删,恢复
|
||||
if (sysDictDB.getDelFlag() == CommonConstant.DEL_FLAG_1) {
|
||||
sysDictService.updateDictDelFlag(CommonConstant.DEL_FLAG_0, sysDictDB.getId());
|
||||
}else{//存在重复同名标签内容,未删
|
||||
result.error500("标签名称不能重复");
|
||||
}
|
||||
} else {//不是同名
|
||||
if(ObjectUtils.isNotEmpty(sysDict.getIsTagDict()) && sysDict.getIsTagDict() == 1){
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(sysDict.getDictName());
|
||||
sysDict.setDictCode(pinYin.replace(" ","_"));
|
||||
|
||||
sysDict.setCreateTime(new Date());
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
sysDictService.save(sysDict);
|
||||
@@ -432,13 +437,38 @@ public class SysDictController {
|
||||
if (StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(String.valueOf(sysDict.getIsReadOnly()))) {
|
||||
result.error500("固定字段,不可修改");
|
||||
}else{
|
||||
sysDict.setUpdateTime(new Date());
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
if (ok) {
|
||||
result.success("编辑成功!");
|
||||
//编辑成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
} else {
|
||||
//校验--不能重复数据
|
||||
QueryWrapper<SysDict> queryWrapper = new QueryWrapper<>();
|
||||
//查询同一模块下,同名数据
|
||||
queryWrapper.eq("dict_name", sysDict.getDictName());
|
||||
List<SysDict> existDictList = this.sysDictService.list(queryWrapper);
|
||||
if (!existDictList.isEmpty()) {
|
||||
if (existDictList.get(0).getId().equals(sysDict.getId())) {//已存在同名的数据,就是正在编辑的这个
|
||||
sysDict.setUpdateTime(new Date());
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
if (ok) {
|
||||
result.success("编辑成功!");
|
||||
//编辑成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
} else {//已存在同名的数据,不是正在编辑的这个
|
||||
SysDict sysDictDB = existDictList.get(0);
|
||||
//存在重复同名标签内容,且已删,恢复
|
||||
if (sysDictDB.getDelFlag() == CommonConstant.DEL_FLAG_1) {
|
||||
sysDictService.updateDictDelFlag(CommonConstant.DEL_FLAG_0, sysDictDB.getId());
|
||||
} else {//存在重复同名标签内容,未删
|
||||
result.error500("标签名称不能重复");
|
||||
}
|
||||
}
|
||||
} else {//不是同名
|
||||
sysDict.setUpdateTime(new Date());
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
if (ok) {
|
||||
result.success("编辑成功!");
|
||||
//编辑成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user