<?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.NewsCategoryMapper">

    <resultMap type="com.fastbee.iot.domain.NewsCategory" id="NewsCategoryResult">
        <result property="categoryId"    column="category_id"    />
        <result property="categoryName"    column="category_name"    />
        <result property="orderNum"    column="order_num"    />
        <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>

    <resultMap type="com.fastbee.iot.model.IdAndName" id="CategoryShortResult">
        <result property="id"    column="category_id"    />
        <result property="name"    column="category_name"    />
    </resultMap>

    <sql id="selectNewsCategoryVo">
        select category_id, category_name, order_num, del_flag, create_by, create_time, update_by, update_time, remark from news_category
    </sql>

    <select id="selectNewsCategoryShortList"  resultMap="CategoryShortResult">
        select category_id, category_name
        from news_category
        where del_flag = '0'
        order by order_num
    </select>

    <select id="newsCountInCategorys" parameterType="String" resultType="int">
        select count(1) from news where del_flag = '0' and category_id in
        <foreach item="categoryId" collection="array" open="(" separator="," close=")">
            #{categoryId}
        </foreach>
        and del_flag = '0'
    </select>
</mapper>
