<?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="org.springblade.modules.business.notice.mapper.NoticeAttachMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="noticeResultMap" type="org.springblade.modules.business.notice.entity.NoticeAttachEntity">
        <result column="group_id" property="groupId"/>
        <result column="attach_id" property="attachId"/>
    </resultMap>

    <resultMap id="noticeResultMapVO" type="org.springblade.modules.business.notice.vo.NoticeAttachVO">
        <result column="group_id" property="groupId"/>
        <result column="attach_id" property="attachId"/>
        <result column="original_name" property="attachName"/>
        <result column="name" property="attachUrl"/>
    </resultMap>

    <select id="selectPage" resultMap="noticeResultMapVO">
        SELECT
        n.*,
        a.original_name  ,a.name
        FROM
        blade_notice_attach n
        LEFT JOIN blade_attach  a on n.attach_id =  a.id
        WHERE
        n.is_deleted = 0
        <if test="notice.groupId!=null">
            and n.group_id = #{notice.groupId}
        </if>
        order by n.create_time desc
    </select>
</mapper>
