update 标签管理
This commit is contained in:
@@ -51,8 +51,14 @@ public class LawsTag implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String sysOrgCode;
|
||||
|
||||
/**文档库-表id*/
|
||||
private String cgformHeadId;
|
||||
/**表名*/
|
||||
private String tableName;
|
||||
|
||||
/**字段名字*/
|
||||
private String dbFieldName;
|
||||
|
||||
/**旧字段名字*/
|
||||
private String dbFieldNameOld;
|
||||
|
||||
/**所属模块(1文档库,0文档拆分)*/
|
||||
@Dict(dicCode = "module")
|
||||
@@ -132,9 +138,6 @@ public class LawsTag implements Serializable {
|
||||
/**逻辑删除标识 0未删 1已删*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**字段名字*/
|
||||
private String dbFieldName;
|
||||
|
||||
/**是否主键 0否 1是*/
|
||||
private Integer dbIsKey;
|
||||
|
||||
|
||||
+25
-8
@@ -10,8 +10,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.constant.enums.LanguageEnum;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.enums.FixedFieldEnum;
|
||||
@@ -137,14 +139,19 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
lawsTag.setUpdateBy(sysUser.getUsername());
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(lawsTag.getDbFieldTxt());
|
||||
lawsTag.setDbFieldName(pinYin.replace(" ","_"));
|
||||
|
||||
String dbFieldName = lawsTag.getDbFieldName();
|
||||
// 数据库的字段名称必须以字母开头,若不以字母开头加上固定的grp前缀
|
||||
if (!Validator.isMatchRegex("^[a-zA-Z].*$", lawsTag.getDbFieldName())){
|
||||
lawsTag.setDbFieldName("grp_" + lawsTag.getDbFieldName());
|
||||
if (!Validator.isMatchRegex("^[a-zA-Z].*$", dbFieldName)){
|
||||
lawsTag.setDbFieldName("grp_" + dbFieldName);
|
||||
}
|
||||
|
||||
if (dbFieldName.length() > 64){
|
||||
throw new JeroBootException("tag.add.字段名称太长",dbFieldName);
|
||||
}
|
||||
executeDDL(lawsTag,"add");
|
||||
lawsTag.setDbFieldNameOld(dbFieldName);
|
||||
}
|
||||
save(lawsTag);
|
||||
executeDDL(lawsTag,"add");
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +201,7 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
}
|
||||
|
||||
//字段名称设置成拼音+下划线,存入数据库
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(lawsTag.getDbFieldName());
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(lawsTag.getDbFieldTxt());
|
||||
lawsTag.setDbFieldName(pinYin.replace(" ","_"));
|
||||
//处理DBLength为null的情况,默认为100
|
||||
Integer dbLength = lawsTag.getDbLength();
|
||||
@@ -232,9 +239,12 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
if (!Validator.isMatchRegex("^[a-zA-Z].*$", dbFieldName)){
|
||||
lawsTag.setDbFieldName("grp_" + dbFieldName);
|
||||
}
|
||||
saveOrUpdate(lawsTag);
|
||||
if (dbFieldName.length() > 64){
|
||||
throw new JeroBootException("tag.add.字段名称太长",dbFieldName);
|
||||
}
|
||||
executeDDL(lawsTag,"modify");
|
||||
|
||||
lawsTag.setDbFieldNameOld(dbFieldName);
|
||||
saveOrUpdate(lawsTag);
|
||||
}
|
||||
|
||||
private void executeDDL(LawsTag lawsTag, String modifyOrAdd) {
|
||||
@@ -252,7 +262,14 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
}
|
||||
String tableName = FileTableIdEnum.getTableName(isModel);
|
||||
String dbFieldTxt = lawsTag.getDbFieldTxt();
|
||||
String sql = "alter table " + tableName + " " + modifyOrAdd + " " + dbFieldName + " " + type + " null comment '"+dbFieldTxt+"'";
|
||||
String dbFieldNameOld = lawsTag.getDbFieldNameOld();
|
||||
String sql;
|
||||
if (StringUtils.isNotBlank(dbFieldNameOld)){
|
||||
sql = "alter table " + tableName + " change " + dbFieldNameOld + " " + dbFieldName + " " + type + " null comment '"+dbFieldTxt+"'";
|
||||
}else {
|
||||
sql = "alter table " + tableName + " " + modifyOrAdd + " " + dbFieldName + " " + type + " null comment '"+dbFieldTxt+"'";
|
||||
}
|
||||
|
||||
lawsTagMapper.executeDDL(sql);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user