<?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.fastbee.iot.mapper.NewsMapper">

    <resultMap type="com.fastbee.iot.domain.News" id="NewsResult">
        <result property="newsId"    column="news_id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="isTop"    column="is_top"    />
        <result property="isBanner"    column="is_banner"    />
        <result property="categoryId"    column="category_id"    />
        <result property="categoryName"    column="category_name"    />
        <result property="status"    column="status"    />
        <result property="author"    column="author"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectNewsVo">
        select news_id, title, img_url, is_top, is_banner, category_id, category_name, status, author, del_flag, create_by, create_time, update_by, update_time, remark from news
    </sql>

    <select id="selectTopNewsList" parameterType="com.fastbee.iot.domain.News" resultMap="NewsResult">
        select n.news_id, n.title, n.img_url, n.is_top, n.is_banner, n.category_id, c.category_name, n.status, n.author, n.create_time, n.remark
        from news n left join news_category c on c.category_id=n.category_id
        where n.is_top=1 and n.status=1
        and n.del_flag = '0'
        and c.del_flag = '0'
        order by n.create_time desc
    </select>

</mapper>

