courseScheduleStudentMusicScoreMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.CourseScheduleStudentMusicScoreDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore" id="CourseScheduleStudentMusicScore">
  9. <result column="id_" property="id"/>
  10. <result column="course_schedule_id_" property="courseScheduleId"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="user_type_" property="userType"/>
  13. <result column="down_status_" property="downStatus"/>
  14. <result column="music_score_accompaniment_id_" property="musicScoreAccompanimentId"/>
  15. <result column="play_status_" property="playStatus"/>
  16. <result column="accompaniment_play_status_" property="accompanimentPlayStatus"/>
  17. <result column="speed_" property="speed"/>
  18. <result column="mp3_url_" property="mp3Url"/>
  19. <result column="url_" property="url"/>
  20. <result column="music_score_name_" property="musicScoreName"/>
  21. <result column="create_time_" property="createTime"/>
  22. <result column="update_time_" property="updateTime"/>
  23. <result column="tenant_id_" property="tenantId" />
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="CourseScheduleStudentMusicScore">
  27. SELECT * FROM course_schedule_student_music_score WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="CourseScheduleStudentMusicScore">
  31. SELECT * FROM course_schedule_student_music_score where tenant_id_ = #{tenantId} ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore" useGeneratedKeys="true" keyColumn="id"
  35. keyProperty="id">
  36. INSERT INTO course_schedule_student_music_score (course_schedule_id_,user_id_,user_type_,down_status_,music_score_accompaniment_id_,play_status_,accompaniment_play_status_,speed_,create_time_,update_time_,tenant_id_)
  37. VALUES(#{courseScheduleId},#{userId},#{userType},#{downStatus},#{musicScoreAccompanimentId},#{playStatus},#{accompanimentPlayStatus},#{speed},now(),now(),#{tenantId})
  38. </insert>
  39. <insert id="batchInsert">
  40. INSERT INTO course_schedule_student_music_score (course_schedule_id_,user_id_,user_type_,down_status_,music_score_accompaniment_id_,play_status_,accompaniment_play_status_,speed_,create_time_,update_time_,tenant_id_)
  41. VALUE
  42. <foreach collection="scheduleStudentMusicScores" item="item" separator=",">
  43. (#{item.courseScheduleId},#{item.userId},#{item.userType},#{item.downStatus},#{item.musicScoreAccompanimentId},#{item.playStatus},#{item.accompanimentPlayStatus},#{item.speed},now(),now(),#{item.tenantId})
  44. </foreach>
  45. </insert>
  46. <!-- 根据主键查询一条记录 -->
  47. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore">
  48. UPDATE course_schedule_student_music_score
  49. <set>
  50. <if test="accompanimentPlayStatus != null">
  51. accompaniment_play_status_ = #{accompanimentPlayStatus},
  52. </if>
  53. <if test="downStatus != null">
  54. down_status_ = #{downStatus},
  55. </if>
  56. <if test="playStatus != null">
  57. play_status_ = #{playStatus},
  58. </if>
  59. <if test="speed != null">
  60. speed_ = #{speed},
  61. </if>
  62. update_time_ = NOW()
  63. </set>
  64. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  65. </update>
  66. <update id="closePlayStatus">
  67. UPDATE course_schedule_student_music_score SET play_status_ = 0,accompaniment_play_status_ = 0,update_time_ = NOW()
  68. WHERE course_schedule_id_ = #{scheduleId}
  69. <if test="musicScoreAccompanimentId != null">
  70. AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
  71. </if>
  72. <if test="userId != null">
  73. AND user_id_ = #{userId}
  74. </if>
  75. </update>
  76. <update id="openPlayStatus">
  77. UPDATE course_schedule_student_music_score SET play_status_ = 1,update_time_ = NOW()
  78. WHERE course_schedule_id_ = #{scheduleId}
  79. AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
  80. <if test="userId != null">
  81. AND user_id_ = #{userId}
  82. </if>
  83. </update>
  84. <update id="openAccompanimentPlayStatus">
  85. UPDATE course_schedule_student_music_score SET accompaniment_play_status_ = 1,update_time_ = NOW()
  86. WHERE course_schedule_id_ = #{scheduleId} AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
  87. <if test="userId != null">
  88. AND user_id_ = #{userId}
  89. </if>
  90. </update>
  91. <!-- 根据主键删除一条记录 -->
  92. <delete id="delete">
  93. DELETE FROM course_schedule_student_music_score WHERE id_ = #{id}
  94. </delete>
  95. <!-- 分页查询 -->
  96. <select id="queryPage" resultMap="CourseScheduleStudentMusicScore" parameterType="map">
  97. SELECT * FROM course_schedule_student_music_score where tenant_id_ = #{tenantId}
  98. <include refid="global.limit" />
  99. </select>
  100. <!-- 查询当前表的总记录数 -->
  101. <select id="queryCount" resultType="int">
  102. SELECT COUNT(*) FROM course_schedule_student_music_score where tenant_id_ = #{tenantId}
  103. </select>
  104. <select id="queryByScoreIdAndCourseId"
  105. resultMap="CourseScheduleStudentMusicScore">
  106. SELECT cssm.*,
  107. CASE WHEN smsa.metronome_mp3_url_ IS NULL OR smsa.metronome_mp3_url_ = '' THEN smsa.mp3_url_ ELSE smsa.metronome_mp3_url_ END url_,
  108. sms.url_ mp3_url_,sms.name_ music_score_name_
  109. FROM course_schedule_student_music_score cssm
  110. LEFT JOIN sys_music_score_accompaniment smsa ON cssm.music_score_accompaniment_id_ = smsa.id_
  111. LEFT JOIN sys_music_score sms ON sms.id_ = smsa.exam_song_id_
  112. <where>
  113. <if test="courseId != null">
  114. AND cssm.course_schedule_id_ = #{courseId}
  115. </if>
  116. <if test="musicScoreAccompanimentId != null">
  117. AND cssm.music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
  118. </if>
  119. <if test="userType != null">
  120. AND cssm.user_type_ = #{userType}
  121. </if>
  122. <if test="userId != null">
  123. AND cssm.user_id_ = #{userId}
  124. </if>
  125. <if test="downStatus != null">
  126. AND cssm.down_status_ = #{downStatus}
  127. </if>
  128. </where>
  129. </select>
  130. </mapper>