ClassGroupStudentMapperMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.ClassGroupStudentMapper" id="ClassGroupStudentMapper">
  9. <result column="id_" property="id"/>
  10. <result column="class_group_id_" property="classGroupId"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="create_time_" property="createTime"/>
  13. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  14. </resultMap>
  15. <!-- 根据主键查询一条记录 -->
  16. <select id="get" resultMap="ClassGroupStudentMapper">
  17. SELECT * FROM class_group_student_mapper WHERE id_ = #{id}
  18. </select>
  19. <!-- 全查询 -->
  20. <select id="findAll" resultMap="ClassGroupStudentMapper">
  21. SELECT * FROM class_group_student_mapper ORDER BY id_
  22. </select>
  23. <!-- 向数据库增加一条记录 -->
  24. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ClassGroupStudentMapper" useGeneratedKeys="true"
  25. keyColumn="id" keyProperty="id">
  26. INSERT INTO class_group_student_mapper (id_,class_group_id_,user_id_,status_,create_time_)
  27. VALUES(#{id},#{classGroupId},#{userId},#{status},now())
  28. </insert>
  29. <!-- 根据主键查询一条记录 -->
  30. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ClassGroupStudentMapper">
  31. UPDATE class_group_student_mapper
  32. <set>
  33. <if test="userId != null">
  34. user_id_ = #{userId},
  35. </if>
  36. <if test="classGroupId != null">
  37. class_group_id_ = #{classGroupId},
  38. </if>
  39. <if test="status != null">
  40. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  41. </if>
  42. </set>
  43. WHERE id_ = #{id}
  44. </update>
  45. <!-- 根据主键删除一条记录 -->
  46. <delete id="delete">
  47. DELETE FROM class_group_student_mapper WHERE id_ = #{id}
  48. </delete>
  49. <delete id="deleteByClassId">
  50. DELETE FROM class_group_student_mapper WHERE class_group_id_ = #{classGroupId}
  51. </delete>
  52. <!-- 分页查询 -->
  53. <select id="queryPage" resultMap="ClassGroupStudentMapper" parameterType="map">
  54. SELECT * FROM class_group_student_mapper ORDER BY id_
  55. <include refid="global.limit"/>
  56. </select>
  57. <!-- 查询当前表的总记录数 -->
  58. <select id="queryCount" resultType="int">
  59. SELECT COUNT(*) FROM class_group_student_mapper
  60. </select>
  61. <!-- 班级学生批量插入 -->
  62. <insert id="classGroupStudentsInsert" parameterType="java.util.List">
  63. INSERT INTO class_group_student_mapper (class_group_id_,user_id_,status_,create_time_)
  64. VALUES
  65. <foreach collection="classGroupStudentMapperList" item="item" index="index" separator=",">
  66. (#{item.classGroupId},#{item.userId},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now())
  67. </foreach>
  68. </insert>
  69. <select id="query" resultMap="ClassGroupStudentMapper" parameterType="map">
  70. SELECT * FROM class_group_student_mapper where class_group_id_ = #{classGroupId} and user_id_ = #{userId} AND status_ IN ('NORMAL','LEAVE')
  71. </select>
  72. <select id="findStudentNumByClassGroupId" resultType="string">
  73. SELECT
  74. su.username_
  75. FROM
  76. class_group_student_mapper cgsm
  77. LEFT JOIN sys_user su ON cgsm.user_id_=su.id_
  78. WHERE cgsm.class_group_id_=#{classGroupId}
  79. </select>
  80. <resultMap id="teacherClassStudentDto" type="com.ym.mec.biz.dal.dto.TeacherClassStudentDto">
  81. <result property="userId" column="user_id_"/>
  82. <result property="userName" column="username_"/>
  83. <result property="avatar" column="avatar_"/>
  84. <result property="continuousAbsenteeismTimes" column="continuous_absenteeism_times_"/>
  85. </resultMap>
  86. <select id="findClassStudent" resultMap="teacherClassStudentDto">
  87. SELECT
  88. su.id_ user_id_,
  89. su.username_,
  90. su.avatar_,
  91. mgsf.continuous_absenteeism_times_
  92. FROM
  93. class_group_student_mapper cgsm
  94. LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
  95. LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
  96. LEFT JOIN music_group_student_fee_ mgsf ON cg.music_group_id_=mgsf.music_group_id_
  97. WHERE
  98. cgsm.class_group_id_ = #{classGroupId}
  99. ORDER BY su.id_
  100. <include refid="global.limit"/>
  101. </select>
  102. <select id="findClassStudentNum" resultType="int">
  103. SELECT
  104. COUNT(*)
  105. FROM
  106. class_group_student_mapper cgsm
  107. WHERE
  108. cgsm.class_group_id_ = #{classGroupId}
  109. </select>
  110. <select id="findStudentByCourse" resultMap="com.ym.mec.biz.dal.dao.StudentAttendanceDao.studentAttendanceViewUtilEntity">
  111. SELECT
  112. su.id_ student_id_,
  113. su.username_,
  114. su.avatar_,
  115. IF(sa.status_ IS NULL,'TRUANT',sa.status_) status_
  116. FROM
  117. course_schedule_student_payment cssp
  118. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  119. LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_
  120. AND cssp.user_id_ = sa.user_id_
  121. WHERE
  122. cssp.course_schedule_id_ =#{courseScheduleId}
  123. </select>
  124. <update id="deleteStudentByMusicGroupId" parameterType="map">
  125. update class_group_student_mapper set status_ = 'QUIT' where class_group_id_ in (select id_ from class_group where music_group_id_ = #{musicGroupId}) and user_id_ = #{userId}
  126. </update>
  127. <update id="deleteStudentByClassGroupId">
  128. update class_group_student_mapper set status_ = 'QUIT' WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
  129. </update>
  130. <select id="findClassStudentMapperByUserIdAndClassGroupId" resultMap="ClassGroupStudentMapper">
  131. SELECT * FROM class_group_student_mapper WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId} AND status_ = 'NORMAL'
  132. </select>
  133. <select id="findByClassGroups" resultMap="ClassGroupStudentMapper">
  134. SELECT * FROM class_group_student_mapper WHERE class_group_id_ IN
  135. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  136. #{classGroupId}
  137. </foreach>
  138. </select>
  139. </mapper>