<?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.common.mapper.MessageMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.common.model.Message">
        <id column="HANDLE" property="handle" />
        <result column="SITE" property="site" />
        <result column="OBJECT_BO" property="objectBo" />
        <result column="TYPE" property="type" />
        <result column="MESSAGE_TYPE" property="messageType" />
        <result column="SEND_USER_GROUP" property="sendUserGroup" />
        <result column="SEND_USER" property="sendUser" />
        <result column="CONTENT" property="content" />
        <result column="UP_USER_GROUP" property="upUserGroup" />
        <result column="UP_USER" property="upUser" />
        <result column="UP_MESSAGE_TYPE" property="upMessageType" />
        <result column="UP_DATE_TIME" property="upDateTime" />
        <result column="GRADE" property="grade" />
        <result column="RESPONSE_DATE_TIME" property="responseDateTime" />
        <result column="NODE" property="node" />
        <result column="STATUS" property="status" />
        <result column="CREATED_USER" property="createdUser" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_USER" property="modifiedUser" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, SITE, OBJECT_BO, TYPE, MESSAGE_TYPE, SEND_USER_GROUP, SEND_USER, CONTENT, UP_USER_GROUP, UP_USER, UP_MESSAGE_TYPE, UP_DATE_TIME, GRADE, RESPONSE_DATE_TIME, NODE, STATUS, CREATED_USER, CREATED_DATE_TIME, MODIFIED_USER, MODIFIED_DATE_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_MESSAGE
        <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="selectBatchIds" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM Z_MESSAGE WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </select>

    <select id="selectOne" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include> FROM Z_MESSAGE
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
            <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
            <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
            <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
            <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
            <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
            <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
            <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
            <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
            <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
            <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
            <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
            <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
            <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
            <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
            <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
            <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM Z_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                <if test="ew.entity.handle!=null">
                    HANDLE=#{ew.entity.handle}
                </if>
                <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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.common.model.Message">
        INSERT INTO Z_MESSAGE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="site!=null">SITE,</if>
            <if test="objectBo!=null">OBJECT_BO,</if>
            <if test="type!=null">TYPE,</if>
            <if test="messageType!=null">MESSAGE_TYPE,</if>
            <if test="sendUserGroup!=null">SEND_USER_GROUP,</if>
            <if test="sendUser!=null">SEND_USER,</if>
            <if test="content!=null">CONTENT,</if>
            <if test="upUserGroup!=null">UP_USER_GROUP,</if>
            <if test="upUser!=null">UP_USER,</if>
            <if test="upMessageType!=null">UP_MESSAGE_TYPE,</if>
            <if test="upDateTime!=null">UP_DATE_TIME,</if>
            <if test="grade!=null">GRADE,</if>
            <if test="responseDateTime!=null">RESPONSE_DATE_TIME,</if>
            <if test="node!=null">NODE,</if>
            <if test="status!=null">STATUS,</if>
            <if test="createdUser!=null">CREATED_USER,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedUser!=null">MODIFIED_USER,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="site!=null">#{site},</if>
            <if test="objectBo!=null">#{objectBo},</if>
            <if test="type!=null">#{type},</if>
            <if test="messageType!=null">#{messageType},</if>
            <if test="sendUserGroup!=null">#{sendUserGroup},</if>
            <if test="sendUser!=null">#{sendUser},</if>
            <if test="content!=null">#{content},</if>
            <if test="upUserGroup!=null">#{upUserGroup},</if>
            <if test="upUser!=null">#{upUser},</if>
            <if test="upMessageType!=null">#{upMessageType},</if>
            <if test="upDateTime!=null">#{upDateTime},</if>
            <if test="grade!=null">#{grade},</if>
            <if test="responseDateTime!=null">#{responseDateTime},</if>
            <if test="node!=null">#{node},</if>
            <if test="status!=null">#{status},</if>
            <if test="createdUser!=null">#{createdUser},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedUser!=null">#{modifiedUser},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.common.model.Message">
        INSERT INTO Z_MESSAGE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{site},
            #{objectBo},
            #{type},
            #{messageType},
            #{sendUserGroup},
            #{sendUser},
            #{content},
            #{upUserGroup},
            #{upUser},
            #{upMessageType},
            #{upDateTime},
            #{grade},
            #{responseDateTime},
            #{node},
            #{status},
            #{createdUser},
            #{createdDateTime},
            #{modifiedUser},
            #{modifiedDateTime},
        </trim>
    </insert>


    <update id="updateById">
        UPDATE Z_MESSAGE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.objectBo!=null">OBJECT_BO=#{et.objectBo},</if>
        <if test="et.type!=null">TYPE=#{et.type},</if>
        <if test="et.messageType!=null">MESSAGE_TYPE=#{et.messageType},</if>
        <if test="et.sendUserGroup!=null">SEND_USER_GROUP=#{et.sendUserGroup},</if>
        <if test="et.sendUser!=null">SEND_USER=#{et.sendUser},</if>
        <if test="et.content!=null">CONTENT=#{et.content},</if>
        <if test="et.upUserGroup!=null">UP_USER_GROUP=#{et.upUserGroup},</if>
        <if test="et.upUser!=null">UP_USER=#{et.upUser},</if>
        <if test="et.upMessageType!=null">UP_MESSAGE_TYPE=#{et.upMessageType},</if>
        <if test="et.upDateTime!=null">UP_DATE_TIME=#{et.upDateTime},</if>
        <if test="et.grade!=null">GRADE=#{et.grade},</if>
        <if test="et.responseDateTime!=null">RESPONSE_DATE_TIME=#{et.responseDateTime},</if>
        <if test="et.node!=null">NODE=#{et.node},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
        </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="updateAllColumnById">
        UPDATE Z_MESSAGE <trim prefix="SET" suffixOverrides=",">
        SITE=#{et.site},
        OBJECT_BO=#{et.objectBo},
        TYPE=#{et.type},
        MESSAGE_TYPE=#{et.messageType},
        SEND_USER_GROUP=#{et.sendUserGroup},
        SEND_USER=#{et.sendUser},
        CONTENT=#{et.content},
        UP_USER_GROUP=#{et.upUserGroup},
        UP_USER=#{et.upUser},
        UP_MESSAGE_TYPE=#{et.upMessageType},
        UP_DATE_TIME=#{et.upDateTime},
        GRADE=#{et.grade},
        RESPONSE_DATE_TIME=#{et.responseDateTime},
        NODE=#{et.node},
        STATUS=#{et.status},
        CREATED_USER=#{et.createdUser},
        CREATED_DATE_TIME=#{et.createdDateTime},
        MODIFIED_USER=#{et.modifiedUser},
        MODIFIED_DATE_TIME=#{et.modifiedDateTime},
     </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
    </update>


    <update id="update">
        UPDATE Z_MESSAGE <trim prefix="SET" suffixOverrides=",">
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.objectBo!=null">OBJECT_BO=#{et.objectBo},</if>
        <if test="et.type!=null">TYPE=#{et.type},</if>
        <if test="et.messageType!=null">MESSAGE_TYPE=#{et.messageType},</if>
        <if test="et.sendUserGroup!=null">SEND_USER_GROUP=#{et.sendUserGroup},</if>
        <if test="et.sendUser!=null">SEND_USER=#{et.sendUser},</if>
        <if test="et.content!=null">CONTENT=#{et.content},</if>
        <if test="et.upUserGroup!=null">UP_USER_GROUP=#{et.upUserGroup},</if>
        <if test="et.upUser!=null">UP_USER=#{et.upUser},</if>
        <if test="et.upMessageType!=null">UP_MESSAGE_TYPE=#{et.upMessageType},</if>
        <if test="et.upDateTime!=null">UP_DATE_TIME=#{et.upDateTime},</if>
        <if test="et.grade!=null">GRADE=#{et.grade},</if>
        <if test="et.responseDateTime!=null">RESPONSE_DATE_TIME=#{et.responseDateTime},</if>
        <if test="et.node!=null">NODE=#{et.node},</if>
        <if test="et.status!=null">STATUS=#{et.status},</if>
        <if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
        <if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</if>
        <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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="deleteById">
        DELETE FROM Z_MESSAGE WHERE HANDLE=#{handle}
    </delete>

    <delete id="deleteByMap">
        DELETE FROM Z_MESSAGE
        <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_MESSAGE
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    <if test="ew.entity.handle!=null">
                        HANDLE=#{ew.entity.handle}
                    </if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.objectBo!=null"> AND OBJECT_BO=#{ew.entity.objectBo}</if>
                    <if test="ew.entity.type!=null"> AND TYPE=#{ew.entity.type}</if>
                    <if test="ew.entity.messageType!=null"> AND MESSAGE_TYPE=#{ew.entity.messageType}</if>
                    <if test="ew.entity.sendUserGroup!=null"> AND SEND_USER_GROUP=#{ew.entity.sendUserGroup}</if>
                    <if test="ew.entity.sendUser!=null"> AND SEND_USER=#{ew.entity.sendUser}</if>
                    <if test="ew.entity.content!=null"> AND CONTENT=#{ew.entity.content}</if>
                    <if test="ew.entity.upUserGroup!=null"> AND UP_USER_GROUP=#{ew.entity.upUserGroup}</if>
                    <if test="ew.entity.upUser!=null"> AND UP_USER=#{ew.entity.upUser}</if>
                    <if test="ew.entity.upMessageType!=null"> AND UP_MESSAGE_TYPE=#{ew.entity.upMessageType}</if>
                    <if test="ew.entity.upDateTime!=null"> AND UP_DATE_TIME=#{ew.entity.upDateTime}</if>
                    <if test="ew.entity.grade!=null"> AND GRADE=#{ew.entity.grade}</if>
                    <if test="ew.entity.responseDateTime!=null"> AND RESPONSE_DATE_TIME=#{ew.entity.responseDateTime}</if>
                    <if test="ew.entity.node!=null"> AND NODE=#{ew.entity.node}</if>
                    <if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
                    <if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
                    <if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
                    <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</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>

    <delete id="deleteBatchIds">
        DELETE FROM Z_MESSAGE WHERE HANDLE IN (
        <foreach item="item" index="index" collection="coll" separator=",">#{item}
        </foreach>)
    </delete>
    <!-- BaseMapper标准查询/修改/删除 -->

</mapper>
