<?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="jnpf.cultivate.mapper.CultivateIdentifyItemsMapper">

    <select id="countForTableId" resultType="jnpf.model.cultivate.dto.learn.BatchCommonCountDto">

        SELECT
            F_TableId AS selectKey,
        COUNT(1) AS num
        FROM
            ftb_cultivate_identify_items
        WHERE
            F_DeleteMark = 0

        <if test="ids != null and ids.size() > 0 ">
            and F_TableId in
            <foreach collection="ids" item="item" open="("  separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY
            F_TableId
    </select>

    <select id="listWithCategory" resultType="jnpf.model.cultivate.vo.identify.IdentifyItemsWithCategoryVo">
        SELECT
            items.F_Id AS id,
            items.F_TableId AS tableId,
            items.F_Name AS name,
            items.F_TotalScore AS score,
            items.F_Type AS type,
            items.F_MinScore AS minScore,
            items.F_MaxScore AS maxScore,
            items.F_SortCode AS sortCode,
            items.F_PoolId AS poolId,
            items.F_IsAbnormal AS isAbnormal,
            items.F_CateId AS cateId,
            categories.F_Name AS cateName,
            items.F_BusinessId AS businessId
        FROM
            ftb_cultivate_identify_items items
        LEFT JOIN
            ftb_cultivate_identify_categories categories ON items.F_CateId = categories.F_Id
        WHERE  items.F_TableId = #{tableId} AND items.F_DeleteMark = 0 order by items.F_SortCode  asc
    </select>
</mapper>