标签修改

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;
}
}
@@ -9,6 +9,7 @@ import com.jero.common.system.base.controller.JeroController;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.tag.entity.OnlCgformArea;
import com.jero.modules.tag.entity.OnlCgformTag;
import com.jero.modules.enums.FixedFieldEnum;
import com.jero.modules.tag.service.IOnlCgformTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -86,8 +87,8 @@ public class OnlCgformTagController extends JeroController<OnlCgformTag, IOnlCgf
*
* @return
*/
@AutoLog(value = "OCR识别转换记录表-查询条件中英文切换")
@ApiOperation(value="OCR识别转换记录表-查询条件中英文切换", notes="OCR识别转换记录表-查询条件中英文切换")
@AutoLog(value = "标签管理-查询条件中英文切换")
@ApiOperation(value="标签管理-查询条件中英文切换", notes="OCR识别转换记录表-查询条件中英文切换")
@GetMapping(value = "/queryCondition")
public Result<List<Map<String, Object>>> queryCondition(@RequestParam(name = "flag") String flag,
@RequestParam(name = "cut") String cut) {
@@ -137,7 +138,7 @@ public class OnlCgformTagController extends JeroController<OnlCgformTag, IOnlCgf
@ApiOperation(value="标签管理-编辑", notes="标签管理-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OnlCgformTag onlCgformTag) {
if(onlCgformTag.getIsReadOnly() == 1 || onlCgformTag.getIsReadOnly()==2){
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(onlCgformTag.getIsReadOnly()) || FixedFieldEnum.CONFIGURABLE_FIELD.getValue().equals(onlCgformTag.getIsReadOnly())) {
return Result.error("固定字段,不可修改");
}else {
onlCgformTagService.editById(onlCgformTag);
@@ -158,8 +159,7 @@ public class OnlCgformTagController extends JeroController<OnlCgformTag, IOnlCgf
Result<OnlCgformTag> result = new Result<>();
OnlCgformTag onlCgformTag = onlCgformTagService.queryById(id);
if(StringUtils.isNotBlank(String.valueOf(onlCgformTag.getIsReadOnly()))) {
//TODO 使用枚举的形式定义
if (onlCgformTag.getIsReadOnly() == 1 || onlCgformTag.getIsReadOnly() == 2) {
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(onlCgformTag.getIsReadOnly()) || FixedFieldEnum.CONFIGURABLE_FIELD.getValue().equals(onlCgformTag.getIsReadOnly())) {
result.error500("固定字段,不可删除");
} else {
onlCgformTagService.deleteById(id);
@@ -180,8 +180,7 @@ public class OnlCgformTagController extends JeroController<OnlCgformTag, IOnlCgf
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
OnlCgformTag onlCgformTag = onlCgformTagService.queryById(ids);
//TODO 使用枚举的形式定义
if(onlCgformTag.getIsReadOnly() == 1 || onlCgformTag.getIsReadOnly()==2){
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(onlCgformTag.getIsReadOnly()) || FixedFieldEnum.CONFIGURABLE_FIELD.getValue().equals(onlCgformTag.getIsReadOnly())) {
return Result.error("固定字段,不可删除");
}else {
this.onlCgformTagService.deleteByIds(Arrays.asList(ids.split(",")));
@@ -1,7 +1,6 @@
package com.jero.modules.tag.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.api.vo.Result;
import com.jero.modules.tag.entity.OnlCgformArea;
import com.jero.modules.tag.entity.OnlCgformTag;
@@ -65,11 +64,11 @@ public interface IOnlCgformTagService extends IService<OnlCgformTag> {
List<OnlCgformTag> queryList(OnlCgformArea onlCgformArea);
/**
* 同一“所属模块”下的“属性名称”不能重复
* 根据所属模块、属性名称、英文名称是否一致还原数据
*
* @return
*/
Result<?> queryExitData(OnlCgformTag onlCgformTag) ;
Integer queryExitData(OnlCgformTag onlCgformTag) ;
/**
* 列表表头中英文切换
@@ -77,7 +76,7 @@ public interface IOnlCgformTagService extends IService<OnlCgformTag> {
* @param cut
* @return
*/
public List<Map<String, Object>> getHeader(String flag, String cut);
List<Map<String, Object>> getHeader(String flag, String cut);
/**
* 查询条件中英文切换
@@ -85,5 +84,13 @@ public interface IOnlCgformTagService extends IService<OnlCgformTag> {
* @param cut
* @return
*/
public List<Map<String, Object>> queryCondition(String flag, String cut);
List<Map<String, Object>> queryCondition(String flag, String cut);
/**
* 表单中英文切换
* @param flag
* @param cut
* @return
*/
List<Map<String, Object>> getForm(String flag, String cut);
}
@@ -136,18 +136,25 @@ public class OnlCgformTagServiceImpl extends ServiceImpl<OnlCgformTagMapper, Onl
List<Map<String, Object>> list = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldList) {
Map<String, Object> map = new HashMap<>();
if ("file_name".equals(onlCgformField.getDbFieldName())) {
if("file_name".equals(onlCgformField.getDbFieldName())){
//跳转详情的标识
map.put("click", "true");
map.put("click","true");
}
//单独处理发布日期和标准实施日期
if ("update_time".equals(onlCgformField.getDbFieldName())) {
map.put("sort", "true");//列表排序标识
}
map.put("db_field_name", LineHumpUtil.lineToHump(onlCgformField.getDbFieldName()));//字段
if (CutEnum.CN.getValue().equals(cut)) {
String dbFieldName = onlCgformField.getDbFieldName();
if (org.apache.commons.lang.StringUtils.isNotBlank(onlCgformField.getDictField())) {
map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName)+ "_dictText");//配置了数据字典的字段,需要特殊处理
}else{
map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName));//字段
}
if(CutEnum.CN.getValue().equals(cut)){
map.put("db_field_txt", onlCgformField.getDbFieldTxt());//字段中文名
} else {
}else{
map.put("db_field_txt", onlCgformField.getDbFieldEnName());//字段英文名
}
list.add(map);
@@ -182,4 +189,34 @@ public class OnlCgformTagServiceImpl extends ServiceImpl<OnlCgformTagMapper, Onl
}
return list;
}
}
/**
* 表单中英文切换
*
* @return
*/
@Override
public List<Map<String, Object>> getForm(String flag, String cut) {
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
if (fieldList.size() != 0) {
//过滤出搜索条件()
fieldList = fieldList.stream().filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm()))).collect(Collectors.toList());
}
List<Map<String, Object>> list = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldList) {
Map<String, Object> map = new HashMap<>();
map.put("area", null);//展示区域。没用到
map.put("field_show_type", onlCgformField.getFieldShowType());//类型(判断是下拉还是输入框,等等)
map.put("field_must_input", onlCgformField.getFieldMustInput());//是否必填
map.put("dict_field", onlCgformField.getDictField()); //下拉类型的数据字典编码
map.put("db_field_name", LineHumpUtil.lineToHump(onlCgformField.getDbFieldName()));//字段
if (CutEnum.CN.getValue().equals(cut)) {
map.put("db_field_txt", onlCgformField.getDbFieldTxt());//字段中文名
} else {
map.put("db_field_txt", onlCgformField.getDbFieldEnName());//字段英文名
}
list.add(map);
}
return list;
}
}