|
@@ -2,23 +2,15 @@ package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.dayaedu.cbs.common.enums.school.ECourseType;
|
|
|
+import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.yonge.cooleshow.admin.io.request.TenantAlbumVo;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantAlbum;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantAlbumRef;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.MusicTagService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SubjectService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantAlbumRefService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantAlbumService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
@@ -33,18 +25,9 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -79,6 +62,9 @@ public class TenantAlbumController {
|
|
|
@Autowired
|
|
|
private MusicTagService musicTagService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CoursewareFeignService coursewareFeignService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询分页
|
|
|
*
|
|
@@ -128,16 +114,34 @@ public class TenantAlbumController {
|
|
|
tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
|
|
|
|
|
|
|
|
|
- List<Long> musicSheetIdlist = tenantAlbumMusics.stream().map(next -> next.getMusicSheetId()).distinct().collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<Long> musicSheetIdlist = tenantAlbumMusics.stream()
|
|
|
+ .filter(o ->o.getSubjectType() !=SubjectTypeEnum.COURSEWARE)
|
|
|
+ .map(TenantAlbumMusic::getMusicSheetId).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 过滤出课件
|
|
|
+ List<Long> coursewareList = tenantAlbumMusics.stream()
|
|
|
+ .filter(o -> o.getSubjectType() == SubjectTypeEnum.COURSEWARE)
|
|
|
+ .map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long,CbsLessonCoursewareWrapper.Entity> coursewareDtoMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(coursewareList)) {
|
|
|
+ List<CbsLessonCoursewareWrapper.Entity> entities = coursewareFeignService
|
|
|
+ .lessonCoursewareLambdaQuery(CbsLessonCoursewareWrapper.LambdaQuery.builder().ids(coursewareList).build()).feignData();
|
|
|
+ coursewareDtoMap.putAll(entities.stream().collect(Collectors.toMap(CbsLessonCoursewareWrapper.Entity::getId, Function.identity())));
|
|
|
+ }
|
|
|
|
|
|
- StudentMusicSheetSearch search = new StudentMusicSheetSearch();
|
|
|
- search.setMusicSheetIdlist(musicSheetIdlist);
|
|
|
- search.setPage(1);
|
|
|
- search.setRows(9999);
|
|
|
- IPage<MusicSheetVo> records = musicSheetService.selectStudentPage(PageUtil.getPage(search), search, null);
|
|
|
- Map<Long, MusicSheetVo> idMsMap = records.getRecords().stream()
|
|
|
- .collect(Collectors.toMap(MusicSheet::getId, Function.identity()));
|
|
|
+ Map<Long, MusicSheetVo> idMsMap = new HashMap<>();
|
|
|
+ Map<Integer,Subject> subjectMap = subjectService.getAllMap();
|
|
|
+ Map<Long, MusicTag> musicTagMap = musicTagService.getAllMap();
|
|
|
+ if (CollectionUtils.isNotEmpty(musicSheetIdlist)) {
|
|
|
+ StudentMusicSheetSearch search = new StudentMusicSheetSearch();
|
|
|
+ search.setMusicSheetIdlist(musicSheetIdlist);
|
|
|
+ search.setPage(1);
|
|
|
+ search.setRows(9999);
|
|
|
+ IPage<MusicSheetVo> records = musicSheetService.selectStudentPage(PageUtil.getPage(search), search, null);
|
|
|
+ idMsMap.putAll(records.getRecords().stream()
|
|
|
+ .collect(Collectors.toMap(MusicSheet::getId, Function.identity())));
|
|
|
+ }
|
|
|
List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
|
|
|
groupByType.forEach((key, value) -> {
|
|
|
value.sort(Comparator.comparing(TenantAlbumMusic::getSortNumber));
|
|
@@ -148,40 +152,56 @@ public class TenantAlbumController {
|
|
|
TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
|
|
|
BeanUtils.copyProperties(next, tenantAlbumSheet);
|
|
|
Long musicSheetId = tenantAlbumSheet.getMusicSheetId();
|
|
|
- MusicSheetVo musicSheet = idMsMap.getOrDefault(musicSheetId, new MusicSheetVo());
|
|
|
- tenantAlbumSheet.setMusicSheetName(musicSheet.getMusicSheetName());
|
|
|
- tenantAlbumSheet.setMusicTag(musicSheet.getMusicTag());
|
|
|
- tenantAlbumSheet.setComposer(musicSheet.getComposer());
|
|
|
- tenantAlbumSheet.setMusicSubject(musicSheet.getMusicSubject());
|
|
|
- return tenantAlbumSheet;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- tenantAlbumSheets.stream().forEach(t->{
|
|
|
- String musicSubject = t.getMusicSubject();
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(musicSubject)){
|
|
|
- //设置对应声部名称
|
|
|
- List<Subject> subject = subjectService.findBySubjectByIdList(musicSubject);
|
|
|
- if (CollectionUtils.isNotEmpty(subject)) {
|
|
|
- t.setMusicSubjectName(subject.get(0).getName());
|
|
|
- }
|
|
|
- }
|
|
|
+ switch (key) {
|
|
|
+ case COURSEWARE:
|
|
|
+ CbsLessonCoursewareWrapper.Entity entity = coursewareDtoMap.get(musicSheetId);
|
|
|
+ if (entity != null) {
|
|
|
+ tenantAlbumSheet.setMusicSheetName(entity.getName());
|
|
|
+ tenantAlbumSheet.setTitleImg(entity.getCoverImg());
|
|
|
+ tenantAlbumSheet.setMusicSubject(entity.getCourseTypeCode());
|
|
|
+ tenantAlbumSheet.setMusicSubjectName(ECourseType.valueOf(entity.getCourseTypeCode()).getName());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MUSIC:
|
|
|
+ case SUBJECT:
|
|
|
+ case ENSEMBLE:
|
|
|
+ {
|
|
|
+ MusicSheetVo musicSheet = idMsMap.getOrDefault(musicSheetId, new MusicSheetVo());
|
|
|
+ tenantAlbumSheet.setMusicSheetName(musicSheet.getMusicSheetName());
|
|
|
+ tenantAlbumSheet.setMusicTag(musicSheet.getMusicTag());
|
|
|
+ tenantAlbumSheet.setComposer(musicSheet.getComposer());
|
|
|
+ tenantAlbumSheet.setMusicSubject(musicSheet.getMusicSubject());
|
|
|
+
|
|
|
+ //设置对应标签名称
|
|
|
+ String musicTag = tenantAlbumSheet.getMusicTag();
|
|
|
+ if (StringUtils.isNotBlank(musicTag)){
|
|
|
+ String[] split = musicTag.split(",");
|
|
|
+ List<String> tagNames = Arrays.stream(split).map(Long::parseLong).map(musicTagMap::get)
|
|
|
+ .filter(Objects::nonNull).map(MusicTag::getName).collect(Collectors.toList());
|
|
|
+ tenantAlbumSheet.setMusicTagName(String.join(",", tagNames));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tenantAlbumSheet.getMusicSubject())){
|
|
|
+ //设置对应声部名称
|
|
|
+ String subjectName = Arrays.stream(tenantAlbumSheet.getMusicSubject().split(","))
|
|
|
+ .map(Integer::parseInt).map(o -> {
|
|
|
+
|
|
|
+ Subject subject = subjectMap.get(o);
|
|
|
+ if (subject != null) {
|
|
|
+ return subject.getName();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.joining(","));
|
|
|
+ tenantAlbumSheet.setMusicSubjectName(subjectName);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- //设置对应标签名称
|
|
|
- String musicTag = t.getMusicTag();
|
|
|
- if (StringUtils.isNotBlank(musicTag)){
|
|
|
- String[] split = musicTag.split(",");
|
|
|
- for (String s : split) {
|
|
|
- List<Long> list = new ArrayList<>();
|
|
|
- list.add(Long.parseLong(s));
|
|
|
- String tagName = musicTagService.getMusicTagNames(list);
|
|
|
- t.setMusicTagName(tagName);
|
|
|
}
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
- tenantAlbumSheets =tenantAlbumSheets.stream().filter(o -> o.getMusicSheetName() != null).collect(Collectors.toList());
|
|
|
-
|
|
|
+ return tenantAlbumSheet;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
sheetData.setTenantAlbumSheetList(tenantAlbumSheets);
|
|
|
musicSheetData.add(sheetData);
|
|
@@ -199,17 +219,13 @@ public class TenantAlbumController {
|
|
|
@ApiOperation(value = "新增专辑", notes = "新增专辑")
|
|
|
@PreAuthorize("@pcs.hasPermissions('tenantAlbum/save')")
|
|
|
public HttpResponseResult<Boolean> save(@Validated @RequestBody TenantAlbumVo.TenantAlbum album) {
|
|
|
- //判断当前机构是否已经绑定机构专辑
|
|
|
- List<TenantAlbumRef> list = tenantAlbumRefService.lambdaQuery()
|
|
|
- .eq(TenantAlbumRef::getTenantId, album.getTenantId())
|
|
|
- .list();
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- throw new BizException("当前机构已有专辑");
|
|
|
- }
|
|
|
|
|
|
// 检查曲目重复
|
|
|
if (CollectionUtils.isNotEmpty(album.getMusicSheetData())) {
|
|
|
- List<Long> musicIds = album.getMusicSheetData().stream().flatMap(o -> o.getMusicSheetList().stream().map(m -> m.getId())).collect(Collectors.toList());
|
|
|
+ List<Long> musicIds = album.getMusicSheetData().stream()
|
|
|
+ .filter(o ->o.getSubjectType() !=SubjectTypeEnum.COURSEWARE)
|
|
|
+ .flatMap(o -> o.getMusicSheetList().stream().map(TenantAlbumVo.MusicObject::getId))
|
|
|
+ .collect(Collectors.toList());
|
|
|
Set<Long> musicSet = new HashSet<>(musicIds);
|
|
|
if (musicSet.size() < musicIds.size()) {
|
|
|
throw new BizException("不能添加相同的曲目");
|
|
@@ -220,7 +236,6 @@ public class TenantAlbumController {
|
|
|
List<TenantAlbumVo.MusicSheetData> musicSheetData = album.getMusicSheetData();
|
|
|
|
|
|
List<TenantAlbumWrapper.MusicSheetData> musicSheetDataList = musicSheetData.stream().map(next ->{
|
|
|
- //TenantAlbumWrapper.MusicSheetData sheetData =new TenantAlbumWrapper.MusicSheetData();
|
|
|
TenantAlbumWrapper.MusicSheetData sheetData =new TenantAlbumWrapper.MusicSheetData();
|
|
|
|
|
|
List<TenantAlbumVo.MusicObject> musicSheetList = next.getMusicSheetList();
|
|
@@ -244,19 +259,12 @@ public class TenantAlbumController {
|
|
|
@PreAuthorize("@pcs.hasPermissions('tenantAlbum/update')")
|
|
|
public HttpResponseResult<Boolean> update( @RequestBody TenantAlbumVo.TenantAlbum album) {
|
|
|
|
|
|
- //判断当前机构是否已经绑定机构专辑
|
|
|
- List<TenantAlbumRef> list = tenantAlbumRefService.lambdaQuery()
|
|
|
- .eq(TenantAlbumRef::getTenantId, album.getTenantId())
|
|
|
- .ne(TenantAlbumRef::getTenantAlbumId, album.getId())
|
|
|
- .list();
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- throw new BizException("当前机构已有专辑");
|
|
|
- }
|
|
|
-
|
|
|
// 检查曲目重复
|
|
|
if (CollectionUtils.isNotEmpty(album.getMusicSheetData())) {
|
|
|
- List<Long> musicIds = album.getMusicSheetData().stream().flatMap(o -> o.getMusicSheetList()
|
|
|
- .stream().map(TenantAlbumVo.MusicObject::getId)).collect(Collectors.toList());
|
|
|
+ List<Long> musicIds = album.getMusicSheetData().stream()
|
|
|
+ .filter(o -> o.getSubjectType() != SubjectTypeEnum.COURSEWARE)
|
|
|
+ .flatMap(o -> o.getMusicSheetList().stream().map(TenantAlbumVo.MusicObject::getId))
|
|
|
+ .collect(Collectors.toList());
|
|
|
Set<Long> musicSet = new HashSet<>(musicIds);
|
|
|
if (musicSet.size() < musicIds.size()) {
|
|
|
throw new BizException("不能添加相同的曲目");
|
|
@@ -267,7 +275,6 @@ public class TenantAlbumController {
|
|
|
List<TenantAlbumVo.MusicSheetData> musicSheetData = album.getMusicSheetData();
|
|
|
|
|
|
List<TenantAlbumWrapper.MusicSheetData> musicSheetDataList = musicSheetData.stream().map(next ->{
|
|
|
- //TenantAlbumWrapper.MusicSheetData sheetData =new TenantAlbumWrapper.MusicSheetData();
|
|
|
TenantAlbumWrapper.MusicSheetData sheetData =new TenantAlbumWrapper.MusicSheetData();
|
|
|
|
|
|
List<TenantAlbumVo.MusicObject> musicSheetList = next.getMusicSheetList();
|
|
@@ -289,10 +296,7 @@ public class TenantAlbumController {
|
|
|
@ApiOperation(value = "启用/冻结", notes = "启用/冻结")
|
|
|
@PreAuthorize("@pcs.hasPermissions('tenantAlbum/updateStatus')")
|
|
|
public HttpResponseResult<Boolean> updateStatus(@Validated @RequestBody TenantAlbumVo.UpdateStatus status) {
|
|
|
- tenantAlbumService.lambdaUpdate()
|
|
|
- .set(TenantAlbum::getStatus, status.getStatus())
|
|
|
- .eq(TenantAlbum::getId, status.getId())
|
|
|
- .update();
|
|
|
+ tenantAlbumService.updateStatus(status.getId(), status.getStatus());
|
|
|
return HttpResponseResult.succeed();
|
|
|
}
|
|
|
|