<?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.model.mapper.AppBannerMapper">
    
    <resultMap type="AppBanner" id="AppBannerResult">
        <result property="id"    column="id"    />
        <result property="image"    column="image"    />
        <result property="url"    column="url"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppBannerVo">
        select id, image, url, create_time, create_by, update_time, update_by, del_flag from app_banner
    </sql>

    <select id="selectAppBannerList" parameterType="AppBanner" resultMap="AppBannerResult">
        <include refid="selectAppBannerVo"/>
        <where>  
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
    </select>
    
    <select id="selectAppBannerById" parameterType="AppBanner" resultMap="AppBannerResult">
        <include refid="selectAppBannerVo"/>
        where id = #{id}
    </select>
    <select id="getBannerList" resultType="com.ruoyi.model.domain.AppBanner">
        <include refid="selectAppBannerVo"/>
    </select>

    <insert id="insertAppBanner" parameterType="AppBanner">
        insert into app_banner
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="image != null">image,</if>
            <if test="url != null">url,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="image != null">#{image},</if>
            <if test="url != null">#{url},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppBanner" parameterType="AppBanner">
        update app_banner
        <trim prefix="SET" suffixOverrides=",">
            <if test="image != null">image = #{image},</if>
            <if test="url != null">url = #{url},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppBannerById" parameterType="Long">
        delete from app_banner where id = #{id}
    </delete>

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