fix:88095
This commit is contained in:
@@ -30,6 +30,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLSyntaxErrorException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -134,6 +136,7 @@ public class LawsTagController extends JeroController<LawsTag, ILawsTagService>
|
||||
}
|
||||
return Result.OK(ResultCommon.OK);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,14 @@ public interface LawsTagMapper extends BaseMapper<LawsTag> {
|
||||
|
||||
int updateAllById(@Param("updated")LawsTag updated);
|
||||
|
||||
/**
|
||||
* 查看字段是否已存在
|
||||
* @param tableName 表名
|
||||
* @param dbFieldName 字段名
|
||||
* @return
|
||||
*/
|
||||
long selectColumns(@Param("tableName") String tableName,@Param("dbFieldName") String dbFieldName);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
where is_model=#{isModel} and db_field_en_name=#{dbFieldEnName} and db_field_txt=#{dbFieldTxt} and del_flag = 1
|
||||
</select>
|
||||
|
||||
<!--auto generated by MybatisCodeHelper on 2023-11-09-->
|
||||
<!--auto generated by MybatisCodeHelper on 2023-11-09-->
|
||||
<update id="updateAllById">
|
||||
update laws_tag
|
||||
<set>
|
||||
@@ -169,4 +169,10 @@
|
||||
</set>
|
||||
where id = #{updated.id}
|
||||
</update>
|
||||
</mapper>
|
||||
<select id="selectColumns" resultType="java.lang.Long">
|
||||
SELECT count(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = #{tableName}
|
||||
AND COLUMN_NAME = #{dbFieldName}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+18
-2
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.SQLSyntaxErrorException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -106,7 +108,6 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
if (dbFieldName.length() > 64){
|
||||
throw new JeroBootException(ResultCommon.TAG_ADD_ERROR_1,dbFieldName);
|
||||
}
|
||||
|
||||
if (lawsTag1 != null){
|
||||
executeDDL(lawsTag,"modify");
|
||||
}else {
|
||||
@@ -211,10 +212,25 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
if (StringUtils.isNotBlank(dbFieldNameOld)){
|
||||
sql = "alter table " + tableName + " change `" + dbFieldNameOld + "` `" + dbFieldName + "` " + type + " null comment '"+dbFieldTxt+"'";
|
||||
}else {
|
||||
// 验证字段是否存在
|
||||
long l = lawsTagMapper.selectColumns(tableName,dbFieldName);
|
||||
if(l > 0){
|
||||
throw new JeroBootException(ResultCommon.TAG_EDIT_ERROR_2);
|
||||
}
|
||||
sql = "alter table " + tableName + " " + modifyOrAdd + " `" + dbFieldName + "` " + type + " null comment '"+dbFieldTxt+"'";
|
||||
}
|
||||
|
||||
lawsTagMapper.executeDDL(sql);
|
||||
try{
|
||||
lawsTagMapper.executeDDL(sql);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
// 捕获所有的SQLException
|
||||
if (e.getMessage().contains("java.sql.SQLSyntaxErrorException: Row size too large.")) {
|
||||
// 判断是否为SQLSyntaxErrorException
|
||||
throw new JeroBootException(ResultCommon.ROW_SIZE_TOO_LARGE);
|
||||
}
|
||||
throw new JeroBootException(ResultCommon.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user