<?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.ResourceTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.ResourceType">
        <result column="HANDLE" property="handle" />
        <result column="CHANGE_STAMP" property="changeStamp" />
        <result column="SITE" property="site" />
        <result column="RESOURCE_TYPE" property="resourceType" />
        <result column="DESCRIPTION" property="description" />
        <result column="CREATED_DATE_TIME" property="createdDateTime" />
        <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        HANDLE, CHANGE_STAMP, SITE, RESOURCE_TYPE, DESCRIPTION, CREATED_DATE_TIME, MODIFIED_DATE_TIME
    </sql>

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

    <select id="selectByMap" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List"></include>
        FROM RESOURCE_TYPE
        <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 RESOURCE_TYPE
        <where>
            <if test="ew.entity.handle!=null">
              HANDLE=#{ew.handle}
            </if>
            <if test="ew.entity.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
            <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
            <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
            <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
            <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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">
                    and ${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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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.meapi.model.ResourceType">
        INSERT INTO RESOURCE_TYPE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            HANDLE,
            <if test="changeStamp!=null">CHANGE_STAMP,</if>
            <if test="site!=null">SITE,</if>
            <if test="resourceType!=null">RESOURCE_TYPE,</if>
            <if test="description!=null">DESCRIPTION,</if>
            <if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
            <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            <if test="changeStamp!=null">#{changeStamp},</if>
            <if test="site!=null">#{site},</if>
            <if test="resourceType!=null">#{resourceType},</if>
            <if test="description!=null">#{description},</if>
            <if test="createdDateTime!=null">#{createdDateTime},</if>
            <if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
        </trim>
    </insert>

    <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.ResourceType">
        INSERT INTO RESOURCE_TYPE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="Base_Column_List"></include>
        </trim> VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{handle},
            #{changeStamp},
            #{site},
            #{resourceType},
            #{description},
            #{createdDateTime},
            #{modifiedDateTime},
        </trim>
    </insert>






    <update id="update">
        UPDATE RESOURCE_TYPE <trim prefix="SET" suffixOverrides=",">
        <if test="et.handle!=null">HANDLE=#{et.handle},</if>
        <if test="et.changeStamp!=null">CHANGE_STAMP=#{et.changeStamp},</if>
        <if test="et.site!=null">SITE=#{et.site},</if>
        <if test="et.resourceType!=null">RESOURCE_TYPE=#{et.resourceType},</if>
        <if test="et.description!=null">DESCRIPTION=#{et.description},</if>
        <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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="deleteByMap">
        DELETE FROM RESOURCE_TYPE
        <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 RESOURCE_TYPE
        <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.changeStamp!=null"> AND CHANGE_STAMP=#{ew.entity.changeStamp}</if>
                    <if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
                    <if test="ew.entity.resourceType!=null"> AND RESOURCE_TYPE=#{ew.entity.resourceType}</if>
                    <if test="ew.entity.description!=null"> AND DESCRIPTION=#{ew.entity.description}</if>
                    <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</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>

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

</mapper>
