<?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.ycl.jxkg.mapper.ClassesUserMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.vo.ClassesUserVO">
|
<result column="classes_id" property="classesId"/>
|
<result column="user_id" property="userId"/>
|
<result column="real_name" property="realName"/>
|
<result column="sex" property="sex"/>
|
<result column="phone" property="phone"/>
|
<result column="create_time" property="createTime"/>
|
<result column="user_name" property="userName"/>
|
<result column="age" property="age"/>
|
<result column="birth_day" property="birthDay"/>
|
<result column="status" property="status"/>
|
</resultMap>
|
|
<resultMap id="ResultMap" type="com.ycl.jxkg.domain.vo.StudentExamInfoVO">
|
<result column="id" property="userId"/>
|
<result column="phone" property="phone"/>
|
<result column="real_name" property="realName"/>
|
<result column="do_time" property="doTime"/>
|
<result column="exam_submit" property="examSubmit"/>
|
<result column="status" property="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
|
<result column="phone" property="phone"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="mark_paper_status" property="markPaperStatus" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
|
</resultMap>
|
|
|
<select id="getById" resultMap="BaseResultMap">
|
SELECT TCU.classes_id,
|
TCU.user_id,
|
TCU.create_time,
|
TCU.id
|
FROM t_classes_user TCU
|
WHERE TCU.id = #{id}
|
AND TCU.deleted = 0
|
</select>
|
|
|
<select id="getPage" resultMap="BaseResultMap">
|
SELECT TCU.classes_id,
|
TCU.user_id,
|
TCU.create_time,
|
TCU.id,
|
TU.real_name,
|
TU.sex,
|
TU.phone,
|
TU.user_name,
|
TU.age,
|
TU.birth_day,
|
TU.status
|
FROM t_classes_user TCU
|
INNER JOIN t_user TU ON TU.id = TCU.user_id and TU.deleted = 0 AND TCU.classes_id = #{query.classesId} AND TCU.deleted = 0 AND TCU.teacher = 0
|
<where>
|
<if test="query.studentName != null and query.studentName != ''">AND TU.real_name like concat('%',
|
#{query.studentName}, '%')
|
</if>
|
</where>
|
order by TU.id desc
|
</select>
|
|
|
<select id="getClassesUserList" resultMap="ResultMap">
|
SELECT
|
TU.id,
|
TU.real_name,
|
TU.phone
|
FROM
|
t_classes_user TCU
|
INNER JOIN t_user TU ON TU.id = TCU.user_id AND TCU.classes_id = #{classesId}
|
WHERE
|
TCU.deleted = 0 AND TCU.teacher = 0
|
</select>
|
|
<select id="getClassesByUserId" resultType="java.lang.Integer">
|
select classes_id
|
from t_classes_user
|
where user_id = #{userId} and deleted = 0 and teacher = 0
|
</select>
|
|
<select id="getClassesByUserId1" resultType="com.ycl.jxkg.domain.vo.ClassesVO">
|
select distinct tc.id, tc.class_name
|
from t_classes_user tcu inner join t_classes tc ON tcu.classes_id = tc.id
|
and tcu.user_id = #{userId} and tcu.teacher = 0 and tcu.deleted = 0
|
</select>
|
|
<select id="getClassesNameByUserId" resultType="java.lang.String">
|
select tc.class_name
|
from t_classes_user tcu
|
left join t_classes tc on tcu.classes_id = tc.id
|
where user_id = #{userId} and tcu.deleted = 0 and tc.deleted =0
|
</select>
|
|
<select id="getTeacherListByClassesId" resultType="com.ycl.jxkg.domain.vo.StudentVO">
|
SELECT
|
DISTINCT tu.id, tu.real_name
|
FROM t_user tu
|
INNER JOIN t_classes_user tcu ON tu.id = tcu.user_id AND tcu.classes_id = #{id} AND tcu.deleted = 0 AND tcu.teacher = 1 AND tu.deleted = 0
|
</select>
|
|
<select id="getTeachersByClassesIds" resultType="string">
|
SELECT
|
DISTINCT tu.real_name
|
FROM t_user tu
|
INNER JOIN t_classes_user tcu ON tu.id = tcu.user_id AND tcu.deleted = 0 AND tcu.teacher = 1 AND tu.deleted = 0
|
WHERE
|
tcu.classes_id in <foreach collection="classesIds" open="(" separator="," close=")" item="classesId">
|
#{classesId}
|
</foreach>
|
</select>
|
</mapper>
|