<?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.TestCaidanMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.TestCaidan">
        <result column="SequenceID" property="sequenceid" jdbcType="INTEGER"/>
        <result column="CaiDanXiangMing" property="caidanxiangming" jdbcType="VARCHAR"/>
        <result column="CaiDanCiXu" property="caidancixu" jdbcType="SMALLINT"/>
        <result column="URL" property="url" jdbcType="VARCHAR"/>
        <result column="CaiDanShuoMing" property="caidanshuoming" jdbcType="VARCHAR"/>
        <result column="ChuFaTiaoJian" property="chufatiaojian" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        SequenceID, ID, CaiDanXiangMing, CaiDanCiXu, URL, CaiDanShuoMing, ChuFaTiaoJian            </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from CaiDan_Table
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from CaiDan_Table
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TestCaidan"
            useGeneratedKeys="true" keyProperty="id">
        insert into CaiDan_Table
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sequenceid!= null">
                SequenceID,
            </if>
            <if test="caidanxiangming!= null">
                CaiDanXiangMing,
            </if>
            <if test="caidancixu!= null">
                CaiDanCiXu,
            </if>
            <if test="url!= null">
                URL,
            </if>
            <if test="caidanshuoming!= null">
                CaiDanShuoMing,
            </if>
            <if test="chufatiaojian!= null">
                ChuFaTiaoJian,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sequenceid != null">
                #{sequenceid,jdbcType=INTEGER},
            </if>
            <if test="caidanxiangming != null">
                #{caidanxiangming,jdbcType=VARCHAR},
            </if>
            <if test="caidancixu != null">
                #{caidancixu,jdbcType=SMALLINT},
            </if>
            <if test="url != null">
                #{url,jdbcType=VARCHAR},
            </if>
            <if test="caidanshuoming != null">
                #{caidanshuoming,jdbcType=VARCHAR},
            </if>
            <if test="chufatiaojian != null">
                #{chufatiaojian,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TestCaidan">
        update CaiDan_Table
        <set>
            <if test="sequenceid != null">
                SequenceID= #{sequenceid,jdbcType=INTEGER},
            </if>
            <if test="caidanxiangming != null">
                CaiDanXiangMing= #{caidanxiangming,jdbcType=VARCHAR},
            </if>
            <if test="caidancixu != null">
                CaiDanCiXu= #{caidancixu,jdbcType=SMALLINT},
            </if>
            <if test="url != null">
                URL= #{url,jdbcType=VARCHAR},
            </if>
            <if test="caidanshuoming != null">
                CaiDanShuoMing= #{caidanshuoming,jdbcType=VARCHAR},
            </if>
            <if test="chufatiaojian != null">
                ChuFaTiaoJian= #{chufatiaojian,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryTestCaidanByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TestCaidan">
        select
        <include refid="Base_Column_List"/>
        from CaiDan_Table
        <where>
            and 1 = 1
            <if test="record.sequenceid != null and !&quot;&quot;.equals(record.sequenceid)">
                and SequenceID = #{record.sequenceid}
            </if>
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and ID = #{record.id}
            </if>
            <if test="record.caidanxiangming != null and !&quot;&quot;.equals(record.caidanxiangming)">
                and CaiDanXiangMing = #{record.caidanxiangming}
            </if>
            <if test="record.caidancixu != null and !&quot;&quot;.equals(record.caidancixu)">
                and CaiDanCiXu = #{record.caidancixu}
            </if>
            <if test="record.url != null and !&quot;&quot;.equals(record.url)">
                and URL = #{record.url}
            </if>
            <if test="record.caidanshuoming != null and !&quot;&quot;.equals(record.caidanshuoming)">
                and CaiDanShuoMing = #{record.caidanshuoming}
            </if>
            <if test="record.chufatiaojian != null and !&quot;&quot;.equals(record.chufatiaojian)">
                and ChuFaTiaoJian = #{record.chufatiaojian}
            </if>

            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR CaiDanXiangMing LIKE concat('%',#{record.searchKey},'%')
                    OR URL LIKE concat('%',#{record.searchKey},'%')
                    OR CaiDanShuoMing LIKE concat('%',#{record.searchKey},'%')
                    OR ChuFaTiaoJian 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="queryAllTestCaidan" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TestCaidan">
        select
        <include refid="Base_Column_List"/>
        from CaiDan_Table
        <where>
            and 1 = 1
            <if test="sequenceid != null and !&quot;&quot;.equals(sequenceid)">
                and SequenceID = #{sequenceid}
            </if>
            <if test="id != null and !&quot;&quot;.equals(id)">
                and ID = #{id}
            </if>
            <if test="caidanxiangming != null and !&quot;&quot;.equals(caidanxiangming)">
                and CaiDanXiangMing = #{caidanxiangming}
            </if>
            <if test="caidancixu != null and !&quot;&quot;.equals(caidancixu)">
                and CaiDanCiXu = #{caidancixu}
            </if>
            <if test="url != null and !&quot;&quot;.equals(url)">
                and URL = #{url}
            </if>
            <if test="caidanshuoming != null and !&quot;&quot;.equals(caidanshuoming)">
                and CaiDanShuoMing = #{caidanshuoming}
            </if>
            <if test="chufatiaojian != null and !&quot;&quot;.equals(chufatiaojian)">
                and ChuFaTiaoJian = #{chufatiaojian}
            </if>

            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR CaiDanXiangMing LIKE concat('%',#{searchKey},'%')
                    OR URL LIKE concat('%',#{searchKey},'%')
                    OR CaiDanShuoMing LIKE concat('%',#{searchKey},'%')
                    OR ChuFaTiaoJian 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="queryTestCaidan" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.TestCaidan">
        select top 1
        <include refid="Base_Column_List"/>
        from CaiDan_Table
        <where>
            and 1 = 1
            <if test="sequenceid != null and !&quot;&quot;.equals(sequenceid)">
                and SequenceID = #{sequenceid}
            </if>
            <if test="id != null and !&quot;&quot;.equals(id)">
                and ID = #{id}
            </if>
            <if test="caidanxiangming != null and !&quot;&quot;.equals(caidanxiangming)">
                and CaiDanXiangMing = #{caidanxiangming}
            </if>
            <if test="caidancixu != null and !&quot;&quot;.equals(caidancixu)">
                and CaiDanCiXu = #{caidancixu}
            </if>
            <if test="url != null and !&quot;&quot;.equals(url)">
                and URL = #{url}
            </if>
            <if test="caidanshuoming != null and !&quot;&quot;.equals(caidanshuoming)">
                and CaiDanShuoMing = #{caidanshuoming}
            </if>
            <if test="chufatiaojian != null and !&quot;&quot;.equals(chufatiaojian)">
                and ChuFaTiaoJian = #{chufatiaojian}
            </if>

        </where>
    </select>
    <delete id="delete">
        delete
        from CaiDan_Table
        where id = #{id,jdbcType=INTEGER}
    </delete>

    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestCaidan">
        select
        <include refid="Base_Column_List"/>
        from CaiDan_Table
        <where>
            and 1 = 1
        </where>
        order by id desc
    </select>
</mapper>

