<?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.BomanAnnexMapper">
    
    <resultMap type="BomanAnnex" id="BomanAnnexResult">
        <result property="annexId"    column="annex_id"    />
        <result property="annexUrl"    column="annex_url"    />
        <result property="annexName"    column="annex_name"    />
        <result property="annexVoid"    column="annex_void"    />
        <result property="annexVoidName"    column="annex_void_name"    />
        <result property="annexImage"    column="annex_image"    />
        <result property="annexImageName"    column="annex_image_name"    />
        <result property="type"    column="type"    />
        <result property="keywords"    column="keywords"    />
        <result property="dimension"    column="dimension"    />
        <result property="releaseTime"    column="release_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectBomanAnnexVo">
        select annex_id, annex_url, annex_name,annex_void,annex_void_name,annex_image,annex_image_name, type,dimension, keywords, release_time, create_time, create_by, update_by, update_time from boman_annex
    </sql>

    <select id="selectBomanAnnexList" parameterType="BomanAnnex" resultMap="BomanAnnexResult">
        <include refid="selectBomanAnnexVo"/>
        <where>  
            <if test="annexUrl != null  and annexUrl != ''"> and annex_url = #{annexUrl}</if>
            <if test="annexName != null  and annexName != ''"> and annex_name like concat('%', #{annexName}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="keywords != null  and keywords != ''"> and keywords = #{keywords}</if>
            <if test="releaseTime != null "> and release_time = #{releaseTime}</if>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectBomanAnnexByAnnexId" parameterType="Long" resultMap="BomanAnnexResult">
        <include refid="selectBomanAnnexVo"/>
        where annex_id = #{annexId}
    </select>
        
    <insert id="insertBomanAnnex" parameterType="BomanAnnex" useGeneratedKeys="true" keyProperty="annexId">
        insert into boman_annex
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="annexUrl != null and annexUrl != ''">annex_url,</if>
            <if test="annexName != null and annexName != ''">annex_name,</if>
            <if test="annexVoid != null and annexVoid != ''">annex_void,</if>
            <if test="annexVoidName != null and annexVoidName != ''">annex_void_name,</if>
            <if test="annexImage != null and annexImage != ''">annex_image,</if>
            <if test="annexImageName != null and annexImageName != ''">annex_image_name,</if>
            <if test="type != null">type,</if>
            <if test="dimension != null ">dimension,</if>
            <if test="keywords != null and keywords != ''">keywords,</if>
            <if test="releaseTime != null">release_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="annexUrl != null and annexUrl != ''">#{annexUrl},</if>
            <if test="annexName != null ">#{annexName},</if>
            <if test="annexVoid != null ">#{annexVoid},</if>
            <if test="annexVoidName != null ">#{annexVoidName},</if>
            <if test="annexImage != null ">#{annexImage},</if>
            <if test="annexImageName != null ">#{annexImageName},</if>
            <if test="type != null">#{type},</if>
            <if test="dimension != null and dimension != ''">#{dimension},</if>
            <if test="keywords != null and keywords != ''">#{keywords},</if>
            <if test="releaseTime != null">#{releaseTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <insert id="batchBomanAnnex">
        insert into boman_annex(annex_url, annex_name,annex_void,annex_void_name,annex_image,annex_image_name,keywords,dimension,type,create_time) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.annexUrl},#{item.annexName},#{item.annexVoid},#{item.annexVoidName},#{item.annexImage},#{item.annexImageName},#{item.keywords},#{item.dimension},#{item.type},sysdate())
        </foreach>
    </insert>
    <update id="updateBomanAnnex" parameterType="BomanAnnex">
        update boman_annex
        <trim prefix="SET" suffixOverrides=",">
            <if test="annexUrl != null and annexUrl != ''">annex_url = #{annexUrl},</if>
            <if test="annexName != null and annexName != ''">annex_name = #{annexName},</if>
            <if test="annexVoid != null ">annex_void = #{annexVoid},</if>
            <if test="annexVoidName != null ">annex_void_name = #{annexVoidName},</if>
            <if test="annexImage != null ">annex_image = #{annexImage},</if>
            <if test="annexImageName != null ">annex_image_name = #{annexImageName},</if>
            <if test="type != null">type = #{type},</if>
            <if test="dimension != null ">dimension = #{dimension},</if>
            <if test="keywords != null and keywords != ''">keywords = #{keywords},</if>
            <if test="releaseTime != null">release_time = #{releaseTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where annex_id = #{annexId}
    </update>

    <delete id="deleteBomanAnnexByAnnexId" parameterType="Long">
        delete from boman_annex where annex_id = #{annexId}
    </delete>

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