<?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.ruoyi.inspect.mapper.StaffCompetencyInspectItemConfigMapper">
|
|
<resultMap id="BaseResultMap" type="com.ruoyi.inspect.pojo.StaffCompetencyInspectItemConfig">
|
<id property="id" column="id" jdbcType="BIGINT"/>
|
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
|
<result property="ancestors" column="ancestors" jdbcType="VARCHAR"/>
|
<result property="itemName" column="item_name" jdbcType="VARCHAR"/>
|
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
<result property="isEnable" column="is_enable" jdbcType="BIT"/>
|
<result property="createUser" column="create_user" jdbcType="INTEGER"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="updateUser" column="update_user" jdbcType="INTEGER"/>
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id,parent_id,ancestors,item_name,
|
sort,is_enable,create_user,
|
create_time,update_user,update_time
|
</sql>
|
|
<sql id="selectConfigVo">
|
select id,parent_id,ancestors,item_name,
|
sort,is_enable,create_user,
|
create_time,update_user,update_time
|
from staff_competency_inspect_item_config
|
</sql>
|
|
<insert id="insertConfig">
|
insert into staff_competency_inspect_item_config(
|
<if test="config.parentId != null and config.parentId != 0">parent_id,</if>
|
<if test="config.ancestors != null and config.ancestors != ''">ancestors,</if>
|
<if test="config.itemName != null and config.itemName != ''">item_name,</if>
|
<if test="config.sort != null">sort,</if>
|
<if test="config.isEnable != null">is_enable</if>
|
)values(
|
<if test="config.parentId != null and config.parentId != 0">#{config.parentId},</if>
|
<if test="config.ancestors != null and config.ancestors != ''">#{config.ancestors},</if>
|
<if test="config.itemName != null and config.itemName != ''">#{config.itemName},</if>
|
<if test="config.sort != null">#{config.sort},</if>
|
<if test="config.isEnable != null">#{config.isEnable}</if>
|
)
|
</insert>
|
<update id="updateConfig">
|
update staff_competency_inspect_item_config
|
<set>
|
<if test="config.parentId != null and config.parentId != 0">parent_id = #{config.parentId},</if>
|
<if test="config.itemName != null and config.itemName != ''">item_name = #{config.itemName},</if>
|
<if test="config.ancestors != null and config.ancestors != ''">ancestors = #{config.ancestors},</if>
|
<if test="config.sort != null">sort = #{config.sort},</if>
|
<if test="config.isEnable != null">is_enable = #{config.isEnable}</if>
|
</set>
|
where id = #{config.id}
|
</update>
|
<update id="updateConfigStatusNormal">
|
update staff_competency_inspect_item_config set is_enable = 1 where id in
|
<foreach collection="configIds" item="configId" open="(" separator="," close=")">
|
#{configId}
|
</foreach>
|
</update>
|
<update id="updateConfigChildren">
|
update staff_competency_inspect_item_config set ancestors =
|
<foreach collection="children" item="item" index="index"
|
separator=" " open="case dept_id" close="end">
|
when #{item.id} then #{item.ancestors}
|
</foreach>
|
where id in
|
<foreach collection="children" item="item" index="index"
|
separator="," open="(" close=")">
|
#{item.id}
|
</foreach>
|
</update>
|
<select id="selectConfigList" resultType="com.ruoyi.inspect.pojo.StaffCompetencyInspectItemConfig">
|
<include refid="selectConfigVo"/>
|
where 1 = 1
|
<if test="config.id != null and config.id != 0">
|
AND id = #{config.id}
|
</if>
|
<if test="config.parentId != null and config.parentId != 0">
|
AND parent_id = #{config.parentId}
|
</if>
|
<if test="config.itemName != null and config.itemName != ''">
|
AND item_name like concat('%', #{config.itemName}, '%')
|
</if>
|
<if test="config.isEnable != null">
|
AND is_enable = #{config.isEnable}
|
</if>
|
order by sort
|
</select>
|
<select id="selectConfigById" resultType="com.ruoyi.inspect.vo.StaffCompetencyInspectItemConfigVO">
|
select <include refid="Base_Column_List"/>,
|
(select item_name from staff_competency_inspect_item_config where id = parent_id) parent_name
|
from staff_competency_inspect_item_config
|
where id = #{configId}
|
</select>
|
<select id="checkDeptNameUnique" resultType="com.ruoyi.inspect.pojo.StaffCompetencyInspectItemConfig">
|
<include refid="selectConfigVo"/>
|
where item_name=#{itemName}
|
<choose>
|
<when test="parentId!=null and parentId!=''">
|
and parent_id = #{parentId}
|
</when>
|
<when test="parentId==null or parentId==''">
|
and parent_id <= 0
|
</when>
|
</choose>
|
limit 1
|
</select>
|
<select id="selectChildrenConfigById" resultType="com.ruoyi.inspect.pojo.StaffCompetencyInspectItemConfig">
|
select * from staff_competency_inspect_item_config where find_in_set(#{configId}, ancestors)
|
</select>
|
<select id="hasChildByConfigId" resultType="java.lang.Integer">
|
select count(1) from staff_competency_inspect_item_config
|
where parent_id = #{configId} limit 1
|
</select>
|
<select id="selectNormalChildrenConfigById" resultType="java.lang.Integer">
|
select count(*) from staff_competency_inspect_item_config where is_enable = 1 and find_in_set(#{configId}, ancestors)
|
</select>
|
<select id="selectConfigHeader" resultType="com.ruoyi.inspect.vo.StaffConfigHeaderVO">
|
select
|
c2.item_name AS item_name,
|
c1.item_name AS children_item_name,
|
c1.id AS children_id
|
from staff_competency_inspect_item_config c1 left join staff_competency_inspect_item_config c2 on c1.parent_id=c2.id
|
where c1.is_enable=1
|
and c2.id is not null
|
order by c1.parent_id,c1.sort
|
</select>
|
</mapper>
|