update 类重命名

This commit is contained in:
lijiarao
2023-08-25 15:00:33 +08:00
parent 6120e2a6f6
commit b34504175f
4 changed files with 40 additions and 75 deletions
@@ -13,7 +13,7 @@ import com.jero.modules.laws.common.mapper.LawsCommonMapper;
import com.jero.modules.laws.common.service.ILawsCommonService; import com.jero.modules.laws.common.service.ILawsCommonService;
import com.jero.modules.tag.entity.LawsArea; import com.jero.modules.tag.entity.LawsArea;
import com.jero.modules.tag.entity.LawsTag; import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.FileTableIdEnum; import com.jero.modules.tag.enums.TableNameEnum;
import com.jero.modules.tag.enums.LawsFieldTypeEnum; import com.jero.modules.tag.enums.LawsFieldTypeEnum;
import com.jero.modules.tag.service.ILawsAreaService; import com.jero.modules.tag.service.ILawsAreaService;
import com.spire.ms.System.Collections.ArrayList; import com.spire.ms.System.Collections.ArrayList;
@@ -50,7 +50,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 获取操作模块 // 获取操作模块
String module = parameterMap.get("module").toString(); String module = parameterMap.get("module").toString();
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 查询全部字段列表 // 查询全部字段列表
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
@@ -127,7 +127,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
@Override @Override
public List<LawsTag> getCommonHeader(String module) { public List<LawsTag> getCommonHeader(String module) {
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
// 筛选出用于列表显示的字段(isShowList **列表是否显示0否 1是* // 筛选出用于列表显示的字段(isShowList **列表是否显示0否 1是*
@@ -146,7 +146,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 获取操作模块 // 获取操作模块
String module = parameterMap.get("module").toString(); String module = parameterMap.get("module").toString();
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
// 筛选出表单显示的 // 筛选出表单显示的
@@ -192,7 +192,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
String id = parameterMap.get("id").toString(); String id = parameterMap.get("id").toString();
parameterMap.remove("id"); parameterMap.remove("id");
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
// 筛选出表单显示的 // 筛选出表单显示的
@@ -235,7 +235,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 获取操作语言 // 获取操作语言
LanguageEnum language = MessageUtils.getLanguage(); LanguageEnum language = MessageUtils.getLanguage();
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
fieldList = fieldList.stream().filter(lawsTag -> YesOrNoEnum.YES.getInteger() fieldList = fieldList.stream().filter(lawsTag -> YesOrNoEnum.YES.getInteger()
@@ -266,7 +266,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 获取操作语言 // 获取操作语言
LanguageEnum language = MessageUtils.getLanguage(); LanguageEnum language = MessageUtils.getLanguage();
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
// 筛选表单显示的字段 // 筛选表单显示的字段
@@ -326,7 +326,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
@Override @Override
public Map<String, Object> getByIdAndModule(String id, String module) { public Map<String, Object> getByIdAndModule(String id, String module) {
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取全部字段 // 获取全部字段
List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName); List<LawsTag> fieldList = lawsCommonMapper.getFieldList(tableName);
@@ -351,7 +351,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
@Override @Override
public String deleteByIdsAndModule(String ids, String module) { public String deleteByIdsAndModule(String ids, String module) {
// 获取要操作的表名 // 获取要操作的表名
String tableName = FileTableIdEnum.getTableName(module); String tableName = TableNameEnum.getTableName(module);
// 获取要删除的id集合 // 获取要删除的id集合
if (StringUtils.isBlank(ids)) { if (StringUtils.isBlank(ids)) {
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.ERROR)); throw new JeroBootException(MessageUtils.getMessage(ResultCommon.ERROR));
@@ -10,7 +10,7 @@ import com.jero.common.system.base.controller.JeroController;
import com.jero.common.util.MessageUtils; import com.jero.common.util.MessageUtils;
import com.jero.modules.enums.FixedFieldEnum; import com.jero.modules.enums.FixedFieldEnum;
import com.jero.modules.tag.entity.LawsTag; import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.FileTableIdEnum; import com.jero.modules.tag.enums.TableNameEnum;
import com.jero.modules.tag.service.ILawsTagService; import com.jero.modules.tag.service.ILawsTagService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -106,18 +106,18 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
}else{ }else{
//类不同, 删除原标签,同步数据库.再加回来新的,再同步 //类不同, 删除原标签,同步数据库.再加回来新的,再同步
this.lawsTagService.deleteById(lawsTagDB.getId()); this.lawsTagService.deleteById(lawsTagDB.getId());
if(lawsTag.getIsModel().equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库 if(lawsTag.getIsModel().equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
}else {//同步文档拆分 }else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
this.lawsTagService.add(lawsTag); this.lawsTagService.add(lawsTag);
} }
if(lawsTag.getIsModel().equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库 if(lawsTag.getIsModel().equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
}else {//同步文档拆分 }else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
}else{ }else{
//中英切换提示语 //中英切换提示语
@@ -125,10 +125,10 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
} }
}else { }else {
lawsTagService.add(lawsTag); lawsTagService.add(lawsTag);
if(lawsTag.getIsModel().equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库 if(lawsTag.getIsModel().equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
}else {//同步文档拆分 }else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
return result.success("添加成功!"); return result.success("添加成功!");
} }
@@ -151,7 +151,7 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
return Result.error(MessageUtils.getMessage("tag.edit.固定字段,不可修改")); return Result.error(MessageUtils.getMessage("tag.edit.固定字段,不可修改"));
}else { }else {
String isModel = lawsTag.getIsModel(); String isModel = lawsTag.getIsModel();
String tableName = FileTableIdEnum.getTableName(isModel); String tableName = TableNameEnum.getTableName(isModel);
QueryWrapper<LawsTag> queryWrapper=new QueryWrapper<>(); QueryWrapper<LawsTag> queryWrapper=new QueryWrapper<>();
//查询同一模块下,同名数据 //查询同一模块下,同名数据
queryWrapper.eq("db_Field_txt", lawsTag.getDbFieldTxt()) queryWrapper.eq("db_Field_txt", lawsTag.getDbFieldTxt())
@@ -164,11 +164,11 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
if (lawsTagOld.getId().equals(lawsTag.getId())) { if (lawsTagOld.getId().equals(lawsTag.getId())) {
lawsTagService.editById(lawsTag); lawsTagService.editById(lawsTag);
//同步文档库 //同步文档库
if (isModel.equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) { if (isModel.equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
} else {//同步文档拆分 } else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
//已存在同名的数据,不是正在编辑的这个 //已存在同名的数据,不是正在编辑的这个
} else { } else {
@@ -177,10 +177,10 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
lawsTagService.updateDictDelFlag(CommonConstant.DEL_FLAG_0, lawsTagOld.getId()); lawsTagService.updateDictDelFlag(CommonConstant.DEL_FLAG_0, lawsTagOld.getId());
lawsTag.setId(lawsTagOld.getId()); lawsTag.setId(lawsTagOld.getId());
lawsTagService.editById(lawsTag); lawsTagService.editById(lawsTag);
if (isModel.equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库 if (isModel.equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
} else {//同步文档拆分 } else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
//有未删数据,报错 //有未删数据,报错
} else { } else {
@@ -189,10 +189,10 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
} }
}else{ }else{
lawsTagService.editById(lawsTag); lawsTagService.editById(lawsTag);
if(isModel.equals(FileTableIdEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库 if(isModel.equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())) {//同步文档库
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID.getValue()), "normal");
}else {//同步文档拆分 }else {//同步文档拆分
//this.onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_SPLIT_ID.getValue()), "normal"); //this.onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_SPLIT_ID.getValue()), "normal");
} }
} }
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
@@ -221,7 +221,7 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
return Result.error(MessageUtils.getMessage("tag.edit.固定字段,不可删除")); return Result.error(MessageUtils.getMessage("tag.edit.固定字段,不可删除"));
} else { } else {
lawsTagService.removeById(id); lawsTagService.removeById(id);
////onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID),"normal");//逻辑删除-->改变状态,数据库不删 ////onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID),"normal");//逻辑删除-->改变状态,数据库不删
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
} }
@@ -258,7 +258,7 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
} }
} else { } else {
lawsTagService.removeById(midTag.getId()); lawsTagService.removeById(midTag.getId());
////onlCgformApiController.h(String.valueOf(FileTableIdEnum.FILE_TABLE_ID),"normal");//逻辑删除-->改变状态,数据库不删 ////onlCgformApiController.h(String.valueOf(TableNameEnum.FILE_TABLE_ID),"normal");//逻辑删除-->改变状态,数据库不删
//中英切换提示语 //中英切换提示语
if(LanguageEnum.CN.getValue().equals(midTag.getCut())) { if(LanguageEnum.CN.getValue().equals(midTag.getCut())) {
result.success("批量删除成功!"); result.success("批量删除成功!");
@@ -6,7 +6,7 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum FileTableIdEnum { public enum TableNameEnum {
/** /**
* *
*/ */
@@ -20,9 +20,9 @@ public enum FileTableIdEnum {
String value; String value;
public static String getTableName(String value){ public static String getTableName(String value){
for (FileTableIdEnum fileTableIdEnum : values()) { for (TableNameEnum tableNameEnum : values()) {
if (fileTableIdEnum.getValue().equals(value)) { if (tableNameEnum.getValue().equals(value)) {
return fileTableIdEnum.getTableName(); return tableNameEnum.getTableName();
} }
} }
throw new JeroBootException("标签类型不存在"); throw new JeroBootException("标签类型不存在");
@@ -18,7 +18,7 @@ import com.jero.modules.system.service.impl.SysDictServiceImpl;
import com.jero.modules.system.util.HanYuPinYinUtil; import com.jero.modules.system.util.HanYuPinYinUtil;
import com.jero.modules.tag.entity.LawsArea; import com.jero.modules.tag.entity.LawsArea;
import com.jero.modules.tag.entity.LawsTag; import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.FileTableIdEnum; import com.jero.modules.tag.enums.TableNameEnum;
import com.jero.modules.tag.mapper.LawsTagMapper; import com.jero.modules.tag.mapper.LawsTagMapper;
import com.jero.modules.tag.service.ILawsTagService; import com.jero.modules.tag.service.ILawsTagService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -117,10 +117,10 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
} }
} }
lawsTag.setDelFlag(CommonConstant.DEL_FLAG_0); lawsTag.setDelFlag(CommonConstant.DEL_FLAG_0);
//if(lawsTag.getIsModel().equals(FileTableIdEnum.FILE_TABLE_IS_MODEL.getValue())) {//设置文档库-表id //if(lawsTag.getIsModel().equals(TableNameEnum.FILE_TABLE_IS_MODEL.getValue())) {//设置文档库-表id
// lawsTag.setCgformHeadId(FileTableIdEnum.FILE_TABLE_ID.getValue()); // lawsTag.setCgformHeadId(TableNameEnum.FILE_TABLE_ID.getValue());
//}else {//设置文档拆分-表id //}else {//设置文档拆分-表id
// lawsTag.setCgformHeadId(FileTableIdEnum.FILE_SPLIT_ID.getValue()); // lawsTag.setCgformHeadId(TableNameEnum.FILE_SPLIT_ID.getValue());
//} //}
lawsTag.setDbIsKey(Integer.valueOf(YesOrNoEnum.NO.getValue())); lawsTag.setDbIsKey(Integer.valueOf(YesOrNoEnum.NO.getValue()));
lawsTag.setDbIsNull(Integer.valueOf(YesOrNoEnum.YES.getValue())); lawsTag.setDbIsNull(Integer.valueOf(YesOrNoEnum.YES.getValue()));
@@ -160,41 +160,6 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
@Override @Override
public void editById(LawsTag lawsTag) { public void editById(LawsTag lawsTag) {
Integer inputOrderNum = lawsTag.getOrderNum(); Integer inputOrderNum = lawsTag.getOrderNum();
//查询展示顺序相同的
QueryWrapper<LawsTag> queryWrapper= new QueryWrapper<>();
queryWrapper.eq("is_model", lawsTag.getIsModel())
.eq("is_delete",CommonConstant.DEL_FLAG_0)
.orderByAsc("order_num");
Integer orderNumData = list(queryWrapper).stream().filter(e->e.getId().equals(lawsTag.getId()))
.map(e -> e.getOrderNum()).collect(Collectors.toList()).get(0);
queryWrapper.eq("order_num", inputOrderNum);
Integer orderNumCount = lawsTagMapper.selectCount(queryWrapper);
//有重复展示顺序的,后面的号全+1
if(orderNumCount > 0 && !orderNumData.equals(inputOrderNum)) {
//设置排序
QueryWrapper<LawsTag> orderNumQueryWrapper = new QueryWrapper<>();
orderNumQueryWrapper.ge("order_num", inputOrderNum)
.eq("is_model", lawsTag.getIsModel())
.eq("is_delete", CommonConstant.DEL_FLAG_0)
.orderByAsc("order_num");
List<LawsTag> geOrderNumList = list(orderNumQueryWrapper);
//判断相邻的序号,去掉不邻的
for(int i = 0 ; i < geOrderNumList.size() ; i++) {
if (geOrderNumList.size()==1){
break;
}else if(i+1 >= geOrderNumList.size()){
break;
}else if (geOrderNumList.get(i + 1).getOrderNum() - geOrderNumList.get(i).getOrderNum() > 1) {
int deleteStart = geOrderNumList.get(i+1).getOrderNum();
geOrderNumList = geOrderNumList.stream().filter(e->e.getOrderNum() < deleteStart).collect(Collectors.toList());
break;
}
}
geOrderNumList.stream().forEach(e -> e.setOrderNum(e.getOrderNum() + 1));
saveOrUpdateBatch(geOrderNumList);
}
//字段名称设置成拼音+下划线,存入数据库 //字段名称设置成拼音+下划线,存入数据库
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(lawsTag.getDbFieldTxt()); String pinYin = HanYuPinYinUtil.changeToNumberPinYin(lawsTag.getDbFieldTxt());
@@ -256,7 +221,7 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
}else { }else {
type = "varchar("+dbLength+")"; type = "varchar("+dbLength+")";
} }
String tableName = FileTableIdEnum.getTableName(isModel); String tableName = TableNameEnum.getTableName(isModel);
String dbFieldTxt = lawsTag.getDbFieldTxt(); String dbFieldTxt = lawsTag.getDbFieldTxt();
String dbFieldNameOld = lawsTag.getDbFieldNameOld(); String dbFieldNameOld = lawsTag.getDbFieldNameOld();
String sql; String sql;