<?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.LogisticsInfoMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.LogisticsInfo">
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        <trim suffixOverrides=",">
            code,

            name,

        </trim>
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from logistics_info
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from logistics_info
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.LogisticsInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into logistics_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code!= null">
                code,
            </if>
            <if test="name!= null">
                name,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">
                #{code,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.LogisticsInfo">
        update logistics_info
        <set>
            <if test="code != null">
                code= #{code,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                name= #{name,jdbcType=VARCHAR},
            </if>
        </set>
        where
        <if test="id != null and !&quot;&quot;.equals(id)">
            id = #{id,jdbcType=INTEGER}
        </if>

        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
            id in (${idStr})
        </if>

    </update>
    <select id="queryLogisticsInfoByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.LogisticsInfo">
        select
        <include refid="Base_Column_List"/>
        from logistics_info
        <where>
            <if test="record.code != null and !&quot;&quot;.equals(record.code)">
                and code = #{record.code}
            </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 code LIKE concat('%',#{record.searchKey},'%')
                    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

        <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">


            <trim suffixOverrides=",">
                <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                        ${itemDetail}
                    </foreach>
                </foreach>
            </trim>
            ,
        </if>
        code
    </select>
    <select id="queryAllLogisticsInfo" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.LogisticsInfo">
        select
        <include refid="Base_Column_List"/>
        from logistics_info
        <where>
            <if test="code != null and !&quot;&quot;.equals(code)">
                and code = #{code}
            </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 code LIKE concat('%',#{searchKey},'%')
                    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

        <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">


            <trim suffixOverrides=",">
                <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                        ${itemDetail}
                    </foreach>
                </foreach>
            </trim>
            ,
        </if>

        code
    </select>
    <select id="queryLogisticsInfo" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.LogisticsInfo">
        select
        <include refid="Base_Column_List"/>
        from logistics_info
        <where>
            and del_flag = 'N'
            <if test="code != null and !&quot;&quot;.equals(code)">
                and code = #{code}
            </if>
            <if test="name != null and !&quot;&quot;.equals(name)">
                and name = #{name}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE logistics_info SET del_flag = 'Y'
        where
        <if test="id != null and !&quot;&quot;.equals(id)">
            id = #{id,jdbcType=INTEGER}
        </if>

        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
            id in (${idStr})
        </if>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.LogisticsInfo">
        select
        <include refid="Base_Column_List"/>
        from logistics_info
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

