123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776 |
- <?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.ym.mec.biz.dal.dao.StudentCourseHomeworkDao">
- <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomework">
- <result column="id_" property="id"/>
- <result column="user_id_" property="userId"/>
- <result column="username_" property="userName"/>
- <result column="phone_" property="phone"/>
- <result column="avatar_" property="avatar"/>
- <result column="course_homework_id_" property="courseHomeworkId"/>
- <result column="course_schedule_id_" property="courseScheduleId"/>
- <result column="attachments_" property="attachments"/>
- <result column="score_" property="score"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="remark_" property="remark"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_replied_timely_" property="isRepliedTimely"/>
- <result column="is_view_" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="submit_time_" property="submitTime"/>
- <result column="music_score_name_" property="musicScoreName"/>
- <result column="music_score_id_" property="musicScoreId"/>
- <result column="music_score_content_" property="musicScoreContent"/>
- <result column="tenant_id_" property="tenantId"/>
- <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto" id="CourseHomeworkStudentDetailDto">
- <result column="musicGroupName" property="musicGroupName"/>
- <result column="classGroupName" property="classGroupName"/>
- <result column="courseHomeworkId" property="courseHomeworkId"/>
- <result column="course_schedule_id_" property="courseScheduleId"/>
- <result column="studentCourseHomeworkId" property="studentCourseHomeworkId"/>
- <result column="content_" property="content"/>
- <result column="expiry_date_" property="expiryDate"/>
- <result column="completed_num_" property="completedNum"/>
- <result column="expect_num_" property="expectNum"/>
- <result column="attachments_" property="attachments"/>
- <result column="create_time_" property="createTime"/>
- <result column="score_" property="score"/>
- <result column="music_score_id_" property="musicScoreId"/>
- <result column="music_score_content_" property="musicScoreContent"/>
- <result column="submit_time_" property="submitTime"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomeworkFull"
- extends="StudentCourseHomework">
- <result column="musicGroupName" property="courseHomework.musicGroup.name"/>
- <result column="classGroupName" property="courseHomework.classGroup.name"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="StudentCourseHomework">
- SELECT *
- FROM student_course_homework
- WHERE id_ = #{id}
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="StudentCourseHomework">
- SELECT *
- FROM student_course_homework where tenant_id_ = #{tenantId}
- ORDER BY id_
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework" useGeneratedKeys="true"
- keyColumn="id" keyProperty="id">
- INSERT INTO student_course_homework
- (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,
- remark_,status_,is_replied_,is_view_,is_replied_timely_,music_score_id_,music_score_content_,tenant_id_,standard_flag_)
- VALUES(#{userId},#{courseScheduleId},#{courseHomeworkId},#{attachments},#{score},now(),now(),#{remark},
- #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isRepliedTimely},
- #{musicScoreId},#{musicScoreContent},#{tenantId},#{standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
- </insert>
- <insert id="batchInsertStudentCourseHomeworkRecord" parameterType="java.util.List" useGeneratedKeys="true"
- keyColumn="id" keyProperty="id">
- INSERT INTO student_course_homework
- (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,
- update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_,music_score_id_,music_score_content_,tenant_id_,standard_flag_,group_type_)
- VALUE
- <foreach collection="list" item="homework" separator=",">
- (#{homework.userId},#{homework.courseScheduleId},#{homework.courseHomeworkId},#{homework.attachments},
- #{homework.score},now(),now(),#{homework.remark},#{homework.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{homework.isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{homework.isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isRepliedTimely},
- #{homework.musicScoreId},#{homework.musicScoreContent},#{homework.tenantId},
- #{homework.standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{homework.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
- </foreach>
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework">
- UPDATE student_course_homework
- <set>
- <if test="standardFlag != null">
- standard_flag_ = #{standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="musicScoreId != null">
- music_score_id_ = #{musicScoreId},
- </if>
- <if test="musicScoreContent != null and musicScoreContent != ''">
- music_score_content_ = #{musicScoreContent},
- </if>
- <if test="courseHomeworkId != null">
- course_homework_id_ = #{courseHomeworkId},
- </if>
- <if test="courseScheduleId != null">
- course_schedule_id_ = #{courseScheduleId},
- </if>
- update_time_ = NOW(),
- <if test="score != null">
- score_ = #{score},
- </if>
- <if test="attachments != null">
- attachments_ = #{attachments},
- </if>
- <if test="remark != null">
- remark_ = #{remark},
- </if>
- <if test="status != null">
- status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="isReplied != null">
- is_replied_ = #{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="isRepliedTimely != null">
- is_replied_timely_ = #{isRepliedTimely},
- </if>
- <if test="isView != null">
- is_view_ = #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="submitTime!=null">
- submit_time_ = #{submitTime}
- </if>
- </set>
- WHERE id_ = #{id} and tenant_id_ = #{tenantId}
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete">
- DELETE
- FROM student_course_homework
- WHERE id_ = #{id}
- </delete>
- <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkListDto" id="CourseHomeworkDto">
- <result column="id_" property="id"/>
- <result column="course_schedule_id_" property="courseScheduleId"/>
- <result column="content_" property="content"/>
- <result column="create_time_" property="createTime"/>
- <result column="start_class_time_" property="startClassTime"/>
- <result column="expiry_date_" property="expiryDate"/>
- <result column="music_group_id_" property="musicGroupId"/>
- <result column="music_group_name_" property="musicGroupName"/>
- <result column="class_group_id_" property="classGroupId"/>
- <result column="class_group_name_" property="classGroupName"/>
- <result column="completed_num_" property="completedNum"/>
- <result column="expect_num_" property="expectNum"/>
- <result column="expiry_date_" property="expiryDate"/>
- <result column="remark_" property="remark"/>
- <result column="real_name_" property="teacherName"/>
- <result column="avatar_" property="headUrl"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
- <sql id="queryCondition">
- <where>
- (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL) AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
- <if test="createTime != null">
- AND DATE_FORMAT(ch.create_time_,"%Y%m%d") = DATE_FORMAT(#{createTime},"%Y%m%d")
- </if>
- <if test="musicGroupId != null">
- AND cg.music_group_id_ = #{musicGroupId}
- </if>
- <if test="groupType!=null">
- AND cg.group_type_= #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="classGroupId != null">
- AND ch.class_group_id_ = #{classGroupId}
- </if>
- <if test="userId != null">
- AND sch.user_id_ = #{userId}
- </if>
- </where>
- </sql>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="CourseHomeworkDto" parameterType="map">
- SELECT
- sch.id_,
- ch.*,
- IF(cs.group_type_='MUSIC',mg.name_,NULL) music_group_name_,
- cg.name_ class_group_name_,
- CONCAT( class_date_, ' ', start_class_time_ ) start_class_time_,
- ch.expiry_date_,
- sch.remark_,
- sch.status_,
- sch.is_replied_,
- su.real_name_,
- su.avatar_
- FROM student_course_homework sch
- LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
- LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
- LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
- LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
- <include refid="queryCondition"/>
- ORDER BY CONCAT( class_date_, ' ', start_class_time_ ) DESC
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM student_course_homework sch
- LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
- LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
- LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
- <include refid="queryCondition"/>
- </select>
- <select id="findCourseHomeworkStudentDetail" resultMap="CourseHomeworkStudentDetailDto">
- SELECT mg.name_ musicGroupName,
- cg.name_ classGroupName,
- ch.id_ courseHomeworkId,
- ch.content_,
- ch.expiry_date_,
- ch.completed_num_,
- ch.expect_num_,
- ch.expiry_date_,
- ch.create_time_,
- sch.music_score_id_,
- sch.music_score_content_,
- sch.id_ studentCourseHomeworkId,
- sch.attachments_,
- sch.score_,
- sch.status_,
- sch.is_replied_,
- sch.course_schedule_id_,
- sch.standard_flag_,
- sch.submit_time_
- FROM course_homework ch
- LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN music_group mg ON ch.music_group_id_ = mg.id_
- LEFT JOIN class_group cg ON ch.class_group_id_ = cg.id_
- WHERE ch.course_schedule_id_ = #{courseScheduleID}
- AND sch.user_id_ = #{userID}
- </select>
- <select id="constructInitialStudentHomeworkRecords" resultMap="StudentCourseHomework">
- SELECT #{courseHomeworkID} course_homework_id_,
- sa.user_id_,
- 0 status_,
- 0 is_replied_
- FROM student_attendance sa
- WHERE sa.course_schedule_id_ = #{courseScheduleID}
- AND status_ = "NORMAL"
- </select>
- <select id="constructInitialStudentHomeworkRecordsWithPayment" resultMap="StudentCourseHomework">
- SELECT #{courseHomeworkID} course_homework_id_,
- #{courseScheduleID} course_schedule_id_,
- #{musicScoreId} music_score_id_,
- #{musicScoreContent} music_score_content_,
- sa.user_id_,
- 0 status_,
- 0 is_replied_,
- 0 is_replied_timely_
- FROM course_schedule_student_payment sa
- WHERE sa.course_schedule_id_ = #{courseScheduleID}
- <if test="userIdList != null and userIdList.size > 0">
- AND sa.user_id_ IN
- <foreach collection="userIdList" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- </select>
- <select id="findByCourseSchedule" resultMap="StudentCourseHomework">
- SELECT
- sch.*,
- su.username_,
- su.avatar_,
- su.phone_
- FROM
- student_course_homework sch
- LEFT JOIN sys_user su ON sch.user_id_=su.id_
- <where>
- sch.course_schedule_id_=#{courseScheduleId}
- <if test="homeworkId!=null">
- AND sch.course_homework_id_=#{homeworkId}
- </if>
- <if test="userName!=null and userName!=''">
- AND su.username_ LIKE CONCAT('%',#{userName},'%')
- </if>
- </where>
- </select>
- <select id="findByStudentAndCourseHomewok" resultMap="StudentCourseHomework">
- SELECT *
- FROM student_course_homework
- WHERE user_id_ = #{userId}
- AND course_homework_id_ = #{courseHomeworkId}
- </select>
- <select id="queryNotDoneHomeworkList" resultMap="StudentCourseHomeworkFull">
- SELECT sch.*,
- cg.name_ classGroupName,
- mg.name_ musicGroupName
- FROM student_course_homework sch
- LEFT JOIN course_homework ch ON sch.course_homework_id_ = ch.id_
- LEFT JOIN music_group mg ON ch.music_group_id_ = mg.id_
- LEFT JOIN class_group cg ON ch.class_group_id_ = cg.id_
- WHERE date_format(date_add(ch.expiry_date_,interval -1 day),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
- AND (sch.standard_flag_ not in ('STANDARD', 'EXCELLENT') or sch.standard_flag_ is null)
- AND ch.version_tag_ = 'v2'
- </select>
- <select id="countStudentCourseHomeworks" resultType="java.lang.Integer">
- SELECT COUNT(id_)
- FROM student_course_homework
- WHERE course_schedule_id_ = #{search}
- </select>
- <resultMap id="StudentCourseHomeworkDtoMap" type="com.ym.mec.biz.dal.dto.StudentCourseHomeworkDto">
- <result column="student_course_homework_id_" property="studentCourseHomeworkId"/>
- <result column="user_id_" property="studentId"/>
- <result column="username_" property="studentName"/>
- <result column="phone_" property="phone"/>
- <result column="subject_name_" property="subjectNames"/>
- <result column="attachments_" property="url"/>
- <result column="is_replied_" property="isReplied"/>
- <result column="is_view_" property="isView"/>
- <result column="update_time_" property="createTime"/>
- <result column="submit_time_" property="submitTime"/>
- </resultMap>
- <select id="findStudentCourseHomeworks" resultMap="StudentCourseHomeworkDtoMap">
- SELECT sch.id_ student_course_homework_id_,sch.attachments_,sch.is_replied_,sch.is_view_,
- sch.update_time_,cssp.user_id_,su.username_,su.phone_,sch.submit_time_,s.name_ subject_name_
- FROM student_course_homework sch
- LEFT JOIN course_schedule_student_payment cssp ON sch.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ =
- sch.user_id_
- LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
- LEFT JOIN student_registration sr ON cssp.music_group_id_ = sr.music_group_id_ AND cssp.user_id_ = sr.user_id_
- LEFT JOIN `subject` s ON s.id_ = sr.actual_subject_id_
- WHERE sch.course_schedule_id_ = #{search}
- ORDER BY sch.id_ DESC
- <include refid="global.limit"/>
- </select>
- <resultMap id="StudentHomeworkRecordDto" type="com.ym.mec.biz.dal.dto.StudentHomeworkRecordDto">
- <result property="studentCourseHomeworkId" column="student_course_homework_id_"/>
- <result property="courseScheduleId" column="course_schedule_id_"/>
- <result property="courseName" column="course_name_"/>
- <result property="startClassTime" column="start_class_time_"/>
- <result property="teacherId" column="actual_teacher_id_"/>
- <result property="status" column="status_"/>
- <result property="expiryDate" column="expiry_date_"/>
- <result property="teacherName" column="real_name_"/>
- <result property="headUrl" column="avatar_"/>
- <result property="endClassTime" column="endClassTime"/>
- <result property="musicGroupId" column="musicGroupId"/>
- <result property="classGroupId" column="classGroupId"/>
- <result property="teachMode" column="teachMode"/>
- <result property="submitTime" column="submitTime"/>
- <result property="standardFlag" column="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
- <select id="findStudentHomeworkRecord" resultMap="StudentHomeworkRecordDto">
- SELECT
- sch.id_ student_course_homework_id_,
- sch.course_schedule_id_,
- cs.name_ course_name_,
- CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
- CONCAT(cs.class_date_,' ',cs.end_class_time_) endClassTime,
- cs.actual_teacher_id_,
- sch.status_,
- sch.submit_time_ as submitTime,
- sch.standard_flag_ as standardFlag,
- ch.expiry_date_,
- su.real_name_,
- su.avatar_,
- cs.music_group_id_ as musicGroupId,
- cs.class_group_id_ as classGroupId,
- cs.teach_mode_ as teachMode
- FROM
- student_course_homework sch
- LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
- LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
- WHERE sch.user_id_=#{userId} AND cs.pre_course_flag_ = 0
- AND DATE_FORMAT(class_date_, '%Y-%m')=DATE_FORMAT(#{classDate}, '%Y-%m')
- <if test="finishStatus != null">
- <if test="finishStatus == true">
- and sch.standard_flag_ in ('STANDARD','EXCELLENT')
- </if>
- <if test="finishStatus == false">
- and (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
- </if>
- </if>
- <if test="versionTag != null">
- and ch.version_tag_ = #{versionTag}
- </if>
- ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_) DESC
- <include refid="global.limit"/>
- </select>
- <select id="countStudentHomeworkRecord" resultType="int">
- SELECT COUNT(sch.id_)
- FROM student_course_homework sch
- LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
- WHERE sch.user_id_ = #{userId}
- AND DATE_FORMAT(class_date_, '%Y-%m') = DATE_FORMAT(#{classDate}, '%Y-%m')
- <if test="finishStatus != null">
- <if test="finishStatus == true">
- and sch.standard_flag_ in ('STANDARD','EXCELLENT')
- </if>
- <if test="finishStatus == false">
- and (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
- </if>
- </if>
- <if test="versionTag != null">
- and ch.version_tag_ = #{versionTag}
- </if>
- </select>
- <select id="findByCourses" resultMap="StudentCourseHomework">
- SELECT * FROM student_course_homework WHERE course_schedule_id_ IN
- <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
- #{courseId}
- </foreach>
- </select>
- <resultMap id="StudentServeCourseHomeworkDto" type="com.ym.mec.biz.dal.dto.StudentServeCourseHomeworkDto"
- extends="StudentCourseHomework">
- <result property="courseStartTime" column="course_start_time_"/>
- <result property="homeworkCreateTime" column="homework_create_time_"/>
- <result property="musicGroupId" column="music_group_id_"/>
- </resultMap>
- <select id="findStudentHomeworkWithCourseDateRange" resultMap="StudentServeCourseHomeworkDto">
- SELECT
- sch.*,
- DATE_FORMAT(sch.create_time_, '%Y-%m-%d') homework_create_time_,
- cs.class_date_ course_start_time_,
- cs.music_group_id_
- FROM
- student_course_homework sch
- LEFT JOIN course_schedule cs ON sch.course_schedule_id_ = cs.id_
- WHERE
- cs.class_date_ BETWEEN #{startDate} AND #{endDate}
- AND sch.user_id_ IN
- <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
- #{studentId}
- </foreach>
- </select>
- <select id="checkStudentHaveHomeworkInDateRange" resultType="java.lang.Integer">
- SELECT
- DISTINCT sch.user_id_
- FROM
- student_course_homework sch
- LEFT JOIN course_schedule cs ON sch.course_schedule_id_ = cs.id_
- WHERE
- cs.class_date_ BETWEEN #{startDate}
- AND #{endDate}
- AND sch.user_id_ IN
- <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
- #{studentId}
- </foreach>
- </select>
- <select id="queryReplied" resultType="java.util.Map">
- SELECT sch.course_homework_id_ AS 'key',COUNT(0) AS 'value'
- FROM student_course_homework sch
- WHERE sch.course_homework_id_ IN
- <foreach collection="homeWorkIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- AND sch.is_replied_ = 1
- GROUP BY sch.course_homework_id_
- </select>
- <sql id="queryAllCondition">
- <where>
- tenant_id_ = #{tenantId}
- <if test="courseScheduleId!=null">
- AND course_schedule_id_=#{courseScheduleId}
- </if>
- <if test="isReplied!=null">
- AND is_replied_=#{isReplied}
- </if>
- </where>
- </sql>
- <select id="queryAll" resultMap="StudentCourseHomework">
- SELECT * FROM student_course_homework
- <include refid="queryAllCondition"/>
- ORDER BY id_
- <include refid="global.limit"></include>
- </select>
- <select id="countAll" resultType="int">
- SELECT COUNT(*) FROM student_course_homework
- <include refid="queryAllCondition"/>
- </select>
- <delete id="delByCourseScheduleId">
- DELETE
- FROM student_course_homework
- WHERE course_schedule_id_ = #{courseScheduleId}
- </delete>
- <delete id="batchDelByCourseScheduleId">
- DELETE FROM student_course_homework WHERE course_schedule_id_ IN
- <foreach collection="courseScheduleIdList" item="courseScheduleId" open="(" close=")" separator=",">
- #{courseScheduleId}
- </foreach>
- </delete>
- <resultMap id="StudentVisitCourseHomeWorkDto" type="com.ym.mec.biz.dal.dto.StudentVisitCourseHomeWorkDto">
- <result column="groupType" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="groupId" property="groupId"/>
- <result column="courseName" property="courseName"/>
- <result column="createTime" property="createTime"/>
- <result column="teacherName" property="teacherName"/>
- <result column="content" property="content"/>
- <result column="status" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="isReplied" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="isView" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
- <select id="getStudentCourseHomeWorks" resultMap="StudentVisitCourseHomeWorkDto">
- SELECT sch.course_schedule_id_ courseScheduleId,
- cs.group_type_ groupType,
- cs.music_group_id_ groupId,
- cs.name_ courseName,
- sch.create_time_ createTime,
- t.real_name_ teacherName,
- ch.content_ content,
- sch.status_ status,
- sch.is_replied_ isReplied,
- sch.is_view_ isView
- FROM student_course_homework sch
- LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
- LEFT JOIN sys_user t ON t.id_ = cs.actual_teacher_id_
- <include refid="homeWorkCondition"/>
- ORDER BY sch.create_time_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="getStudentCourseHomeWorksCount" resultType="int">
- SELECT COUNT(*) FROM student_course_homework sch
- <include refid="homeWorkCondition"/>
- </select>
- <sql id="getEduCourseHomeworkListCondition">
- <where>
- mg.transaction_teacher_id_ = #{transactionTeacherId}
- AND mg.status_ = "PROGRESS"
- AND sr.music_group_status_='NORMAL'
- <if test="search != null and search != ''">
- AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.id_ = #{search})
- </if>
- <if test="startTime!=null">
- AND cs.class_date_ >= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
- </if>
- <if test="endTime!=null">
- AND cs.class_date_ <= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
- </if>
- </where>
- </sql>
- <select id="getEduCourseHomeworkList" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
- SELECT
- ch.id_ homeworkId,
- cs.id_ courseId,
- cs.name_ courseName,
- CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) courseStartTime,
- cs.actual_teacher_id_ teacherId,
- su.real_name_ teacherName,
- su.avatar_ teacherAvatar,
- COUNT( sch.user_id_ ) exceptStudentNum,
- SUM( sch.status_ ) submitStudentNum,
- SUM( sch.is_replied_ ) repliedStudentNum,
- sch.music_score_id_ musicScoreId
- FROM
- course_homework ch
- LEFT JOIN music_group mg ON mg.id_ = ch.music_group_id_
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
- LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
- LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
- <include refid="getEduCourseHomeworkListCondition" />
- GROUP BY ch.id_
- ORDER BY courseStartTime DESC
- <include refid="global.limit"></include>
- </select>
- <select id="countEduCourseHomeworkList" resultType="int">
- SELECT
- COUNT(DISTINCT cs.id_)
- FROM
- course_homework ch
- LEFT JOIN music_group mg ON mg.id_ = ch.music_group_id_
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
- LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
- LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
- <include refid="getEduCourseHomeworkListCondition" />
- </select>
- <select id="countHomeworkStudentInfoWithMusicGroup" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
- SELECT
- ch.music_group_id_ groupId,
- COUNT( sch.user_id_ ) exceptStudentNum,
- SUM( sch.status_ ) submitStudentNum,
- SUM( sch.is_replied_ ) repliedStudentNum
- FROM
- course_homework ch
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
- LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
- LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
- WHERE sr.music_group_status_='NORMAL'
- AND ch.music_group_id_ IN
- <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
- #{groupId}
- </foreach>
- <if test="startTime!=null">
- AND cs.class_date_ >= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
- </if>
- <if test="endTime!=null">
- AND cs.class_date_ <= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
- </if>
- GROUP BY ch.music_group_id_
- </select>
- <select id="countHomeworkSubjectStudentInfoWithMusicGroup" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
- SELECT
- sr.actual_subject_id_ subjectId,
- COUNT( sch.user_id_ ) exceptStudentNum,
- SUM( sch.status_ ) submitStudentNum,
- SUM( sch.is_replied_ ) repliedStudentNum
- FROM course_homework ch
- LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
- LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
- LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
- LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
- WHERE sr.music_group_status_='NORMAL'
- AND ch.music_group_id_ = #{groupId}
- <if test="startTime!=null">
- AND cs.class_date_ >= #{startTime}
- </if>
- <if test="endTime!=null">
- AND cs.class_date_ <= #{endTime}
- </if>
- GROUP BY sr.actual_subject_id_
- </select>
- <sql id="homeWorkCondition">
- <where>
- sch.tenant_id_ = #{tenantId}
- <if test="userId!=null">
- AND sch.user_id_=#{userId}
- </if>
- <if test="status!=null">
- AND sch.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="isReplied!=null">
- AND sch.is_replied_=#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="startTime != null">
- AND sch.create_time_ >=#{startTime}
- </if>
- <if test="endTime != null">
- <![CDATA[AND sch.create_time_<=#{endTime}
- ]]></if>
- </where>
- </sql>
- <select id="findByCourseScheduleIds" resultMap="StudentCourseHomework">
- select *
- from student_course_homework
- where course_schedule_id_ in
- <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
- #{courseScheduleId}
- </foreach>
- </select>
- <select id="findByStudentIdsAndCourseScheduleId"
- resultType="com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper$StudentLessonTrainingDetail">
- SELECT s.*,sms.name_ as musicScoreName,s2.name_ as subjectName from student_lesson_training_detail s
- left join sys_music_score sms on s.music_score_id_ = sms.id_
- left join subject s2 on s.subject_id_ = s2.id_
- where s.user_id_ in
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- and s.course_homework_id_ = #{courseHomeworkId}
- and s.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- order by s.id_
- </select>
- <select id="findStudentCourseHomeworkByCourse" resultMap="StudentCourseHomework">
- SELECT
- sch.*,
- su.username_,
- su.avatar_,
- su.phone_
- FROM
- student_course_homework sch
- LEFT JOIN sys_user su ON sch.user_id_=su.id_
- left join student s on s.user_id_ = su.id_
- <where>
- sch.course_schedule_id_=#{query.courseScheduleId}
- <if test="query.subjectId != null">
- and s.subject_id_list_ = #{query.subjectId}
- </if>
- </where>
- </select>
- <select id="queryNotSuccessHomeworkList" resultType="int">
- SELECT
- count(sch.id_)
- FROM
- student_course_homework sch
- left join course_homework ch on ch.id_ = sch.course_homework_id_
- WHERE
- sch.user_id_ = #{userId}
- AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
- and ch.expiry_date_ >= now()
- and ch.version_tag_ = 'v2'
- </select>
- <select id="getHomeworkByUserIdAndCourseHomeworkId" resultMap="StudentCourseHomework">
- SELECT
- sch.*
- FROM
- student_course_homework sch
- WHERE
- sch.user_id_ = #{userId}
- AND sch.course_homework_id_ = #{courseHomeworkId}
- </select>
- <select id="queryNotSuccessUserIdByHomeworkIds" resultType="java.lang.Integer">
- SELECT
- distinct sch.user_id_
- FROM
- student_course_homework sch
- left join course_homework ch on ch.id_ = sch.course_homework_id_
- WHERE
- sch.course_homework_id_ in
- <foreach collection="homeworkIds" item="homeworkId" open="(" close=")" separator=",">
- #{homeworkId}
- </foreach>
- AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
- and ch.version_tag_ = 'v2'
- </select>
- <select id="queryNotSuccessExtraHomeworkList2" resultType="int">
- SELECT
- count(ee.id_)
- FROM
- extracurricular_exercises ee
- left join extracurricular_exercises_reply eer on eer.extracurricular_exercises_id_ = ee.id_
- WHERE
- eer.user_id_ = #{userId}
- AND (eer.standard_flag_ not in ('STANDARD','EXCELLENT') or eer.standard_flag_ is null)
- and ee.expire_date_ >= now()
- and ee.version_tag_ = 'v2'
- </select>
- </mapper>
|