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

        <result property="tpcId" column="tpc_id"/>
        <result property="tpcName" column="tpc_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="getTestPaperCatList" resultType="com.sundot.airport.exam.common.model.result.TestPaperCatPageResult">
        SELECT
        c.`id`,
        c.`tpc_id`,
        c.`tpc_name`,
        c.`del_status`,
        c.`create_time`,
        c.`create_uid`,
        c.`update_time`,
        c.`update_uid`,
        (SELECT COUNT(id) FROM edu_cs_test_paper WHERE del_status=0 AND tpc_id=c.tpc_id) testPaperCount
        FROM edu_cs_test_paper_cat c
        WHERE c.del_status=0
		UNION ALL
		SELECT 0 id,
		'' tpc_id,
		'未分类' tpc_name,
		0 del_status,
		NOW() create_time,
		'' create_uid,
		NOW() update_time,
		'' update_uid,
		COUNT(id) testPaperCount
		FROM edu_cs_test_paper
		WHERE tpc_id='' AND del_status=0
    </select>
</mapper>

