浏览代码

乐迷,学生扩展声部,选择全部声部时,需要查询该学生所有扩展声部对应的曲子

zouxuan 8 月之前
父节点
当前提交
e5cd32a296
共有 1 个文件被更改,包括 29 次插入14 次删除
  1. 29 14
      mec-application/src/main/java/com/ym/mec/student/controller/SysMusicScoreController.java

+ 29 - 14
mec-application/src/main/java/com/ym/mec/student/controller/SysMusicScoreController.java

@@ -1,17 +1,16 @@
 package com.ym.mec.student.controller;
 
-import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.dal.wrapper.MusicSheetWrapper;
-import com.ym.mec.biz.service.SysMusicScoreAccompanimentService;
+import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.biz.service.SysMusicScoreService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -19,8 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.student:}/sysMusicScore")
 @Api(tags = "曲库")
@@ -33,7 +30,7 @@ public class SysMusicScoreController extends BaseController {
     @Resource
     private SysUserService sysUserService;
     @Resource
-    private SysMusicScoreAccompanimentService sysMusicScoreAccompanimentService;
+    private StudentService studentService;
     @ApiOperation(value = "分页查询")
     @GetMapping("/queryPage2")
     public Object queryPage2(SysExamSongQueryInfo queryInfo) {
@@ -43,22 +40,40 @@ public class SysMusicScoreController extends BaseController {
         queryInfo.setType("COMMON");
         queryInfo.setClientFlag(true);
         queryInfo.setClientType(ClientTypeEnum.SMART_PRACTICE);
-        if(queryInfo.getSubjectId() == null && StringUtils.isNotEmpty(queryInfo.getCategoriesId())){
-            List<Subject> subjects = sysMusicScoreAccompanimentService.querySubjectIds(Integer.parseInt(queryInfo.getCategoriesId()));
-            if(CollectionUtils.isNotEmpty(subjects)){
-                StringBuffer subjectIds = new StringBuffer();
-                for (Subject subject : subjects) {
+        if(queryInfo.getSubjectId() == null){
+            Student student = studentService.get(userId);
+            StringBuffer subjectIds = new StringBuffer();
+            if(StringUtils.isNotEmpty(student.getSubjectId())){
+                String[] split = student.getSubjectId().split(",");
+                for (String s : split) {
                     if(subjectIds.length() > 0){
                         subjectIds.append(",");
                     }
-                    if (subject.getId() == 5){
+                    if (s.equals("5")){
                         subjectIds.append("6");
-                    }else if(subject.getId() == 122){
+                    }else if(s.equals("122")){
                         subjectIds.append("122,121,113,23");
+                    }else {
+                        subjectIds.append(s);
                     }
                 }
-                queryInfo.setSubjectIds(subjectIds.toString());
             }
+            if(StringUtils.isNotEmpty(student.getExtSubjectIds())){
+                String[] split = student.getExtSubjectIds().split(",");
+                for (String s : split) {
+                    if(subjectIds.length() > 0){
+                        subjectIds.append(",");
+                    }
+                    if (s.equals("5")){
+                        subjectIds.append("6");
+                    }else if(s.equals("122")){
+                        subjectIds.append("122,121,113,23");
+                    }else {
+                        subjectIds.append(s);
+                    }
+                }
+            }
+            queryInfo.setSubjectIds(subjectIds.toString());
         }
         return succeed(sysMusicScoreService.queryMusicScorePageInfo(queryInfo));
     }