<?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.system.mapper.ActSuppliesRoleDetailMapper">
    
    <resultMap type="ActSuppliesRoleDetail" id="ActSuppliesRoleDetailResult">
        <result property="id"    column="id"    />
        <result property="roleId"    column="role_id"    />
        <result property="detailName"    column="detail_name"    />
        <result property="detailMH"    column="detail_m_h"    />
        <result property="detailContent"    column="detail_content"    />
        <result property="detailML"    column="detail_m_l"    />
        <result property="status"    column="status"    />
        <result property="detailYH"    column="detail_y_h"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="datailYL"    column="datail_y_l"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectActSuppliesRoleDetailVo">
        select id, role_id, detail_name, detail_m_h, detail_content, detail_m_l, status, detail_y_h, create_by, create_time, datail_y_l, update_by, update_time from act_supplies_role_detail
    </sql>

    <select id="selectActSuppliesRoleDetailList" parameterType="ActSuppliesRoleDetail" resultMap="ActSuppliesRoleDetailResult">
        <include refid="selectActSuppliesRoleDetailVo"/>
        <where>  
            <if test="roleId != null "> and role_id = #{roleId}</if>
            <if test="detailName != null  and detailName != ''"> and detail_name like concat('%', #{detailName}, '%')</if>
            <if test="detailMH != null  and detailMH != ''"> and detail_m_h = #{detailMH}</if>
            <if test="detailContent != null  and detailContent != ''"> and detail_content = #{detailContent}</if>
            <if test="detailML != null  and detailML != ''"> and detail_m_l = #{detailML}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="detailYH != null  and detailYH != ''"> and detail_y_h = #{detailYH}</if>
            <if test="datailYL != null  and datailYL != ''"> and datail_y_l = #{datailYL}</if>
        </where>
    </select>
    
    <select id="selectActSuppliesRoleDetailById" parameterType="Integer" resultMap="ActSuppliesRoleDetailResult">
        <include refid="selectActSuppliesRoleDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertActSuppliesRoleDetail" parameterType="ActSuppliesRoleDetail" useGeneratedKeys="true" keyProperty="id">
        insert into act_supplies_role_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="roleId != null">role_id,</if>
            <if test="detailName != null">detail_name,</if>
            <if test="detailMH != null">detail_m_h,</if>
            <if test="detailContent != null">detail_content,</if>
            <if test="detailML != null">detail_m_l,</if>
            <if test="status != null">status,</if>
            <if test="detailYH != null">detail_y_h,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="datailYL != null">datail_y_l,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="roleId != null">#{roleId},</if>
            <if test="detailName != null">#{detailName},</if>
            <if test="detailMH != null">#{detailMH},</if>
            <if test="detailContent != null">#{detailContent},</if>
            <if test="detailML != null">#{detailML},</if>
            <if test="status != null">#{status},</if>
            <if test="detailYH != null">#{detailYH},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="datailYL != null">#{datailYL},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateActSuppliesRoleDetail" parameterType="ActSuppliesRoleDetail">
        update act_supplies_role_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="roleId != null">role_id = #{roleId},</if>
            <if test="detailName != null">detail_name = #{detailName},</if>
            <if test="detailMH != null">detail_m_h = #{detailMH},</if>
            <if test="detailContent != null">detail_content = #{detailContent},</if>
            <if test="detailML != null">detail_m_l = #{detailML},</if>
            <if test="status != null">status = #{status},</if>
            <if test="detailYH != null">detail_y_h = #{detailYH},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="datailYL != null">datail_y_l = #{datailYL},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteActSuppliesRoleDetailById" parameterType="Integer">
        delete from act_supplies_role_detail where id = #{id}
    </delete>

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