<?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.cyksj.mapper.InformationMapper">


    <select id="getInformation" resultType="com.cyksj.model.views.InformationListView">
        select id,title,thumbnail,created_time,content,sub_title,logo,is_black_font from information where status is true and deleted is true
        <choose>
            <when test="categoryId != null">
                and JSON_CONTAINS(category_ids,'"${categoryId}"') = 1
            </when>
            <otherwise>
                and recommend is true
            </otherwise>
        </choose>
        order by sorted, case when top is true then 1 else 2 end,created_time desc
    </select>

    <select id="getInformationByTitle" resultType="com.cyksj.model.views.InformationListView">
        select id,title,thumbnail,created_time,content,sub_title,logo,is_black_font
        from information
        where title like '%${title}%'
          and status is true
          and deleted is true
        order by created_time desc
    </select>
</mapper>