<?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.TestDeployMapper" >
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.TestDeploy" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="del_flag" property="delFlag" jdbcType="CHAR" />
        <result column="name" property="name" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List" >
        <trim  suffixOverrides="," >
        id,

        del_flag,

        name,

        </trim>
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
        select
        <include refid="Base_Column_List" />
        from test_deploy
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
        delete from test_deploy
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TestDeploy" useGeneratedKeys="true" keyProperty="id">
        insert into test_deploy
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="id!= null" >
                id,
            </if>
            <if test="delFlag!= null" >
                del_flag,
            </if>
            <if test="name!= null" >
                name,
            </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="name != null" >
                #{name,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TestDeploy" >
        update test_deploy
        <set >
            <if test="id != null" >
               id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null" >
               del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="name != null" >
               name= #{name,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryTestDeployByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestDeploy">
        select <include refid="Base_Column_List"/> from test_deploy
        <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.name != null and !&quot;&quot;.equals(record.name)">
                and  name = #{record.name}
            </if>
         <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
                 OR  name 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="queryAllTestDeploy" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestDeploy">
        select <include refid="Base_Column_List"/> from test_deploy
        <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="name != null and !&quot;&quot;.equals(name)">
                and  name = #{name}
            </if>
            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
                            OR  name 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="queryTestDeploy" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestDeploy">
        select <include refid="Base_Column_List"/> from test_deploy
        <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="name != null and !&quot;&quot;.equals(name)">
                and name = #{name}
            </if>

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

