<?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.xmomen.module.resource.mapper.ResourceMapperExt">

    <!--    查询消息    -->
    <select id="getResourceModel"
            resultType="com.xmomen.module.resource.model.ResourceModel"
            parameterType="com.xmomen.module.resource.model.ResourceQuery">
        SELECT * FROM cd_resource t
        <where>
            <if test="id">
                AND t.ID = #{id}
            </if>
            <if test="entityId">
                AND t.ENTITY_ID = #{entityId}
            </if>
            <if test="entityType">
                AND t.ENTITY_TYPE = #{entityType}
            </if>
            <if test="ids">
                AND t.ID IN
                <foreach collection="ids" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="excludeIds">
                AND t.ID NOT IN
                <foreach collection="excludeIds" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        ORDER BY t.id
    </select>

    <!--更新默认资源-->
    <update id="updateDefaultByEntityId" parameterType="java.lang.String">
        update
        cd_resource
        set
          is_default = 0
        where
        entity_id=#{entityId}
    </update>

</mapper>