<?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.ard.inspection.mapper.ArdInspectionGroupMapper">
|
|
<resultMap type="ArdInspectionGroup" id="ArdInspectionGroupResult">
|
<result property="groupId" column="group_id" />
|
<result property="groupParentId" column="group_parent_id" />
|
<result property="ancestors" column="ancestors" />
|
<result property="groupName" column="group_name" />
|
<result property="orderNum" column="order_num" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="parentName" column="parent_name" />
|
</resultMap>
|
|
<sql id="selectArdInspectionGroupVo">
|
select group_id,
|
group_parent_id,
|
ancestors,
|
group_name,
|
order_num,
|
create_by,
|
create_time,
|
update_by,
|
update_time
|
from ard_inspection_group
|
</sql>
|
|
<select id="selectArdInspectionGroupList" parameterType="ArdInspectionGroup" resultMap="ArdInspectionGroupResult">
|
<include refid="selectArdInspectionGroupVo"/>
|
<where>
|
<if test="groupId != null ">
|
and group_id = #{groupId}
|
</if>
|
<if test="groupParentId != null ">
|
and group_parent_id = #{groupParentId}
|
</if>
|
<if test="ancestors != null and ancestors != ''">
|
and ancestors = #{ancestors}
|
</if>
|
<if test="groupName != null and groupName != ''">
|
and group_name like concat('%', #{groupName}, '%')
|
</if>
|
<if test="orderNum != null ">
|
and order_num = #{orderNum}
|
</if>
|
</where>
|
order by group_parent_id, order_num
|
</select>
|
|
<select id="selectArdInspectionGroupByGroupId" parameterType="Long" resultMap="ArdInspectionGroupResult">
|
SELECT
|
g.group_id,
|
g.group_parent_id,
|
g.ancestors,
|
g.group_name,
|
g.order_num,
|
( SELECT group_name FROM ard_inspection_group WHERE group_id = g.group_parent_id) parent_name
|
FROM
|
ard_inspection_group g
|
WHERE
|
g.group_id = #{groupId}
|
</select>
|
|
<insert id="insertArdInspectionGroup" parameterType="ArdInspectionGroup">
|
insert into ard_inspection_group
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="groupId != null">group_id,</if>
|
<if test="groupParentId != null">group_parent_id,</if>
|
<if test="ancestors != null">ancestors,</if>
|
<if test="groupName != null">group_name,</if>
|
<if test="orderNum != null">order_num,</if>
|
<if test="createBy != null">create_by,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateBy != null">update_by,</if>
|
<if test="updateTime != null">update_time,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="groupId != null">#{groupId},</if>
|
<if test="groupParentId != null">#{groupParentId},</if>
|
<if test="ancestors != null">#{ancestors},</if>
|
<if test="groupName != null">#{groupName},</if>
|
<if test="orderNum != null">#{orderNum},</if>
|
<if test="createBy != null">#{createBy},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
</trim>
|
</insert>
|
|
<update id="updateArdInspectionGroup" parameterType="ArdInspectionGroup">
|
update ard_inspection_group
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="groupParentId != null">group_parent_id = #{groupParentId},</if>
|
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
<if test="groupName != null">group_name = #{groupName},</if>
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
</trim>
|
where group_id = #{groupId}
|
</update>
|
|
<delete id="deleteArdInspectionGroupByGroupId" parameterType="Long">
|
delete from ard_inspection_group where group_id = #{groupId}
|
</delete>
|
|
<delete id="deleteArdInspectionGroupByGroupIds" parameterType="String">
|
delete from ard_inspection_group where group_id in
|
<foreach item="groupId" collection="array" open="(" separator="," close=")">
|
#{groupId}
|
</foreach>
|
</delete>
|
|
<select id="checkInspectionGroupNameUnique" resultMap="ArdInspectionGroupResult">
|
<include refid="selectArdInspectionGroupVo"/>
|
where group_name=#{groupName}
|
and group_parent_id = #{groupParentId} limit 1
|
</select>
|
|
<select id="selectChildrenInspectionGroupById" parameterType="Long" resultMap="ArdInspectionGroupResult">
|
select * from ard_inspection_group where find_in_set(#{groupId}, ancestors)
|
</select>
|
|
<update id="updateInspectionGroupChildren" parameterType="java.util.List">
|
update ard_inspection_group set ancestors =
|
<foreach collection="inspectionGroups" item="item" index="index"
|
separator=" " open="case group_id" close="end">
|
when #{item.groupId} then #{item.ancestors}
|
</foreach>
|
where group_id in
|
<foreach collection="inspectionGroups" item="item" index="index"
|
separator="," open="(" close=")">
|
#{item.groupId}
|
</foreach>
|
</update>
|
|
<select id="hasChildByInspectionGroupId" parameterType="Long" resultType="int">
|
select count(1) from ard_inspection_group
|
where group_parent_id = #{groupId} limit 1
|
</select>
|
|
<select id="checkInspectionGroupExistUser" parameterType="Long" resultType="int">
|
select count(1) from sys_user where group_id = #{groupId} and del_flag = '0'
|
</select>
|
|
</mapper>
|