修改表字段回滚失败,调整语句先后顺序,金额类型默认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()">
<choose>
<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},
</when>
<otherwise>
add COLUMN ${item.enName} decimal(${item.filedLength}) DEFAULT NULL COMMENT
add COLUMN ${item.enName} decimal(${item.filedLength},8) DEFAULT NULL COMMENT
#{item.chName},
</otherwise>
</choose>
@ -505,14 +505,14 @@ where id = #{id}
<when test="filedType == '2'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add COLUMN ${enName} decimal(${filedLength}) DEFAULT NULL COMMENT
add COLUMN ${enName} decimal(${filedLength},8) DEFAULT NULL COMMENT
#{chName}
</when>
<when test="dataType == '3'.toString()">
drop COLUMN ${enName}
</when>
<otherwise>
MODIFY COLUMN ${enName} decimal(${filedLength}) DEFAULT NULL COMMENT
MODIFY COLUMN ${enName} decimal(${filedLength},8) DEFAULT NULL COMMENT
#{chName}
</otherwise>
</choose>
@ -566,13 +566,13 @@ where id = #{id}
<when test="filedType == '2'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add ${enName} decimal(${filedLength}) DEFAULT NULL
add ${enName} decimal(${filedLength},8) DEFAULT NULL
</when>
<when test="dataType == '3'.toString()">
drop ${enName}
</when>
<otherwise>
MODIFY ${enName} decimal(${filedLength}) DEFAULT NULL
MODIFY ${enName} decimal(${filedLength},8) DEFAULT NULL
</otherwise>
</choose>
</when>

View File

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