修改表字段回滚失败,调整语句先后顺序,金额类型默认8位小数

This commit is contained in:
lvleigang 2024-07-11 11:48:39 +08:00
parent c96e1f2f70
commit 0d8c43fb46
2 changed files with 16 additions and 11 deletions

View File

@ -442,11 +442,11 @@ where id = #{id}
<when test="item.filedType == '2'.toString()"> <when test="item.filedType == '2'.toString()">
<choose> <choose>
<when test="item.dataType == '1'.toString()"> <when test="item.dataType == '1'.toString()">
MODIFY COLUMN ${item.enName} decimal(${item.filedLength}) DEFAULT NULL COMMENT MODIFY COLUMN ${item.enName} decimal(${item.filedLength},8) DEFAULT NULL COMMENT
#{item.chName}, #{item.chName},
</when> </when>
<otherwise> <otherwise>
add COLUMN ${item.enName} decimal(${item.filedLength}) DEFAULT NULL COMMENT add COLUMN ${item.enName} decimal(${item.filedLength},8) DEFAULT NULL COMMENT
#{item.chName}, #{item.chName},
</otherwise> </otherwise>
</choose> </choose>
@ -505,14 +505,14 @@ where id = #{id}
<when test="filedType == '2'.toString()"> <when test="filedType == '2'.toString()">
<choose> <choose>
<when test="dataType == '1'.toString()"> <when test="dataType == '1'.toString()">
add COLUMN ${enName} decimal(${filedLength}) DEFAULT NULL COMMENT add COLUMN ${enName} decimal(${filedLength},8) DEFAULT NULL COMMENT
#{chName} #{chName}
</when> </when>
<when test="dataType == '3'.toString()"> <when test="dataType == '3'.toString()">
drop COLUMN ${enName} drop COLUMN ${enName}
</when> </when>
<otherwise> <otherwise>
MODIFY COLUMN ${enName} decimal(${filedLength}) DEFAULT NULL COMMENT MODIFY COLUMN ${enName} decimal(${filedLength},8) DEFAULT NULL COMMENT
#{chName} #{chName}
</otherwise> </otherwise>
</choose> </choose>
@ -566,13 +566,13 @@ where id = #{id}
<when test="filedType == '2'.toString()"> <when test="filedType == '2'.toString()">
<choose> <choose>
<when test="dataType == '1'.toString()"> <when test="dataType == '1'.toString()">
add ${enName} decimal(${filedLength}) DEFAULT NULL add ${enName} decimal(${filedLength},8) DEFAULT NULL
</when> </when>
<when test="dataType == '3'.toString()"> <when test="dataType == '3'.toString()">
drop ${enName} drop ${enName}
</when> </when>
<otherwise> <otherwise>
MODIFY ${enName} decimal(${filedLength}) DEFAULT NULL MODIFY ${enName} decimal(${filedLength},8) DEFAULT NULL
</otherwise> </otherwise>
</choose> </choose>
</when> </when>

View File

@ -1482,6 +1482,11 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
} }
entity.setUpdate(); entity.setUpdate();
entity.setDataType("2"); entity.setDataType("2");
try {
mdmModuleDao.alterTableField(entity);
} catch (Exception e){
throw new BaseSystemException("表字段类型,修改失败,请联系管理员");
}
List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = new ArrayList<>(); List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = new ArrayList<>();
mdmModuleDbFiledsEntities.add(entity); mdmModuleDbFiledsEntities.add(entity);
mdmServiceCache.saveOrUpdateMdmModuleDbFileds(entity.getMdmId(), mdmModuleDbFiledsEntities); mdmServiceCache.saveOrUpdateMdmModuleDbFileds(entity.getMdmId(), mdmModuleDbFiledsEntities);
@ -1505,11 +1510,11 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
} }
} }
} }
try { //try {
mdmModuleDao.alterTableField(entity); // mdmModuleDao.alterTableField(entity);
} catch (Exception e){ //} catch (Exception e){
throw new BaseSystemException("表字段类型,修改失败,请联系管理员"); // throw new BaseSystemException("表字段类型,修改失败,请联系管理员");
} //}
return BaseResult.getSuccessMessageEntity("修改字段成功"); return BaseResult.getSuccessMessageEntity("修改字段成功");
} }