<?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.meapi.mapper.MessageTypeUserGroupMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.MessageTypeUserGroup">
        <result column="HANDLE" property="handle" />
        <result column="MESSAGE_TYPE_BO" property="messageTypeBo" />
        <result column="USER_GROUP_BO" property="userGroupBo" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, MESSAGE_TYPE_BO, USER_GROUP_BO
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM MESSAGE_TYPE_USER_GROUP
        <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 MESSAGE_TYPE_USER_GROUP
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
            <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</if>
        </where>
    </select>

    <select id="selectCount" resultType="Integer">
        SELECT COUNT(1) FROM MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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.meapi.model.MessageTypeUserGroup">
        INSERT INTO MESSAGE_TYPE_USER_GROUP
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="messageTypeBo!=null">MESSAGE_TYPE_BO,</if>
            <if test="userGroupBo!=null">USER_GROUP_BO,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="messageTypeBo!=null">#{messageTypeBo},</if>
            <if test="userGroupBo!=null">#{userGroupBo},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.MessageTypeUserGroup">
        INSERT INTO MESSAGE_TYPE_USER_GROUP
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{messageTypeBo},
            #{userGroupBo},
        </trim>
    </insert>






    <update id="update">
        UPDATE MESSAGE_TYPE_USER_GROUP <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.messageTypeBo!=null">MESSAGE_TYPE_BO=#{et.messageTypeBo},</if>
        <if test="et.userGroupBo!=null">USER_GROUP_BO=#{et.userGroupBo},</if>
    </trim>
        <where>
            <if test="ew!=null">
                <if test="ew.entity!=null">
                    HANDLE=#{ew.entity.handle}
                    <if test="ew.entity.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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 MESSAGE_TYPE_USER_GROUP
        <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 MESSAGE_TYPE_USER_GROUP
        <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.messageTypeBo!=null"> AND MESSAGE_TYPE_BO=#{ew.entity.messageTypeBo}</if>
                    <if test="ew.entity.userGroupBo!=null"> AND USER_GROUP_BO=#{ew.entity.userGroupBo}</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>
