<?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.szxc.mapper.SzxcPersonTagMapper">

    <resultMap type="SzxcPersonTag" id="SzxcPersonTagResult">
        <result property="id"    column="id"    />
        <result property="tagName"    column="tag_name"    />
        <result property="checkEnable"    column="check_enable"    />
        <result property="deptId"    column="dept_id"    />
        <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="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcPersonTagVo">
        select id, tag_name,check_enable, dept_id, create_by, create_time, update_by, update_time, user_id from szxc_person_tag
    </sql>

    <select id="selectSzxcPersonTagList" parameterType="SzxcPersonTag" resultMap="SzxcPersonTagResult">
        <include refid="selectSzxcPersonTagVo"/>  d
        <where>
            <if test="tagName != null  and tagName != ''"> and tag_name like concat('%', #{tagName}, '%')</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="checkEnable != null  and checkEnable != ''"> and check_enable = #{checkEnable}</if>
            <if test="deptId != null and deptId != 0">and dept_id = #{deptId}</if>
       <!-- <if test="deptId != null and deptId != 0">
                AND (d.dept_id = #{deptId} OR d.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
            </if>-->

            <!-- 数据范围过滤 -->
            <!--<if test="params.dataScope != null and params.dataScope !=''">
                ${params.dataScope}
            </if>-->
        </where>
    </select>

    <select id="selectSzxcPersonTagById" parameterType="Long" resultMap="SzxcPersonTagResult">
        <include refid="selectSzxcPersonTagVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcPersonTag" parameterType="SzxcPersonTag" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_person_tag
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tagName != null and tagName != ''">tag_name,</if>
            <if test="checkEnable != null">check_enable,</if>
            <if test="deptId != null">dept_id,</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>
            <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tagName != null and tagName != ''">#{tagName},</if>
            <if test="checkEnable != null">#{checkEnable},</if>
            <if test="deptId != null">#{deptId},</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>
            <if test="userId != null">#{userId},</if>
        </trim>
    </insert>

    <update id="updateSzxcPersonTag" parameterType="SzxcPersonTag">
        update szxc_person_tag
        <trim prefix="SET" suffixOverrides=",">
            <if test="tagName != null and tagName != ''">tag_name = #{tagName},</if>
            <if test="checkEnable != null">check_enable = #{checkEnable},</if>
            <if test="deptId != null">dept_id = #{deptId},</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>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcPersonTagById" parameterType="Long">
        delete from szxc_person_tag where id = #{id}
    </delete>

    <delete id="deleteSzxcPersonTagByIds" parameterType="String">
        delete from szxc_person_tag where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>