<?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.hotwj.platform.noticeManagerment.adminNotice.mapper.HotAdminNoticeMapper">

    <select id="selectReceiptStatusList"
            resultType="com.hotwj.platform.noticeManagerment.adminNotice.domain.vo.HotAdminNoticeVo">
        SELECT n.*, c.company_name, c.responsible_name, c.responsible_mobile
        FROM hot_admin_notice n
        LEFT JOIN sys_company c ON n.company_id = c.id
        <where>
            n.is_deleted = 0
            AND c.is_deleted = 0
            <if test="bo.noticeId != null">
                AND n.notice_id = #{bo.noticeId}
            </if>
            <if test="bo.companyId != null">
                AND n.company_id = #{bo.companyId}
            </if>
            <if test="bo.isReceived != null">
                AND n.is_received = #{bo.isReceived}
            </if>
            <if test="bo.status != null">
                AND n.status = #{bo.status}
            </if>
            <if test="bo.districtCode != null and bo.districtCode != ''">
                AND c.region_code LIKE concat(#{bo.districtCode}, '%')
            </if>
        </where>
        ORDER BY n.receive_time DESC, n.id ASC
    </select>

    <select id="selectPageList"
            resultType="com.hotwj.platform.noticeManagerment.adminNotice.domain.vo.HotAdminNoticeVo">
        SELECT *,
               (SELECT r.audit_remark
                FROM hot_notice_reply r
                WHERE r.relation_id = hot_admin_notice.id
                  AND r.is_deleted = 0
                ORDER BY r.create_time DESC LIMIT 1) as audit_remark
        FROM hot_admin_notice
            ${ew.customSqlSegment}
    </select>
</mapper>