<?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.foreverwin.mesnac.dataimport.mapper.MasterImportLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.dataimport.model.MasterImportLog">
        <result column="TRANS_ID" property="transId" />
        <result column="MESSAGE" property="message" />
        <result column="INDEX" property="index" />
        <result column="LOG_TIME" property="logTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        TRANS_ID, MESSAGE, "INDEX", LOG_TIME
    </sql>

    <!-- BaseMapper标准查询/修改/删除 -->
    <select id="selectById" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_MASTER_IMPORT_LOG WHERE TRANS_ID=#{handle}
    </select>

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_MASTER_IMPORT_LOG
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </select>


    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew.entity.transId!=null">
              TRANS_ID=#{ew.transId}
            </if>
            <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
            <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
            <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                <if test="ew.entity.transId!=null">
                    TRANS_ID=#{ew.entity.transId}
                </if>
                <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.transId!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMaps" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.transId!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectObjs" resultType="Object">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.transId!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectPage" resultMap="BaseResultMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.transId!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <select id="selectMapsPage" resultType="HashMap">
        SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.transId!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </select>

    <insert id="insert" parameterType="com.foreverwin.mesnac.dataimport.model.MasterImportLog">
        INSERT INTO Z_MASTER_IMPORT_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            TRANS_ID,
            <if test="message!=null">MESSAGE,</if>
            <if test="index!=null">"INDEX",</if>
            <if test="logTime!=null">LOG_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{transId},
            <if test="message!=null">#{message},</if>
            <if test="index!=null">#{index},</if>
            <if test="logTime!=null">#{logTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.dataimport.model.MasterImportLog">
        INSERT INTO Z_MASTER_IMPORT_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{transId},
            #{message},
            #{index},
            #{logTime},
        </trim>
    </insert>






    <update id="update">
        UPDATE Z_MASTER_IMPORT_LOG <trim prefix="SET" suffixOverrides=",">
        <if test="et.transId!=null">TRANS_ID=#{et.transId},</if>
        <if test="et.message!=null">MESSAGE=#{et.message},</if>
        <if test="et.index!=null">"INDEX"=#{et.index},</if>
        <if test="et.logTime!=null">LOG_TIME=#{et.logTime},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    TRANS_ID=#{ew.entity.transId}
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </update>


    <delete id="deleteByMap">
        DELETE FROM Z_MASTER_IMPORT_LOG
        <if test="cm!=null and !cm.isEmpty">
            <where>
                <foreach collection="cm.keys" item="k" separator="AND">
                    <if test="cm[k] != null">
                        ${k} = #{cm[${k}]}
                    </if>
                </foreach>
            </where>
        </if>
    </delete>

    <delete id="delete">
        DELETE FROM Z_MASTER_IMPORT_LOG
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        TRANS_ID=#{ew.entity.transId}
                    </if>
                    <if test="ew.entity.message!=null"> AND MESSAGE=#{ew.entity.message}</if>
                    <if test="ew.entity.index!=null"> AND "INDEX"=#{ew.entity.index}</if>
                    <if test="ew.entity.logTime!=null"> AND LOG_TIME=#{ew.entity.logTime}</if>
                </if>
                <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
                    ${ew.sqlSegment}
                </if>
            </if>
        </where>
        <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
            ${ew.sqlSegment}
        </if>
    </delete>

    <!-- BaseMapper标准查询/修改/删除 -->

</mapper>
