<?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.fzm.mall.server.admin.message.mapper.NoticeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.message.model.Notice">
        <id column="id" property="id" />
        <result column="title" property="title" />
        <result column="notice_id" property="noticeId" />
        <result column="content" property="content" />
        <result column="start_time" property="startTime" />
        <result column="end_time" property="endTime" />
        <result column="merchant_id" property="merchantId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.message.entity.dto.NoticeDTO">
        select id, notice_id, title, content, start_time, end_time, create_time, update_time
        from notice
        <where>
            <if test="content != null and content != ''">
                and content like CONCAT('%', #{content},'%') or title like CONCAT('%', #{content},'%')
            </if>
            <if test="merchantId != null and merchantId != ''">
                and merchant_id in(#{merchantId}, #{platformMerchantId})
            </if>
        </where>
        order by create_time desc
    </select>
</mapper>
