<?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.izouma.awesomeadmin.dao.BannerInfoMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.BannerInfo">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="title" property="title" jdbcType="VARCHAR"/>
        <result column="subtitle" property="subtitle" jdbcType="VARCHAR"/>
        <result column="image" property="image" jdbcType="VARCHAR"/>
        <result column="news_url" property="newsUrl" jdbcType="VARCHAR"/>
        <result column="rank" property="rank" jdbcType="INTEGER"/>
        <result column="hot" property="hot" jdbcType="INTEGER"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        <trim suffixOverrides=",">
            id,

            del_flag,

            title,

            subtitle,

            image,

            news_url,

            rank,

            hot,

            remark,

        </trim>
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from banner_info
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from banner_info
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.BannerInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into banner_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="title!= null">
                title,
            </if>
            <if test="subtitle!= null">
                subtitle,
            </if>
            <if test="image!= null">
                image,
            </if>
            <if test="newsUrl!= null">
                news_url,
            </if>
            <if test="rank!= null">
                rank,
            </if>
            <if test="hot!= null">
                hot,
            </if>
            <if test="remark!= null">
                remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="subtitle != null">
                #{subtitle,jdbcType=VARCHAR},
            </if>
            <if test="image != null">
                #{image,jdbcType=VARCHAR},
            </if>
            <if test="newsUrl != null">
                #{newsUrl,jdbcType=VARCHAR},
            </if>
            <if test="rank != null">
                #{rank,jdbcType=INTEGER},
            </if>
            <if test="hot != null">
                #{hot,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.BannerInfo">
        update banner_info
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="title != null">
                title= #{title,jdbcType=VARCHAR},
            </if>
            <if test="subtitle != null">
                subtitle= #{subtitle,jdbcType=VARCHAR},
            </if>
            <if test="image != null">
                image= #{image,jdbcType=VARCHAR},
            </if>
            <if test="newsUrl != null">
                news_url= #{newsUrl,jdbcType=VARCHAR},
            </if>
            <if test="rank != null">
                rank= #{rank,jdbcType=INTEGER},
            </if>
            <if test="hot != null">
                hot= #{hot,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                remark= #{remark,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryBannerInfoByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.BannerInfo">
        select
        <include refid="Base_Column_List"/>
        from banner_info
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.title != null and !&quot;&quot;.equals(record.title)">
                and title = #{record.title}
            </if>
            <if test="record.subtitle != null and !&quot;&quot;.equals(record.subtitle)">
                and subtitle = #{record.subtitle}
            </if>
            <if test="record.image != null and !&quot;&quot;.equals(record.image)">
                and image = #{record.image}
            </if>
            <if test="record.newsUrl != null and !&quot;&quot;.equals(record.newsUrl)">
                and news_url = #{record.newsUrl}
            </if>
            <if test="record.rank != null and !&quot;&quot;.equals(record.rank)">
                and rank = #{record.rank}
            </if>
            <if test="record.hot != null and !&quot;&quot;.equals(record.hot)">
                and hot = #{record.hot}
            </if>
            <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
                and remark = #{record.remark}
            </if>
            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR title LIKE concat('%',#{record.searchKey},'%')
                    OR subtitle LIKE concat('%',#{record.searchKey},'%')
                    OR remark LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>

        </where>
        order by id desc
    </select>
    <select id="queryAllBannerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
        select
        <include refid="Base_Column_List"/>
        from banner_info
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="title != null and !&quot;&quot;.equals(title)">
                and title = #{title}
            </if>
            <if test="subtitle != null and !&quot;&quot;.equals(subtitle)">
                and subtitle = #{subtitle}
            </if>
            <if test="image != null and !&quot;&quot;.equals(image)">
                and image = #{image}
            </if>
            <if test="newsUrl != null and !&quot;&quot;.equals(newsUrl)">
                and news_url = #{newsUrl}
            </if>
            <if test="rank != null and !&quot;&quot;.equals(rank)">
                and rank = #{rank}
            </if>
            <if test="hot != null and !&quot;&quot;.equals(hot)">
                and hot = #{hot}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>
            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR title LIKE concat('%',#{searchKey},'%')
                    OR subtitle LIKE concat('%',#{searchKey},'%')
                    OR remark LIKE concat('%',#{searchKey},'%')
                </trim>
            </if>
            <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
                <foreach item="item" index="index" collection="advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>
        </where>
        order by id desc
    </select>
    <select id="queryBannerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
        select
        <include refid="Base_Column_List"/>
        from banner_info
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="title != null and !&quot;&quot;.equals(title)">
                and title = #{title}
            </if>
            <if test="subtitle != null and !&quot;&quot;.equals(subtitle)">
                and subtitle = #{subtitle}
            </if>
            <if test="image != null and !&quot;&quot;.equals(image)">
                and image = #{image}
            </if>
            <if test="newsUrl != null and !&quot;&quot;.equals(newsUrl)">
                and news_url = #{newsUrl}
            </if>
            <if test="rank != null and !&quot;&quot;.equals(rank)">
                and rank = #{rank}
            </if>
            <if test="hot != null and !&quot;&quot;.equals(hot)">
                and hot = #{hot}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE banner_info SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BannerInfo">
        select
        <include refid="Base_Column_List"/>
        from banner_info
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

