<?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.BlackManageMapper">
    
    <resultMap type="BlackManage" id="BlackManageResult">
        <result property="blackManageId"    column="black_manage_id"    />
        <result property="blackType"    column="black_type"    />
        <result property="blackTitle"    column="black_title"    />
        <result property="blackNum"    column="black_num"    />
        <result property="isDel"    column="is_del"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBlackManageVo">
        select black_manage_id, black_type, black_title, black_num, is_del, create_by, create_time, update_by, update_time, remark from black_manage
    </sql>

    <select id="selectBlackManageList" parameterType="BlackManage" resultMap="BlackManageResult">
        <include refid="selectBlackManageVo"/>
        <where>  
            <if test="blackType != null  and blackType != ''"> and black_type = #{blackType}</if>
            <if test="blackTitle != null  and blackTitle != ''"> and black_title = #{blackTitle}</if>
            <if test="blackNum != null  and blackNum != ''"> and black_num = #{blackNum}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectBlackManageByBlackManageId" parameterType="Long" resultMap="BlackManageResult">
        <include refid="selectBlackManageVo"/>
        where black_manage_id = #{blackManageId}
    </select>

    <insert id="insertBlackManage" parameterType="BlackManage" useGeneratedKeys="true" keyProperty="blackManageId">
        insert into black_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="blackType != null and blackType != ''">black_type,</if>
            <if test="blackTitle != null and blackTitle != ''">black_title,</if>
            <if test="blackNum != null and blackNum != ''">black_num,</if>
            <if test="isDel != null and isDel != ''">is_del,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="blackType != null and blackType != ''">#{blackType},</if>
            <if test="blackTitle != null and blackTitle != ''">#{blackTitle},</if>
            <if test="blackNum != null and blackNum != ''">#{blackNum},</if>
            <if test="isDel != null and isDel != ''">#{isDel},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBlackManage" parameterType="BlackManage">
        update black_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="blackType != null and blackType != ''">black_type = #{blackType},</if>
            <if test="blackTitle != null and blackTitle != ''">black_title = #{blackTitle},</if>
            <if test="blackNum != null and blackNum != ''">black_num = #{blackNum},</if>
            <if test="isDel != null and isDel != ''">is_del = #{isDel},</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="remark != null">remark = #{remark},</if>
        </trim>
        where black_manage_id = #{blackManageId}
    </update>

    <delete id="deleteBlackManageByBlackManageId" parameterType="Long">
        delete from black_manage where black_manage_id = #{blackManageId}
    </delete>

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