<?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.PdmExamineRoleDetailMapper">

    <resultMap type="PdmExamineRoleDetail" id="PdmExamineRoleDetailResult">
        <result property="id"    column="id"    />
        <result property="targetId"    column="target_id"    />
        <result property="detailName"    column="detail_name"    />
        <result property="minNum"    column="min_num"    />
        <result property="maxNum"    column="max_num"    />
        <result property="manageAmt"    column="manage_amt"    />
        <result property="manageAssistantAmt"    column="manage_assistant_amt"    />
        <result property="deptDirectorAmt"    column="dept_director_amt"    />
        <result property="deptDirectorAssistantAmt"    column="dept_director_assistant_amt"    />
        <result property="deptManageAmt"    column="dept_manage_amt"    />
        <result property="principAmt"    column="princip_amt"    />
        <result property="workPrincipAmt"    column="work_princip_amt"    />
        <result property="ownerAmt"    column="owner_amt"    />
        <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="selectPdmExamineRoleDetailVo">
        select id, target_id, detail_name, min_num, max_num, manage_amt, manage_assistant_amt, dept_director_amt, dept_director_assistant_amt, dept_manage_amt, princip_amt, work_princip_amt, owner_amt, create_by, create_time, update_by, update_time from pdm_examine_role_detail
    </sql>

    <select id="selectPdmExamineRoleDetailList" parameterType="PdmExamineRoleDetail" resultMap="PdmExamineRoleDetailResult">
        <include refid="selectPdmExamineRoleDetailVo"/>
        <where>
            <if test="targetId != null "> and target_id = #{targetId}</if>
            <if test="detailName != null  and detailName != ''"> and detail_name like concat('%', #{detailName}, '%')</if>
            <if test="minNum != null "> and min_num = #{minNum}</if>
            <if test="maxNum != null "> and max_num = #{maxNum}</if>
            <if test="manageAmt != null "> and manage_amt = #{manageAmt}</if>
            <if test="manageAssistantAmt != null "> and manage_assistant_amt = #{manageAssistantAmt}</if>
            <if test="deptDirectorAmt != null "> and dept_director_amt = #{deptDirectorAmt}</if>
            <if test="deptDirectorAssistantAmt != null "> and dept_director_assistant_amt = #{deptDirectorAssistantAmt}</if>
            <if test="deptManageAmt != null "> and dept_manage_amt = #{deptManageAmt}</if>
            <if test="principAmt != null "> and princip_amt = #{principAmt}</if>
            <if test="workPrincipAmt != null "> and work_princip_amt = #{workPrincipAmt}</if>
            <if test="ownerAmt != null "> and owner_amt = #{ownerAmt}</if>
        </where>
    </select>

    <select id="selectPdmExamineRoleDetailById" parameterType="Long" resultMap="PdmExamineRoleDetailResult">
        <include refid="selectPdmExamineRoleDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertPdmExamineRoleDetail" parameterType="PdmExamineRoleDetail" useGeneratedKeys="true" keyProperty="id">
        insert into pdm_examine_role_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="targetId != null">target_id,</if>
            <if test="detailName != null">detail_name,</if>
            <if test="minNum != null">min_num,</if>
            <if test="maxNum != null">max_num,</if>
            <if test="manageAmt != null">manage_amt,</if>
            <if test="manageAssistantAmt != null">manage_assistant_amt,</if>
            <if test="deptDirectorAmt != null">dept_director_amt,</if>
            <if test="deptDirectorAssistantAmt != null">dept_director_assistant_amt,</if>
            <if test="deptManageAmt != null">dept_manage_amt,</if>
            <if test="principAmt != null">princip_amt,</if>
            <if test="workPrincipAmt != null">work_princip_amt,</if>
            <if test="ownerAmt != null">owner_amt,</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="targetId != null">#{targetId},</if>
            <if test="detailName != null">#{detailName},</if>
            <if test="minNum != null">#{minNum},</if>
            <if test="maxNum != null">#{maxNum},</if>
            <if test="manageAmt != null">#{manageAmt},</if>
            <if test="manageAssistantAmt != null">#{manageAssistantAmt},</if>
            <if test="deptDirectorAmt != null">#{deptDirectorAmt},</if>
            <if test="deptDirectorAssistantAmt != null">#{deptDirectorAssistantAmt},</if>
            <if test="deptManageAmt != null">#{deptManageAmt},</if>
            <if test="principAmt != null">#{principAmt},</if>
            <if test="workPrincipAmt != null">#{workPrincipAmt},</if>
            <if test="ownerAmt != null">#{ownerAmt},</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="updatePdmExamineRoleDetail" parameterType="PdmExamineRoleDetail">
        update pdm_examine_role_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="targetId != null">target_id = #{targetId},</if>
            <if test="detailName != null">detail_name = #{detailName},</if>
            <if test="minNum != null">min_num = #{minNum},</if>
            <if test="maxNum != null">max_num = #{maxNum},</if>
            <if test="manageAmt != null">manage_amt = #{manageAmt},</if>
            <if test="manageAssistantAmt != null">manage_assistant_amt = #{manageAssistantAmt},</if>
            <if test="deptDirectorAmt != null">dept_director_amt = #{deptDirectorAmt},</if>
            <if test="deptDirectorAssistantAmt != null">dept_director_assistant_amt = #{deptDirectorAssistantAmt},</if>
            <if test="deptManageAmt != null">dept_manage_amt = #{deptManageAmt},</if>
            <if test="principAmt != null">princip_amt = #{principAmt},</if>
            <if test="workPrincipAmt != null">work_princip_amt = #{workPrincipAmt},</if>
            <if test="ownerAmt != null">owner_amt = #{ownerAmt},</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="deletePdmExamineRoleDetailById" parameterType="Long">
        delete from pdm_examine_role_detail where id = #{id}
    </delete>

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