From 40c13f87313eb604973f97676469104ebab61192 Mon Sep 17 00:00:00 2001 From: xiejunyu Date: Tue, 1 Mar 2022 13:18:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jero/modules/enums/FixedFieldEnum.java | 32 ++++++++++++ .../system/controller/SysDictController.java | 17 +++---- .../jero/modules/system/entity/SysDict.java | 4 -- .../modules/system/entity/SysDictItem.java | 4 -- .../system/service/ISysDictService.java | 8 ++- .../service/impl/SysDictServiceImpl.java | 15 ++++++ .../controller/OnlCgformTagController.java | 13 +++-- .../tag/service/IOnlCgformTagService.java | 17 +++++-- .../service/impl/OnlCgformTagServiceImpl.java | 49 ++++++++++++++++--- 9 files changed, 123 insertions(+), 36 deletions(-) create mode 100644 jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/enums/FixedFieldEnum.java diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/enums/FixedFieldEnum.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/enums/FixedFieldEnum.java new file mode 100644 index 000000000..9d42f3a37 --- /dev/null +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/enums/FixedFieldEnum.java @@ -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; + } +} diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/SysDictController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/SysDictController.java index 29da10d76..7f1704646 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/SysDictController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/SysDictController.java @@ -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 add(@RequestBody SysDict sysDict) { Result result = new Result(); 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 result = new Result(); 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(","))); diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDict.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDict.java index 76c2fccf3..7066fc941 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDict.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDict.java @@ -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; } \ No newline at end of file diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java index 4c9b89b35..8e568e8bc 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java @@ -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; } diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/ISysDictService.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/ISysDictService.java index aaa3b902e..8735f66d0 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/ISysDictService.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/ISysDictService.java @@ -149,6 +149,12 @@ public interface ISysDictService extends IService { */ void refreshCache(); - SysDict queryById(String id); + + /** + * 根据标签名称,标签类型一致还原数据 + * + * @return + */ + Integer queryExitData(SysDict sysDict); } diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysDictServiceImpl.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysDictServiceImpl.java index 6a87911ab..47c5339a5 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysDictServiceImpl.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysDictServiceImpl.java @@ -332,4 +332,19 @@ public class SysDictServiceImpl extends ServiceImpl impl public SysDict queryById(String id) { return getById(id); } + + /** + * 根据标签名称,标签类型一致还原数据 + * + * @return + */ + @Override + public Integer queryExitData(SysDict sysDict) { + LambdaQueryWrapper 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; + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/controller/OnlCgformTagController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/controller/OnlCgformTagController.java index 68413f1c7..f600adc26 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/controller/OnlCgformTagController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/controller/OnlCgformTagController.java @@ -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>> queryCondition(@RequestParam(name = "flag") String flag, @RequestParam(name = "cut") String cut) { @@ -137,7 +138,7 @@ public class OnlCgformTagController extends JeroController 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 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 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(","))); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/IOnlCgformTagService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/IOnlCgformTagService.java index d102f3488..c95304097 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/IOnlCgformTagService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/IOnlCgformTagService.java @@ -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 { List queryList(OnlCgformArea onlCgformArea); /** - * 同一“所属模块”下的“属性名称”不能重复 + * 根据所属模块、属性名称、英文名称是否一致还原数据 * * @return */ - Result queryExitData(OnlCgformTag onlCgformTag) ; + Integer queryExitData(OnlCgformTag onlCgformTag) ; /** * 列表表头中英文切换 @@ -77,7 +76,7 @@ public interface IOnlCgformTagService extends IService { * @param cut * @return */ - public List> getHeader(String flag, String cut); + List> getHeader(String flag, String cut); /** * 查询条件中英文切换 @@ -85,5 +84,13 @@ public interface IOnlCgformTagService extends IService { * @param cut * @return */ - public List> queryCondition(String flag, String cut); + List> queryCondition(String flag, String cut); + + /** + * 表单中英文切换 + * @param flag + * @param cut + * @return + */ + List> getForm(String flag, String cut); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/impl/OnlCgformTagServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/impl/OnlCgformTagServiceImpl.java index 7f49e394c..3ca726b32 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/impl/OnlCgformTagServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/tag/service/impl/OnlCgformTagServiceImpl.java @@ -136,18 +136,25 @@ public class OnlCgformTagServiceImpl extends ServiceImpl> list = new ArrayList<>(); for (OnlCgformField onlCgformField : fieldList) { Map 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> getForm(String flag, String cut) { + List 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> list = new ArrayList<>(); + for (OnlCgformField onlCgformField : fieldList) { + Map 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; + } +}