标签修改

This commit is contained in:
xiejunyu
2022-03-01 13:19:42 +08:00
parent 78a9d15bd5
commit 40c13f8731
9 changed files with 123 additions and 36 deletions
@@ -0,0 +1,32 @@
package com.jero.modules.enums;
public enum FixedFieldEnum {
NON_FIXED_FIELD_ENUM("非固定字段","0"),
FIXED_FIELD_ENUM("固定字段","1"),
CONFIGURABLE_FIELD("字段固定,内部可配","2");
String name;
String value;
private FixedFieldEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -14,6 +14,7 @@ import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.ImportExcelUtil;
import com.jero.common.util.SqlInjectionUtil;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.enums.FixedFieldEnum;
import com.jero.modules.system.entity.SysDict;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.model.SysDictTree;
@@ -342,14 +343,11 @@ public class SysDictController {
public Result<SysDict> add(@RequestBody SysDict sysDict) {
Result<SysDict> result = new Result<SysDict>();
try {
/*if (StringUtils.isNotBlank(sysDict.getDictCode())) {
if(sysDict.getIsTagDict()==1){
sysDict.setDictEnName(sysDict.getDictCode().replace("_", " "));
sysDict.setDictCode(sysDict.getDictEnName().replace(" ", "_"));
}
}*/
Integer count=sysDictService.queryExitData(sysDict);
if (count > 0) {
sysDict.setDelFlag(0);
} else {
if(StringUtils.isEmpty(sysDict.getDictCode())){
//result.error500("字典Code不能为空");
sysDict.setDictCode(sysDict.getDictName());
}else {
sysDict.setCreateTime(new Date());
@@ -360,6 +358,7 @@ public class SysDictController {
//添加成功后需要刷新缓存
sysDictService.refreshCache();
}
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
@@ -417,7 +416,7 @@ public class SysDictController {
Result<SysDict> result = new Result<SysDict>();
SysDict sysDict = sysDictService.queryById(id);
if (StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
if (sysDict.getIsReadOnly() == 1) {
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(sysDict.getIsReadOnly())) {
result.error500("固定字段,不可删除");
} else {
boolean ok = sysDictService.removeById(id);
@@ -445,7 +444,7 @@ public class SysDictController {
result.error500("参数不识别!");
}else {
if (StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
if (sysDict.getIsReadOnly() == 1) {
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(sysDict.getIsReadOnly())) {
result.error500("固定字段,不可删除");
} else {
sysDictService.removeByIds(Arrays.asList(ids.split(",")));
@@ -110,8 +110,4 @@ public class SysDict implements Serializable {
@Dict(dicCode = "attribute_type")
private java.lang.String attributeType;
/**逻辑删除标识 0未删 1已删*/
@Excel(name = "逻辑删除标识 0未删 1已删", width = 15)
@ApiModelProperty(value = "逻辑删除标识 0未删 1已删")
private Integer isDelete;
}
@@ -97,8 +97,4 @@ public class SysDictItem implements Serializable {
@Dict(dicCode = "attribute_type")
private java.lang.String attributeType;
/**逻辑删除标识 0未删 1已删*/
@Excel(name = "逻辑删除标识 0未删 1已删", width = 15)
@ApiModelProperty(value = "逻辑删除标识 0未删 1已删")
private Integer isDelete;
}
@@ -149,6 +149,12 @@ public interface ISysDictService extends IService<SysDict> {
*/
void refreshCache();
SysDict queryById(String id);
/**
* 根据标签名称,标签类型一致还原数据
*
* @return
*/
Integer queryExitData(SysDict sysDict);
}
@@ -332,4 +332,19 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public SysDict queryById(String id) {
return getById(id);
}
/**
* 根据标签名称,标签类型一致还原数据
*
* @return
*/
@Override
public Integer queryExitData(SysDict sysDict) {
LambdaQueryWrapper<SysDict> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(sysDict.getDictName())) {// && StringUtils.isNotBlank(onlCgformTag.getDbFieldName())) {
queryWrapper.eq(SysDict::getDictName, sysDict.getDictName()).and(wq -> wq.eq(SysDict::getAttributeType, sysDict.getAttributeType()));
}
Integer count = sysDictMapper.selectCount(queryWrapper);
return count;
}
}