<?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.mall.mapper.MallImgShowMapper">
    
    <resultMap type="MallImgShow" id="MallImgShowResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="headUrl"    column="head_url"    />
        <result property="backgroundUrl"    column="background_url"    />
        <result property="status"    column="status"    />
        <result property="sort"    column="sort"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="imgType"    column="img_type"    />
    </resultMap>

    <sql id="selectMallImgShowVo">
        select id, name, head_url, background_url, status, sort, create_at, update_at, del_flag from mall_img_show
    </sql>

    <select id="selectMallImgShowList" parameterType="MallImgShow" resultMap="MallImgShowResult">
        <include refid="selectMallImgShowVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="headUrl != null  and headUrl != ''"> and head_url = #{headUrl}</if>
            <if test="backgroundUrl != null  and backgroundUrl != ''"> and background_url = #{backgroundUrl}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="createAt != null  and createAt != ''"> and create_at = #{createAt}</if>
            <if test="updateAt != null  and updateAt != ''"> and update_at = #{updateAt}</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
        </where>
    </select>
    
    <select id="selectMallImgShowById" parameterType="Long" resultMap="MallImgShowResult">
        <include refid="selectMallImgShowVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallImgShow" parameterType="MallImgShow" useGeneratedKeys="true" keyProperty="id">
        insert into mall_img_show
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="headUrl != null">head_url,</if>
            <if test="backgroundUrl != null">background_url,</if>
            <if test="status != null">status,</if>
            <if test="sort != null">sort,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="headUrl != null">#{headUrl},</if>
            <if test="backgroundUrl != null">#{backgroundUrl},</if>
            <if test="status != null">#{status},</if>
            <if test="sort != null">#{sort},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallImgShow" parameterType="MallImgShow">
        update mall_img_show
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="headUrl != null">head_url = #{headUrl},</if>
            <if test="backgroundUrl != null">background_url = #{backgroundUrl},</if>
            <if test="status != null">status = #{status},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallImgShowById" parameterType="Long">
        delete from mall_img_show where id = #{id}
    </delete>

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

    <select id="selectmallimgshowadpopups" resultType="com.ruoyi.mall.domain.MallImgShow">
        select id, name, head_url, background_url, status, sort, create_at, update_at, del_flag from mall_img_show
        where img_type= 'ggtc1'
    </select>

    <select id="selectMallpurchasingnotice" resultType="com.ruoyi.mall.domain.MallImgShow">
        select id, name, head_url, background_url, status, sort, create_at, update_at, del_flag from mall_img_show
        where img_type= 'gmxz1'
    </select>
</mapper>