fix 77968 标签管理--标签项管理--企业标准--删除后新增一个同名的标签报错
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package com.jero.modules.tag.mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.tag.entity.LawsTag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -50,4 +51,12 @@ public interface LawsTagMapper extends BaseMapper<LawsTag> {
|
||||
@org.apache.ibatis.annotations.Param("condition") String condition);
|
||||
|
||||
void executeDDL(@Param("sqlStr") String var1);
|
||||
|
||||
|
||||
LawsTag selectDeleteData(@Param("isModel")String isModel, @Param("dbFieldEnName")String dbFieldEnName, @Param("dbFieldTxt")String dbFieldTxt);
|
||||
|
||||
int updateAllById(@Param("updated")LawsTag updated);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.tag.mapper.LawsTagMapper">
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
is_model,
|
||||
db_field_txt,
|
||||
db_field_en_name,
|
||||
field_show_type,
|
||||
db_length,
|
||||
order_num,
|
||||
field_must_input,
|
||||
is_show_form,
|
||||
is_show_list,
|
||||
is_read_only,
|
||||
show_area,
|
||||
is_query,
|
||||
is_show_laws_list,
|
||||
is_show_search,
|
||||
delFlag
|
||||
</sql>
|
||||
<resultMap id="OnlCgformTagResultMap" type="com.jero.modules.tag.entity.LawsTag">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_by" property="createBy" />
|
||||
@@ -24,7 +46,21 @@
|
||||
<result column="is_query" property="isQuery" />
|
||||
<result column="is_show_laws_list" property="isShowLawsList" />
|
||||
<result column="is_show_search" property="isShowSearch" />
|
||||
<result column="delFlag" property="delFlag" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="table_name" property="tableName"/>
|
||||
<result column="db_field_name" property="dbFieldName"/>
|
||||
<result column="db_field_name_old" property="dbFieldNameOld"/>
|
||||
<result column="dict_id" property="dictId"/>
|
||||
<result column="dict_field" property="dictField"/>
|
||||
<result column="dict_table" property="dictTable"/>
|
||||
<result column="dict_text" property="dictText"/>
|
||||
<result column="sort_flag" property="sortFlag"/>
|
||||
<result column="is_show_form_create" property="isShowFormCreate"/>
|
||||
<result column="db_is_key" property="dbIsKey"/>
|
||||
<result column="db_is_null" property="dbIsNull"/>
|
||||
<result column="db_point_length" property="dbPointLength"/>
|
||||
<result column="db_type" property="dbType"/>
|
||||
<result column="field_href" property="fieldHref"/>
|
||||
</resultMap>
|
||||
<select id="queryPageList" resultType="com.jero.modules.tag.entity.LawsTag">
|
||||
select f.id,f.create_by,f.create_time,f.update_by,f.update_time,f.cgform_head_id,
|
||||
@@ -88,4 +124,107 @@
|
||||
<update id="executeDDL" parameterType="java.lang.String">
|
||||
${sqlStr}
|
||||
</update>
|
||||
|
||||
<!--auto generated by MybatisCodeHelper on 2023-11-09-->
|
||||
<select id="selectDeleteData" resultType="com.jero.modules.tag.entity.LawsTag">
|
||||
select
|
||||
*
|
||||
from laws_tag
|
||||
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-->
|
||||
<update id="updateAllById">
|
||||
update laws_tag
|
||||
<set>
|
||||
<if test="updated.isModel != null and updated.isModel != ''">
|
||||
is_model = #{updated.isModel},
|
||||
</if>
|
||||
<if test="updated.dbFieldTxt != null and updated.dbFieldTxt != ''">
|
||||
db_field_txt = #{updated.dbFieldTxt},
|
||||
</if>
|
||||
<if test="updated.dbFieldEnName != null and updated.dbFieldEnName != ''">
|
||||
db_field_en_name = #{updated.dbFieldEnName},
|
||||
</if>
|
||||
<if test="updated.fieldShowType != null and updated.fieldShowType != ''">
|
||||
field_show_type = #{updated.fieldShowType},
|
||||
</if>
|
||||
<if test="updated.dbLength != null">
|
||||
db_length = #{updated.dbLength},
|
||||
</if>
|
||||
<if test="updated.orderNum != null">
|
||||
order_num = #{updated.orderNum},
|
||||
</if>
|
||||
<if test="updated.fieldMustInput != null and updated.fieldMustInput != ''">
|
||||
field_must_input = #{updated.fieldMustInput},
|
||||
</if>
|
||||
<if test="updated.isShowForm != null">
|
||||
is_show_form = #{updated.isShowForm},
|
||||
</if>
|
||||
<if test="updated.isShowList != null">
|
||||
is_show_list = #{updated.isShowList},
|
||||
</if>
|
||||
<if test="updated.isReadOnly != null">
|
||||
is_read_only = #{updated.isReadOnly},
|
||||
</if>
|
||||
<if test="updated.showArea != null and updated.showArea != ''">
|
||||
show_area = #{updated.showArea},
|
||||
</if>
|
||||
<if test="updated.isQuery != null">
|
||||
is_query = #{updated.isQuery},
|
||||
</if>
|
||||
<if test="updated.isShowLawsList != null">
|
||||
is_show_laws_list = #{updated.isShowLawsList},
|
||||
</if>
|
||||
<if test="updated.isShowSearch != null">
|
||||
is_show_search = #{updated.isShowSearch},
|
||||
</if>
|
||||
<if test="updated.delFlag != null">
|
||||
del_flag = #{updated.delFlag},
|
||||
</if>
|
||||
<if test="updated.tableName != null and updated.tableName != ''">
|
||||
table_name = #{updated.tableName},
|
||||
</if>
|
||||
<if test="updated.dbFieldName != null and updated.dbFieldName != ''">
|
||||
db_field_name = #{updated.dbFieldName},
|
||||
</if>
|
||||
<if test="updated.dbFieldNameOld != null and updated.dbFieldNameOld != ''">
|
||||
db_field_name_old = #{updated.dbFieldNameOld},
|
||||
</if>
|
||||
<if test="updated.dictId != null and updated.dictId != ''">
|
||||
dict_id = #{updated.dictId},
|
||||
</if>
|
||||
<if test="updated.dictField != null and updated.dictField != ''">
|
||||
dict_field = #{updated.dictField},
|
||||
</if>
|
||||
<if test="updated.dictTable != null and updated.dictTable != ''">
|
||||
dict_table = #{updated.dictTable},
|
||||
</if>
|
||||
<if test="updated.dictText != null and updated.dictText != ''">
|
||||
dict_text = #{updated.dictText},
|
||||
</if>
|
||||
<if test="updated.sortFlag != null">
|
||||
sort_flag = #{updated.sortFlag},
|
||||
</if>
|
||||
<if test="updated.isShowFormCreate != null">
|
||||
is_show_form_create = #{updated.isShowFormCreate},
|
||||
</if>
|
||||
<if test="updated.dbIsKey != null">
|
||||
db_is_key = #{updated.dbIsKey},
|
||||
</if>
|
||||
<if test="updated.dbIsNull != null">
|
||||
db_is_null = #{updated.dbIsNull},
|
||||
</if>
|
||||
<if test="updated.dbPointLength != null">
|
||||
db_point_length = #{updated.dbPointLength},
|
||||
</if>
|
||||
<if test="updated.dbType != null and updated.dbType != ''">
|
||||
db_type = #{updated.dbType},
|
||||
</if>
|
||||
<if test="updated.fieldHref != null and updated.fieldHref != ''">
|
||||
field_href = #{updated.fieldHref},
|
||||
</if>
|
||||
</set>
|
||||
where id=#{updated.id}
|
||||
</update>
|
||||
</mapper>
|
||||
+14
-9
@@ -61,17 +61,12 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
public void add(LawsTag lawsTag) {
|
||||
|
||||
//校验--逻辑删除
|
||||
LambdaQueryWrapper<LawsTag> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsTag::getIsModel, lawsTag.getIsModel())
|
||||
.eq(LawsTag::getDbFieldTxt, lawsTag.getDbFieldTxt())
|
||||
.eq(LawsTag::getDbFieldEnName, lawsTag.getDbFieldEnName())
|
||||
.eq(LawsTag::getDelFlag,1);
|
||||
LawsTag lawsTag1 = lawsTagMapper.selectOne(queryWrapper);
|
||||
LawsTag lawsTag1 = lawsTagMapper.selectDeleteData(lawsTag.getIsModel(),lawsTag.getDbFieldEnName(),lawsTag.getDbFieldTxt());
|
||||
if (lawsTag1 != null){
|
||||
lawsTag.setId(lawsTag1.getId());
|
||||
lawsTag.setDbFieldNameOld(lawsTag1.getDbFieldName());
|
||||
}
|
||||
else {
|
||||
|
||||
//处理DBLength为null的情况,默认为100
|
||||
if (lawsTag.getDbLength() == null){
|
||||
lawsTag.setDbLength(100);
|
||||
@@ -108,13 +103,23 @@ public class ILawsTagServiceImpl extends ServiceImpl<LawsTagMapper, LawsTag> imp
|
||||
if (dbFieldName.length() > 64){
|
||||
throw new JeroBootException("tag.add.字段名称太长",dbFieldName);
|
||||
}
|
||||
|
||||
if (lawsTag1 != null){
|
||||
executeDDL(lawsTag,"modify");
|
||||
}else {
|
||||
executeDDL(lawsTag,"add");
|
||||
}
|
||||
executeDDL(lawsTag,"add");
|
||||
|
||||
String isModel = lawsTag.getIsModel();
|
||||
String tableName = TableNameEnum.getTableName(isModel);
|
||||
lawsTag.setTableName(tableName);
|
||||
lawsTag.setDbFieldNameOld(lawsTag.getDbFieldName());
|
||||
saveOrUpdate(lawsTag);
|
||||
if (lawsTag1 != null){
|
||||
lawsTagMapper.updateAllById(lawsTag);
|
||||
}else {
|
||||
saveOrUpdate(lawsTag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user