<?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.powerdistribution.mapper.PdmExamineRoleTargetMapper">

    <resultMap type="PdmExamineRoleTarget" id="PdmExamineRoleTargetResult">
        <result property="id"    column="id"    />
        <result property="targetName"    column="target_name"    />
        <result property="minNum"    column="min_num"    />
        <result property="maxNum"    column="max_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"    />
    </resultMap>

    <sql id="selectPdmExamineRoleTargetVo">
        select id, target_name, min_num, max_num, create_by, create_time, update_by, update_time from pdm_examine_role_target
    </sql>

    <select id="selectPdmExamineRoleTargetList" parameterType="PdmExamineRoleTarget" resultMap="PdmExamineRoleTargetResult">
        <include refid="selectPdmExamineRoleTargetVo"/>
        <where>
            <if test="targetName != null  and targetName != ''"> and target_name like concat('%', #{targetName}, '%')</if>
            <if test="minNum != null "> and min_num = #{minNum}</if>
            <if test="maxNum != null "> and max_num = #{maxNum}</if>
        </where>
    </select>

    <select id="selectPdmExamineRoleTargetById" parameterType="Long" resultMap="PdmExamineRoleTargetResult">
        <include refid="selectPdmExamineRoleTargetVo"/>
        where id = #{id}
    </select>

    <insert id="insertPdmExamineRoleTarget" parameterType="PdmExamineRoleTarget" useGeneratedKeys="true" keyProperty="id">
        insert into pdm_examine_role_target
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="targetName != null">target_name,</if>
            <if test="minNum != null">min_num,</if>
            <if test="maxNum != null">max_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="targetName != null">#{targetName},</if>
            <if test="minNum != null">#{minNum},</if>
            <if test="maxNum != null">#{maxNum},</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="updatePdmExamineRoleTarget" parameterType="PdmExamineRoleTarget">
        update pdm_examine_role_target
        <trim prefix="SET" suffixOverrides=",">
            <if test="targetName != null">target_name = #{targetName},</if>
            <if test="minNum != null">min_num = #{minNum},</if>
            <if test="maxNum != null">max_num = #{maxNum},</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 id = #{id}
    </update>

    <delete id="deletePdmExamineRoleTargetById" parameterType="Long">
        delete from pdm_examine_role_target where id = #{id}
    </delete>

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