<?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="cn.iocoder.yudao.module.notice.mapper.DlBaseNoticeMapper">

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.notice.entity.DlBaseNotice">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="title" column="title" jdbcType="VARCHAR"/>
            <result property="content" column="content" jdbcType="VARCHAR"/>
            <result property="type" column="type" jdbcType="TINYINT"/>
            <result property="status" column="status" jdbcType="TINYINT"/>
            <result property="parentServer" column="parent_server" jdbcType="VARCHAR"/>
            <result property="server" column="server" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_SQL">
        select id,
               title,
               content,
               type,
               status,
               parent_server,
               server,
               create_time
        from dl_base_notice dbn
        where dbn.deleted = '0'
    </sql>

    <select id="pageNotice" resultMap="BaseResultMap">
        <include refid="Base_SQL" />
        <if test="map.parentServer != null and map.parentServer != ''">
            and dbn.parent_server = #{map.parentServer}
        </if>
        <if test="map.server != null and map.server != ''">
            and dbn.server = #{map.server}
        </if>
        <if test="map.typeStr != null and map.typeStr != ''">
            and dbn.type IN
            <foreach collection="map.typeStr.split(',')" separator="," item="item" open="(" close=")">
             #{item}
            </foreach>
        </if>
        <if test="map.status != null">
            and dbn.status = #{map.status}
        </if>
        <if test="map.title != null and map.title != ''">
            and dbn.title like concat('%', #{map.title}, '%')
        </if>
        order by dbn.create_time desc
    </select>
</mapper>
