浏览代码

网络教室曲库

zouxuan 4 年之前
父节点
当前提交
eb5e9a5152

+ 5 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -301,12 +301,12 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     List<Map<Integer, String>> queryMidiByUserIdsAndCourseId(@Param("userIds") Set<String> userIds, @Param("courseScheduleId") String courseScheduleId);
 
     /**
-     * 获取用户的节拍器信息
+     * 获取用户的曲目下载信息
      * @param userIds
      * @param courseScheduleId
      * @return
      */
-    List<Map<Integer, Integer>> queryExamSongByUserIdsAndCourseId(@Param("userIds") Set<String> userIds, @Param("courseScheduleId") String courseScheduleId);
+    List<Map<Integer, String>> queryExamSongByUserIdsAndCourseId(@Param("userIds") Set<String> userIds, @Param("courseScheduleId") String courseScheduleId);
 
     /**
      * 获取单个用户的midi
@@ -349,11 +349,11 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     int countAll(Map<String, Object> params);
 
     /**
-     * 修改学员曲目下载状态
+     * 修改学员曲目下载信息
      * @author zouxuan
      * @param roomId
      */
-    void adjustExamSong(@Param("roomId") Long roomId, @Param("userId") Integer userId, @Param("status") Integer status);
+    void adjustExamSong(@Param("roomId") Long roomId, @Param("userId") Integer userId, @Param("examSongJson") String examSongJson);
 
     /**
      * 获取学员的曲目下载状态
@@ -362,6 +362,6 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @param userId
      * @return
      */
-    Boolean getExamSongDownloadStatus(@Param("roomId") Long roomId,
+    String getExamSongDownloadStatus(@Param("roomId") Long roomId,
                                       @Param("userId") String userId);
 }

+ 5 - 5
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -150,8 +150,8 @@
 	<update id="adjustExamSong">
 		UPDATE course_schedule_student_payment
 		<set>
-			<if test="status != null">
-				exam_song_download_status_ = #{status}
+			<if test="examSongJson != null">
+				exam_song_download_json_ = #{examSongJson}
 			</if>
 		</set>
 		WHERE course_schedule_id_ = #{roomId}
@@ -159,8 +159,8 @@
 			AND user_id_ = #{userId}
 		</if>
 	</update>
-	<select id="getExamSongDownloadStatus" resultType="boolean">
-		SELECT CASE WHEN exam_song_download_status_ IS NULL THEN 0 ELSE exam_song_download_status_ END
+	<select id="getExamSongDownloadStatus" resultType="String">
+		SELECT exam_song_download_json_
 		FROM course_schedule_student_payment
 		WHERE course_schedule_id_ = #{roomId}
 		<if test="userId != null">
@@ -483,7 +483,7 @@
 		AND cssp.course_schedule_id_ = #{courseScheduleId}
 	</select>
 	<select id="queryExamSongByUserIdsAndCourseId" resultType="java.util.Map">
-		SELECT user_id_ 'key',CASE WHEN exam_song_download_status_ IS NULL THEN 0 ELSE exam_song_download_status_ END 'value' FROM course_schedule_student_payment
+		SELECT user_id_ 'key',CASE WHEN exam_song_download_json_ IS NULL THEN '' ELSE exam_song_download_json_ END 'value' FROM course_schedule_student_payment
 		WHERE user_id_ IN
 		<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
 			#{userId}

+ 2 - 2
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -151,8 +151,8 @@ public class RoomController{
     }
 
     @RequestMapping(value = "adjustExamSong", method = RequestMethod.POST)
-    public Object adjustExamSong(Long roomId,Integer status) throws Exception {
-        roomService.adjustExamSong(roomId,status);
+    public Object adjustExamSong(Long roomId,Integer status,Integer examSongId) throws Exception {
+        roomService.adjustExamSong(roomId,status,examSongId);
         return new BaseResponse<>();
     }
 

+ 26 - 27
mec-im/src/main/java/com/ym/pojo/ExamSongDownloadData.java

@@ -1,41 +1,40 @@
 package com.ym.pojo;
 
-import lombok.Data;
-
-@Data
 public class ExamSongDownloadData {
-	private Boolean examSongDownloadOn;
-	private String roomId;
-	private String userId;
-	private String ticket;
+	private Integer status;
+	private String url;
+	private String songName;
 
-	public Boolean getExamSongDownloadOn() {
-		return examSongDownloadOn;
+	public Integer getStatus() {
+		return status;
 	}
 
-	public void setExamSongDownloadOn(Boolean examSongDownloadOn) {
-		this.examSongDownloadOn = examSongDownloadOn;
+	public void setStatus(Integer status) {
+		this.status = status;
 	}
 
-	public String getRoomId() {
-		return roomId;
-	}
-	public void setRoomId(String roomId) {
-		this.roomId = roomId;
-	}
-	public String getUserId() {
-		return userId;
-	}
-	public void setUserId(String userId) {
-		this.userId = userId;
-	}
-	public String getTicket() {
-		return ticket;
+	public String getUrl() {
+		return url;
 	}
-	public void setTicket(String ticket) {
-		this.ticket = ticket;
+
+	public void setUrl(String url) {
+		this.url = url;
 	}
 
+	public String getSongName() {
+		return songName;
+	}
 
+	public void setSongName(String songName) {
+		this.songName = songName;
+	}
 
+	@Override
+	public String toString() {
+		return "{" +
+				"status=" + status +
+				", url='" + url + '\'' +
+				", songName='" + songName + '\'' +
+				'}';
+	}
 }

+ 2 - 2
mec-im/src/main/java/com/ym/pojo/RoomResult.java

@@ -34,7 +34,7 @@ public class RoomResult {
         boolean camera;
         boolean microphone;
         boolean handUpOn;
-        boolean examSongDownloadOn;
+        String examSongDownloadJson;
         CustomMessage playMidiJson;
     }
 
@@ -57,7 +57,7 @@ public class RoomResult {
             result.setHandUpOn(member.isHand());
             result.setHeadUrl(member.getHeadUrl());
             result.setPlayMidiJson(JSONObject.parseObject(midiMap.get(Integer.parseInt(member.getUid())),CustomMessage.class));
-            result.setExamSongDownloadOn(examSongMap.get(member.getRid())=="0"?false:true);
+            result.setExamSongDownloadJson(examSongMap.get(member.getRid()));
             members.add(result);
         }
     }

+ 20 - 5
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.service.Impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.common.ApiException;
 import com.ym.common.DisplayEnum;
@@ -201,7 +202,7 @@ public class RoomServiceImpl implements RoomService {
             display = "display://type=0?userId=" + userId + "?uri=";
         }else {
             //获取学员曲目下载状态
-            userResult.setExamSongDownloadOn(courseScheduleStudentPaymentDao.getExamSongDownloadStatus(courseId,userId));
+            userResult.setExamSongDownloadJson(courseScheduleStudentPaymentDao.getExamSongDownloadStatus(courseId,userId));
             Room room = roomDao.findByRid(roomId);
             if (room != null) {
                 display = room.getDisplay();
@@ -1290,22 +1291,36 @@ public class RoomServiceImpl implements RoomService {
         msg.setUrl(sysExamSong.getUrl());
         imHelper.publishMessage(authUser.getId().toString(), roomId.toString(), msg, 1);
         //学员曲目下载状态改为未下载
-        courseScheduleStudentPaymentDao.adjustExamSong(roomId,null,0);
+        ExamSongDownloadData json = new ExamSongDownloadData();
+        json.setSongName(sysExamSong.getName());
+        json.setUrl(sysExamSong.getUrl());
+        json.setStatus(0);
+        courseScheduleStudentPaymentDao.adjustExamSong(roomId,null, JSON.toJSONString(json));
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void adjustExamSong(Long roomId, Integer status) throws Exception {
-        if(roomId == null || status == null){
+    public void adjustExamSong(Long roomId, Integer status,Integer examSongId) throws Exception {
+        if(roomId == null || status == null || examSongId == null){
             throw new BizException("参数校验失败");
         }
         SysUser authUser = sysUserFeignService.queryUserInfo();
         CourseSchedule courseSchedule = courseScheduleDao.get(roomId);
-        courseScheduleStudentPaymentDao.adjustExamSong(roomId,authUser.getId(),status);
+
         //给老师发送学员曲目下载状态
         DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(DeviceTypeEnum.ExamSong.ordinal(), status==0?false:true);
         deviceResourceMessage.setUserId(courseSchedule.getActualTeacherId().toString());
         imHelper.publishMessage(authUser.getId().toString(), roomId.toString(), deviceResourceMessage, 1);
+
+        SysExamSong sysExamSong = sysExamSongDao.get(examSongId);
+        if(sysExamSong == null){
+            throw new BizException("曲目信息不存在");
+        }
+        ExamSongDownloadData msg = new ExamSongDownloadData();
+        msg.setSongName(sysExamSong.getName());
+        msg.setUrl(sysExamSong.getUrl());
+        msg.setStatus(status);
+        courseScheduleStudentPaymentDao.adjustExamSong(roomId,authUser.getId(),JSON.toJSONString(msg));
     }
 
     public void updateDisplay(String roomId, String senderId, String display, Integer isIncludeSender) throws Exception {

+ 1 - 1
mec-im/src/main/java/com/ym/service/RoomService.java

@@ -92,5 +92,5 @@ public interface RoomService {
      * @param roomId
      * @param status
      */
-    void adjustExamSong(Long roomId,Integer status) throws Exception;
+    void adjustExamSong(Long roomId,Integer status,Integer examSongId) throws Exception;
 }