<?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.sundot.airport.exam.mapper.QuesCatMapper">
    <resultMap id="quesCatMapperResultMap" type="com.sundot.airport.exam.domain.QuesCat">
        <id property="id" column="id"/>

        <result property="qcId" column="qc_id"/>
        <result property="qcName" column="qc_name"/>

        <result property="delStatus" column="del_status"/>
        <result property="createUid" column="create_uid"/>
        <result property="updateUid" column="update_uid"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
    <select id="getQueCatList" resultType="com.sundot.airport.exam.common.model.result.QuesCatPageResult">
        SELECT
        c.`id`,
        c.`qc_id`,
        c.`qc_name`,
        c.`del_status`,
        c.`create_time`,
        c.`create_uid`,
        c.`update_time`,
        c.`update_uid`,
        (SELECT COUNT(id) FROM edu_cs_ques WHERE del_status = 0 AND qc_id = c.qc_id) quesCount
        FROM edu_cs_ques_cat c
        WHERE c.del_status=0
		UNION ALL
		SELECT 0 id,
		'' qc_id,
		'未分类' qc_name,
		0 del_status,
		NOW() create_time,
		'' create_uid,
		NOW() update_time,
		'' update_uid,
		COUNT(id) quesCount
		FROM edu_cs_ques
		WHERE qc_id='' AND del_status=0
    </select>
</mapper>

