解决业务字典模块mapper层小bug。

This commit is contained in:
little-cat-sweet 2021-07-30 17:17:58 +08:00
parent bb2def0f4a
commit dee2ecf79f
3 changed files with 17 additions and 23 deletions

View File

@ -234,16 +234,15 @@ public class XhpcDictBizServiceImpl implements IXhpcDictBizService{
String value=xhpcDictionary.getDictValue(); String value=xhpcDictionary.getDictValue();
String codeValue=xhpcDictionary.getCode(); String codeValue=xhpcDictionary.getCode();
// Judging the father item whether could insert. // Judging the father item whether could insert.
if(!value.equals(dictValue)){ if(value!=null&&!value.equals(dictValue)){
//Ensuring the name(dict_value) has existed. //Ensuring the name(dict_value) has existed.
int size=xhpcDictBizMapper.countParentNameQuantity(dictValue); int size=xhpcDictBizMapper.countParentNameQuantity(dictValue);
if(size>0){ if(size>0){
return AjaxResult.error("您输入的字典名称已经存在。"); return AjaxResult.error("您输入的字典名称已经存在。");
} }
} }
if(!codeValue.equals(code)){ if(codeValue!=null&&!codeValue.equals(code)){
//Ensuring the code whether has existed. //Ensuring the code whether has existed.
int quantity=xhpcDictBizQuantityCheckMapper.countCodeRows(code); int quantity=xhpcDictBizQuantityCheckMapper.countCodeRows(code);
if(quantity>0){ if(quantity>0){
@ -324,12 +323,12 @@ public class XhpcDictBizServiceImpl implements IXhpcDictBizService{
for(String value:idsArray){ for(String value:idsArray){
idsList.add(Long.parseLong(value)); idsList.add(Long.parseLong(value));
} }
int size=xhpcDictBizMapper.deleteChildItemByIds(idsList); int size=xhpcDictBizMapper.deleteChildItemByIds(idsList);
if(size==0){ if(size==0){
return AjaxResult.error("删除失败"); return AjaxResult.error("删除失败");
}else {
return AjaxResult.success();
} }
return AjaxResult.success();
} }
@Override @Override
@ -348,10 +347,12 @@ public class XhpcDictBizServiceImpl implements IXhpcDictBizService{
} }
//Deleting the parent's child. //Deleting the parent's child.
int sizeChild=xhpcDictBizMapper.deleteChildItemsAfterTheirParentDied(idsList); try {
if(sizeChild==0){ xhpcDictBizMapper.deleteChildItemsAfterTheirParentDied(idsList);
} catch (Exception e) {
return AjaxResult.error("删除失败"); return AjaxResult.error("删除失败");
} }
return AjaxResult.success(); return AjaxResult.success();
} }
} }

View File

@ -25,11 +25,11 @@
</select> </select>
<select id="countParentNameColumns" resultType="java.lang.Integer"> <select id="countParentNameColumns" resultType="java.lang.Integer">
select count(dict_value) from xhpc_dict_biz where dict_value=#{name} and dict_biz_id=#{id}; select count(dict_value) from xhpc_dict_biz where dict_value=#{name} and dict_biz_id=#{id} and del_flag=0
</select> </select>
<select id="countSameParentChildNameColumns" resultType="java.lang.Integer"> <select id="countSameParentChildNameColumns" resultType="java.lang.Integer">
select count(dict_value) from xhpc_dict_biz where parent_id=#{id} and dict_value=#{name} select count(dict_value) from xhpc_dict_biz where parent_id=#{id} and dict_value=#{name} and del_flag=0
</select> </select>
<insert id="insertAParentItemToTable"> <insert id="insertAParentItemToTable">
@ -88,17 +88,17 @@
update xhpc_dict_biz set dict_key=#{key},dict_value=#{value},sort=#{sort} where dict_biz_id=#{id} update xhpc_dict_biz set dict_key=#{key},dict_value=#{value},sort=#{sort} where dict_biz_id=#{id}
</update> </update>
<delete id="deleteChildItemByIds"> <update id="deleteChildItemByIds">
update xhpc_dict_biz set del_flag=1 update xhpc_dict_biz set del_flag=1
where where
dict_biz_id in dict_biz_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</delete> </update>
<select id="countParentNameQuantity" resultType="java.lang.Integer"> <select id="countParentNameQuantity" resultType="java.lang.Integer">
select count(dict_biz_id) from xhpc_dict_biz where dict_value=#{name} select count(dict_biz_id) from xhpc_dict_biz where dict_value=#{name} and del_flag=0
</select> </select>
<update id="updateChildCodeAfterParentChanged"> <update id="updateChildCodeAfterParentChanged">
@ -113,9 +113,4 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
</mapper> </mapper>

View File

@ -3,20 +3,18 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.general.mapper.XhpcDictBizQuantityCheckMapper"> <mapper namespace="com.xhpc.general.mapper.XhpcDictBizQuantityCheckMapper">
<select id="countCodeRows" resultType="java.lang.Integer"> <select id="countCodeRows" resultType="java.lang.Integer">
select count(code) from xhpc_dict_biz where code=#{code} select count(code) from xhpc_dict_biz where code=#{code} and del_flag=0
</select> </select>
<select id="countSameParentChildValueColumns" resultType="java.lang.Integer"> <select id="countSameParentChildValueColumns" resultType="java.lang.Integer">
select count(dict_biz_id) from xhpc_dict_biz where parent_id=#{id} and dict_value=#{key} select count(dict_biz_id) from xhpc_dict_biz where parent_id=#{id} and dict_value=#{key} and del_flag=0
</select> </select>
<select id="countSameParentChildKeyColumns" resultType="java.lang.Integer"> <select id="countSameParentChildKeyColumns" resultType="java.lang.Integer">
select count(dict_biz_id) from xhpc_dict_biz where parent_id=#{id} and dict_key=#{key} select count(dict_biz_id) from xhpc_dict_biz where parent_id=#{id} and dict_key=#{key} and del_flag=0
</select> </select>
<select id="countParentName" resultType="java.lang.Integer"> <select id="countParentName" resultType="java.lang.Integer">
select count(dict_biz_id) from xhpc_dict_biz where parent_id=0 and dict_value=#{name} select count(dict_biz_id) from xhpc_dict_biz where parent_id=0 and dict_value=#{name} and del_flag=0
</select> </select>
</mapper> </mapper>