<?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.hxhq.business.mapper.StudySubjectMapper">
    <select id="selectAllSubject" resultType="com.hxhq.business.domain.StudySubject">
        SELECT dept_id,dept_name,jc as deptJc  FROM `sys_dept` WHERE del_flag='0' AND `show_in_subject`=10
        ORDER BY CONVERT(dept_name USING gbk) ASC
    </select>
    <select id="queryPreFormCountList" resultType="com.hxhq.business.dto.study.StudyListDto">
        SELECT study_subject_id AS id, COUNT(0) AS formCount
        FROM `t_study_form_pre`
        WHERE del_flag='0'
        AND study_subject_id IN
        <foreach collection="idList" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        GROUP BY study_subject_id
    </select>
    <select id="queryFormCountList" resultType="com.hxhq.business.dto.study.StudyListDto">
        SELECT study_subject_id AS id, COUNT(0) AS formCount
        FROM `t_study_form_fill`
        WHERE del_flag='0'
        AND study_subject_id IN
        <foreach collection="idList" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        GROUP BY study_subject_id
    </select>
</mapper>