update 通用增删查改基础

This commit is contained in:
liao
2023-08-24 15:46:32 +08:00
parent d9168579de
commit 18e3b9bffc
3 changed files with 14 additions and 14 deletions
@@ -64,7 +64,7 @@ public class LawsCommonController {
@AutoLog(value = "通用操作-获取表单模型")
@ApiOperation(value="通用操作-获取表单模型", notes="通用操作-获取表单模型")
@GetMapping(value = "getFormModel")
public Result<List<Map<String,Object>>> getFormModel(@RequestParam(name="module") String module) {
public Result<Map<String,Object>> getFormModel(@RequestParam(name="module") String module) {
return Result.OK(lawsCommonService.getFormModel(module));
}
@@ -53,7 +53,7 @@ public interface ILawsCommonService {
* @Date: 2023/8/24 10:53
* @Description: 获取表单模型
**/
List<Map<String, Object>> getFormModel(String module);
Map<String, Object> getFormModel(String module);
/**
* @Author: liao
@@ -200,7 +200,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
map.put("db_field_txt", lawsTag.getDbFieldEnName());//字段英文名
}
// 树型结构的集合
if (FieldTypeEnum.TREE.equals(lawsTag.getFieldShowType())) {
if (FieldTypeEnum.TREE.getValue().equals(lawsTag.getFieldShowType())) {
// 对树型结构做处理
map.put("tree", new java.util.ArrayList<>());
} else {
@@ -217,7 +217,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
* @Description: 获取表单模型
**/
@Override
public List<Map<String, Object>> getFormModel(String module) {
public Map<String, Object> getFormModel(String module) {
// 获取操作语言
LanguageEnum language = MessageUtils.getLanguage();
// 获取要操作的表名
@@ -231,10 +231,8 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
LawsArea lawsArea = new LawsArea();
lawsArea.setIsModel(module);
List<LawsArea> areaList = lawsAreaService.queryList(lawsArea);
// 用于返回的集合
List<Map<String, Object>> resultList = new java.util.ArrayList<>();
// 区域集合
Map<String, Object> areaMap = new HashMap<>();
// 用于返回的区域集合
Map<String, Object> areaMap = new LinkedHashMap<>();
// 遍历每个区域做处理
for (LawsArea area : areaList) {
// 获取该区域的所有字段
@@ -260,13 +258,16 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
fieldMap.put("db_field_txt", lawsTag.getDbFieldEnName());//字段英文名
}
fieldMap.put("field_show_type", lawsTag.getFieldShowType()); // 字段类型
fieldMap.put("dict_field", lawsTag.getDictField()); // 字典编码
fieldMap.put("dict_field", ""); // 字典编码
if (StringUtils.isNotBlank(lawsTag.getDictField())) {
fieldMap.put("dict_field", lawsTag.getDictField()); // 字典编码
}
fieldMap.put("show_area", lawsTag.getShowArea()); // 显示区域
fieldMap.put("field_must_input", lawsTag.getFieldMustInput()); // 是否必填
fieldMap.put("db_length", lawsTag.getDbLength()); // 字段长度
fieldMap.put("isReadOnly", lawsTag.getIsReadOnly()); // 是否只读
// 树型结构做处理
if (FieldTypeEnum.TREE.equals(lawsTag.getFieldShowType())) {
if (FieldTypeEnum.TREE.getValue().equals(lawsTag.getFieldShowType())) {
fieldMap.put("tree", new java.util.ArrayList<>());
} else {
fieldMap.put("tree", new java.util.ArrayList<>());
@@ -275,8 +276,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
}
areaMap.put(areaName, fieldMapList);
}
resultList.add(areaMap);
return resultList;
return areaMap;
}
/**
@@ -357,7 +357,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
* @Description: 对数据值做格式处理
**/
private String setValue(String fieldShowType, String value) {
if (FieldTypeEnum.DATE_SINGLE.equals(fieldShowType)) {
if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) {
// 如果是单日期格式,做格式处理
value = "str_to_date('" + value + "','%Y-%m-%d %H:%i:%s')";
} else {
@@ -401,7 +401,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
.equals(lawsTag.getIsShowForm().toString())).collect(Collectors.toList());
}
// 筛选获取日期类型字段
List<String> dateFieldList = fieldList.stream().filter(lawsTag -> FieldTypeEnum.DATE_SINGLE
List<String> dateFieldList = fieldList.stream().filter(lawsTag -> FieldTypeEnum.DATE_SINGLE.getValue()
.equals(lawsTag.getFieldShowType())).collect(Collectors.toList())
.stream().map(LawsTag::getDbFieldName).collect(Collectors.toList());
// 获取全部的字段列表