<?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.abuwx.mapper.BannerInfoMapper">
    
    <resultMap type="BannerInfo" id="BannerInfoResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="infoId"    column="info_id"    />
        <result property="img"    column="img"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="sort"    column="sort"    />
    </resultMap>

    <sql id="selectBannerInfoVo">
        select id, title, info_id, img, status, create_time, update_time, remark, create_by, update_by, delete_flag, sort from banner_info
    </sql>

    <select id="selectBannerInfoList" parameterType="BannerInfo" resultMap="BannerInfoResult">
        <include refid="selectBannerInfoVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="infoId != null "> and info_id = #{infoId}</if>
            <if test="img != null  and img != ''"> and img = #{img}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="deleteFlag != null  and deleteFlag != ''"> and delete_flag = #{deleteFlag}</if>
            <if test="sort != null  and sort != ''"> and sort = #{sort}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
            <if test="params.beginupdateTime != null and params.beginupdateTime != ''"><!-- 开始时间检索 -->
                and date_format(update_time,'%y%m%d') &gt;= date_format(#{params.beginupdateTime},'%y%m%d')
            </if>
            <if test="params.endupdateTime != null and params.endupdateTime != ''"><!-- 结束时间检索 -->
                and date_format(update_time,'%y%m%d') &lt;= date_format(#{params.endupdateTime},'%y%m%d')
            </if>
        </where>
    </select>
    
    <select id="selectBannerInfoById" parameterType="Long" resultMap="BannerInfoResult">
        <include refid="selectBannerInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBannerInfo" parameterType="BannerInfo" useGeneratedKeys="true" keyProperty="id">
        insert into banner_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="infoId != null">info_id,</if>
            <if test="img != null">img,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="deleteFlag != null">delete_flag,</if>
            <if test="sort != null">sort,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="infoId != null">#{infoId},</if>
            <if test="img != null">#{img},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
            <if test="sort != null">#{sort},</if>
         </trim>
    </insert>

    <update id="updateBannerInfo" parameterType="BannerInfo">
        update banner_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="infoId != null">info_id = #{infoId},</if>
            <if test="img != null">img = #{img},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
            <if test="sort != null">sort = #{sort},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBannerInfoById" parameterType="Long">
        delete from banner_info where id = #{id}
    </delete>

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