Blame view

ClassesDictMapper.xml 4.18 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
<?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.meishu.mapper.ClassesDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.meishu.model.ClassesDictDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="school" property="school" />
        <result column="grade" property="grade" />
        <result column="classes" property="classes" />
        <result column="session" property="session" />
        <result column="subject_type" property="subjectType" />
        <result column="class_name" property="className" />
        <result column="semester" property="semester" />
        <result column="status" property="status" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        id, school, grade, classes, session, subject_type, class_name, semester, status
    </sql>

    <select id="getClasses" resultType="com.meishu.vo.classes.GetClassesVO">
        SELECT
            t.id,
            t.class_name,
            t.grade,
            t3.cnt,
            t.`session`,
            t.`status`,
            t.classes,
            t.upgrade_date
        FROM
            classes_dict t
            LEFT JOIN ( SELECT t2.classes_id, count( 1 ) AS cnt FROM classes_user_mapping t2 where t2.delete_date is null GROUP BY t2.classes_id ) t3 ON t.id = t3.classes_id
--             left join classes_dict t4 on t.class_dict_id = t4.id
        WHERE
            1=1
            <if test="session != null and session !=''">
               and  t.SESSION = #{session}
            </if>
            <if test="className != null and className != ''">
               and  t.class_name  like concat('%',#{className} ,'%')
            </if>
            <if test="grade != null and grade != ''">
               and  t.grade = #{grade}
            </if>
            <if test="status != null and status != ''">
               and  t.status = #{status}
            </if>
        order by t.grade_order,t.classes*1
    </select>

    <select id="getClassStudents" resultType="com.meishu.vo.classes.GetClassStudentsVO">
        SELECT
            t.id,
            t2.id as userId,
            t2.user_name,
            t2.study_code,
            t2.phone,
            t3.grade,
            t2.`session`,
            t2.id_card,
            t2.gender,
            t2.email,
            t2.user_status
        FROM
            classes_user_mapping t
            LEFT JOIN user_role t2 ON t.user_id = t2.id
            LEFT JOIN classes_dict t3 ON t.classes_id = t3.id
            where t.classes_id = #{classId}
                and t.delete_date is null
            <if test="userName != null and userName != ''">
                and user_name like concat('%',#{userName} ,'%')
            </if>
    </select>

    <select id="queryNoClassStudents" resultType="com.meishu.model.UserRoleDO">
        SELECT
            *,
            t.id as userId
        FROM
            user_role t
        WHERE
            t.id NOT IN (
            SELECT
                user_id
        FROM
            classes_user_mapping where delete_date is null)
        <if test="userName != null and userName != ''">
            and user_name like concat('%',#{userName} ,'%')
        </if>
        and t.delete_date is null
    </select>


    <select id="getClassesById" resultType="com.meishu.model.ClassesDictDO">
        select
            c.*
        from classes_dict c
        left join classes_user_mapping cum on cum.classes_id = c.id
        where cum.user_id = #{studentId}
        and c.delete_date is null
        and cum.delete_date is null
    </select>

    <select id="getGradeClasses" parameterType="com.meishu.model.ClassesDictDO" resultType="com.meishu.model.ClassesDictDO">
        SELECT
            *
        FROM
            classes_dict t
        WHERE
            t.grade = #{grade}
            AND t.STATUS = '在读'
            and t.delete_date is null
        order by t.classes*1
    </select>

</mapper>