Parcourir la source

酷乐秀优化

zouxuan il y a 4 mois
Parent
commit
6601036acd

+ 27 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/SubjectController.java

@@ -13,11 +13,14 @@ import com.yonge.toolset.base.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.teacher:}/subject")
 @Api(tags = "声部服务")
@@ -66,4 +69,28 @@ public class SubjectController extends BaseController {
 		subjectService.convertSubSubject(subjectSelect);
         return succeed(subjectSelect);
     }
+
+	@ApiOperation(value = "获取子集声部")
+	@GetMapping("/subSubjectSelect")
+    public HttpResponseResult<List<Subject>> subSubjectSelect(String type){
+		String userExtSubjectIds = null;
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser != null && sysUser.getId() != null) {
+        	Teacher teacher = teacherService.getById(sysUser.getId());
+        	if(teacher != null && teacher.getDefaultSubject() != null){
+        		userExtSubjectIds = teacher.getDefaultSubject().toString();
+        	}
+        }
+        List<Subject> subjectSelect = subjectService.subjectSelect(type, userExtSubjectIds);
+		//获取子集声部
+		if(CollectionUtils.isNotEmpty(subjectSelect)){
+			List<Subject> result = new ArrayList<>();
+			subjectSelect.stream()
+					.filter(e->CollectionUtils.isNotEmpty(e.getSubjects()))
+					.forEach(e->result.addAll(e.getSubjects()));
+			return succeed(result);
+		}
+        return succeed(subjectSelect);
+    }
 }