<?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.xingxi.business.ExpressInfo.mapper.ExpressInfoMapper">
    <resultMap type="ExpressInfo" id="ExpressInfoResult">
        <result property="expressInfoId"    column="expressInfoId"    />
        <result property="expressNo"    column="expressNo"    />
        <result property="exprTime"    column="exprTime"    />
        <result property="exprContext"    column="exprContext"    />
        <result property="returnCode"    column="returnCode"    />
        <result property="returnState"    column="returnState"    />
        <result property="returnMsg"    column="returnMsg"    />
        <result property="exprCode"    column="exprCode"    />
        <result property="exprName"    column="exprName"    />
        <result property="exprSite"    column="exprSite"    />
        <result property="exprPhone"    column="exprPhone"    />
        <result property="exprLogo"    column="exprLogo"    />
        <result property="exprCourier"    column="exprCourier"    />
        <result property="courierPhone"    column="courierPhone"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectExpressInfo">
        select expressInfoId, expressNo, exprTime, exprContext, returnCode, returnState, returnMsg, exprCode, exprName, exprSite, exprPhone, exprLogo, exprCourier, courierPhone, delFlag, createUser, createTime, updateUser, updateTime from t_express_info
    </sql>

    <sql id="selectExpressInfoExt">
        select
            ${tableAlias}.expressInfoId,
            ${tableAlias}.expressNo,
            ${tableAlias}.exprTime,
            ${tableAlias}.exprContext,
            ${tableAlias}.returnCode,
            ${tableAlias}.returnState,
            ${tableAlias}.returnMsg,
            ${tableAlias}.exprCode,
            ${tableAlias}.exprName,
            ${tableAlias}.exprSite,
            ${tableAlias}.exprPhone,
            ${tableAlias}.exprLogo,
            ${tableAlias}.exprCourier,
            ${tableAlias}.courierPhone,
            ${tableAlias}.delFlag,
            ${tableAlias}.createUser,
            ${tableAlias}.createTime,
            ${tableAlias}.updateUser,
            ${tableAlias}.updateTime
        from t_express_info ${tableAlias}
    </sql>

    <select id="selectExpressInfoList" parameterType="ExpressInfo" resultMap="ExpressInfoResult">
        <include refid="selectExpressInfo"/>
        <where>  
            <if test="expressNo != null  and expressNo != ''"> and expressNo = #{expressNo}</if>
            <if test="exprTime != null "> and exprTime = #{exprTime}</if>
            <if test="exprContext != null  and exprContext != ''"> and exprContext = #{exprContext}</if>
            <if test="returnCode != null  and returnCode != ''"> and returnCode = #{returnCode}</if>
            <if test="returnState != null  and returnState != ''"> and returnState = #{returnState}</if>
            <if test="returnMsg != null  and returnMsg != ''"> and returnMsg = #{returnMsg}</if>
            <if test="exprCode != null  and exprCode != ''"> and exprCode = #{exprCode}</if>
            <if test="exprName != null  and exprName != ''"> and exprName like concat('%', #{exprName}, '%')</if>
            <if test="exprSite != null  and exprSite != ''"> and exprSite = #{exprSite}</if>
            <if test="exprPhone != null  and exprPhone != ''"> and exprPhone = #{exprPhone}</if>
            <if test="exprLogo != null  and exprLogo != ''"> and exprLogo = #{exprLogo}</if>
            <if test="exprCourier != null  and exprCourier != ''"> and exprCourier = #{exprCourier}</if>
            <if test="courierPhone != null  and courierPhone != ''"> and courierPhone = #{courierPhone}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectExpressInfoByExpressInfoId" parameterType="Long" resultMap="ExpressInfoResult">
        <include refid="selectExpressInfo"/>
        where expressInfoId = #{expressInfoId}
    </select>
        
    <insert id="insertExpressInfo" parameterType="ExpressInfo" useGeneratedKeys="true" keyProperty="expressInfoId">
        insert into t_express_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="expressNo != null">expressNo,</if>
            <if test="exprTime != null">exprTime,</if>
            <if test="exprContext != null">exprContext,</if>
            <if test="returnCode != null">returnCode,</if>
            <if test="returnState != null">returnState,</if>
            <if test="returnMsg != null">returnMsg,</if>
            <if test="exprCode != null">exprCode,</if>
            <if test="exprName != null">exprName,</if>
            <if test="exprSite != null">exprSite,</if>
            <if test="exprPhone != null">exprPhone,</if>
            <if test="exprLogo != null">exprLogo,</if>
            <if test="exprCourier != null">exprCourier,</if>
            <if test="courierPhone != null">courierPhone,</if>
            <if test="delFlag != null">delFlag,</if>
            <if test="createUser != null">createUser,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateUser != null">updateUser,</if>
            <if test="updateTime != null">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="expressNo != null">#{expressNo},</if>
            <if test="exprTime != null">#{exprTime},</if>
            <if test="exprContext != null">#{exprContext},</if>
            <if test="returnCode != null">#{returnCode},</if>
            <if test="returnState != null">#{returnState},</if>
            <if test="returnMsg != null">#{returnMsg},</if>
            <if test="exprCode != null">#{exprCode},</if>
            <if test="exprName != null">#{exprName},</if>
            <if test="exprSite != null">#{exprSite},</if>
            <if test="exprPhone != null">#{exprPhone},</if>
            <if test="exprLogo != null">#{exprLogo},</if>
            <if test="exprCourier != null">#{exprCourier},</if>
            <if test="courierPhone != null">#{courierPhone},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <insert id="batchInsertExpressInfo">
        insert into t_express_info( expressNo, exprTime, exprContext, returnCode, returnState, returnMsg, exprCode, exprName, exprSite, exprPhone, exprLogo, exprCourier, courierPhone, delFlag, createUser, createTime, updateUser, updateTime) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.expressNo}, #{item.exprTime}, #{item.exprContext}, #{item.returnCode}, #{item.returnState}, #{item.returnMsg}, #{item.exprCode}, #{item.exprName}, #{item.exprSite}, #{item.exprPhone}, #{item.exprLogo}, #{item.exprCourier}, #{item.courierPhone}, #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime})
        </foreach>
    </insert>

    <update id="updateExpressInfo" parameterType="ExpressInfo">
        update t_express_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="expressNo != null">expressNo = #{expressNo},</if>
            <if test="exprTime != null">exprTime = #{exprTime},</if>
            <if test="exprContext != null">exprContext = #{exprContext},</if>
            <if test="returnCode != null">returnCode = #{returnCode},</if>
            <if test="returnState != null">returnState = #{returnState},</if>
            <if test="returnMsg != null">returnMsg = #{returnMsg},</if>
            <if test="exprCode != null">exprCode = #{exprCode},</if>
            <if test="exprName != null">exprName = #{exprName},</if>
            <if test="exprSite != null">exprSite = #{exprSite},</if>
            <if test="exprPhone != null">exprPhone = #{exprPhone},</if>
            <if test="exprLogo != null">exprLogo = #{exprLogo},</if>
            <if test="exprCourier != null">exprCourier = #{exprCourier},</if>
            <if test="courierPhone != null">courierPhone = #{courierPhone},</if>
            <if test="delFlag != null">delFlag = #{delFlag},</if>
            <if test="createUser != null">createUser = #{createUser},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where expressInfoId = #{expressInfoId}
    </update>

    <delete id="deleteExpressInfoByExpressInfoId" parameterType="Long">
        delete from t_express_info where expressInfoId = #{expressInfoId}
    </delete>

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

    <update id="logicDeleteExpressInfoByExpressInfoId" parameterType="Long">
        update t_express_info
            set delFlag = '1'
        where expressInfoId = #{expressInfoId}
    </update>

    <update id="logicDeleteExpressInfoByExpressInfoIds" parameterType="String">
        update t_express_info
        set delFlag = '1'
        where expressInfoId in
        <foreach item="expressInfoId" collection="array" open="(" separator="," close=")">
            #{expressInfoId}
        </foreach>
    </update>

    <update id="logicDeleteExpressInfoByCondition" parameterType="ExpressInfo">
        update t_express_info
        set delFlag = '1'
        <where>
            <if test="expressNo != null  and expressNo != ''"> and expressNo = #{expressNo}</if>
            <if test="exprTime != null "> and exprTime = #{exprTime}</if>
            <if test="exprContext != null  and exprContext != ''"> and exprContext = #{exprContext}</if>
            <if test="returnCode != null  and returnCode != ''"> and returnCode = #{returnCode}</if>
            <if test="returnState != null  and returnState != ''"> and returnState = #{returnState}</if>
            <if test="returnMsg != null  and returnMsg != ''"> and returnMsg = #{returnMsg}</if>
            <if test="exprCode != null  and exprCode != ''"> and exprCode = #{exprCode}</if>
            <if test="exprName != null  and exprName != ''"> and exprName like concat('%', #{exprName}, '%')</if>
            <if test="exprSite != null  and exprSite != ''"> and exprSite = #{exprSite}</if>
            <if test="exprPhone != null  and exprPhone != ''"> and exprPhone = #{exprPhone}</if>
            <if test="exprLogo != null  and exprLogo != ''"> and exprLogo = #{exprLogo}</if>
            <if test="exprCourier != null  and exprCourier != ''"> and exprCourier = #{exprCourier}</if>
            <if test="courierPhone != null  and courierPhone != ''"> and courierPhone = #{courierPhone}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </update>
</mapper>