|
@@ -9,6 +9,7 @@ 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.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
|
|
@@ -85,135 +86,89 @@ public class TenantAlbumController {
|
|
|
* @param id 详情ID
|
|
|
* @return TenantAlbum
|
|
|
*/
|
|
|
- @PostMapping("/detail")
|
|
|
+ @PostMapping("/detailInfo")
|
|
|
@ApiOperation(value = "查询详情", notes = "detail")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
|
|
|
- public HttpResponseResult<TenantAlbumWrapper.TenantAlbum> detail(@RequestParam("id") Long id) {
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detailInfo')")
|
|
|
+ public HttpResponseResult<List<TenantAlbumWrapper.TenantAlbumSheet>> detailInfo(@RequestParam("id") Long id,@RequestParam("subjectType") String subjectType) {
|
|
|
TenantAlbum tenantAlbum = tenantAlbumService.detail(id);
|
|
|
if (tenantAlbum == null) {
|
|
|
throw new BizException("专辑信息不存在");
|
|
|
}
|
|
|
|
|
|
- TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(tenantAlbum),
|
|
|
- TenantAlbumWrapper.TenantAlbum.class);
|
|
|
-
|
|
|
- //查关联表
|
|
|
- TenantAlbumRef one = tenantAlbumRefService.lambdaQuery().eq(TenantAlbumRef::getTenantAlbumId, id)
|
|
|
- .last("limit 1").one();
|
|
|
- vo.setTenantId(one.getTenantId().toString());
|
|
|
- //查询曲目表
|
|
|
|
|
|
- TenantInfo tenantInfo = tenantInfoService.getById(one.getTenantId());
|
|
|
- vo.setTenantName(tenantInfo.getName());
|
|
|
List<TenantAlbumMusic> tenantAlbumMusics = tenantAlbumMusicService.lambdaQuery()
|
|
|
- .eq(TenantAlbumMusic::getTenantAlbumId, id)
|
|
|
- .eq(TenantAlbumMusic::getDelFlag, false)
|
|
|
- .list();
|
|
|
-
|
|
|
- Map<SubjectTypeEnum, List<TenantAlbumMusic>> groupByType =
|
|
|
- tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
|
|
|
-
|
|
|
-
|
|
|
- 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<>();
|
|
|
+ .eq(TenantAlbumMusic::getTenantAlbumId, id)
|
|
|
+ .eq(TenantAlbumMusic::getSubjectType, SubjectTypeEnum.valueOf(subjectType))
|
|
|
+ .eq(TenantAlbumMusic::getDelFlag, false)
|
|
|
+ .orderByAsc(TenantAlbumMusic::getSortNumber,TenantAlbumMusic::getId)
|
|
|
+ .list();
|
|
|
+ if (CollectionUtils.isEmpty(tenantAlbumMusics)) {
|
|
|
+ return HttpResponseResult.succeed();
|
|
|
+ }
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(coursewareList)) {
|
|
|
+ if (subjectType.equals(SubjectTypeEnum.COURSEWARE.name())) {
|
|
|
+ List<Long> coursewareList = tenantAlbumMusics.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
|
|
|
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())));
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, MusicSheetVo> idMsMap = new HashMap<>();
|
|
|
- Map<Integer,Subject> subjectMap = subjectService.getAllMap();
|
|
|
- Map<Long, MusicTag> musicTagMap = musicTagService.getAllMap();
|
|
|
- if (CollectionUtils.isNotEmpty(musicSheetIdlist)) {
|
|
|
+ return HttpResponseResult.succeed(entities.stream().map(o -> {
|
|
|
+ TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
|
|
|
+ tenantAlbumSheet.setId(o.getId().toString());
|
|
|
+ tenantAlbumSheet.setMusicSheetName(o.getName());
|
|
|
+ tenantAlbumSheet.setTitleImg(o.getCoverImg());
|
|
|
+ tenantAlbumSheet.setMusicSubject(o.getCourseTypeCode());
|
|
|
+ tenantAlbumSheet.setMusicSubjectName(ECourseType.valueOf(o.getCourseTypeCode()).getName());
|
|
|
+ return tenantAlbumSheet;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ List<Long> musicSheetIdlist = tenantAlbumMusics.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
|
|
|
StudentMusicSheetSearch search = new StudentMusicSheetSearch();
|
|
|
search.setMusicSheetIdlist(musicSheetIdlist);
|
|
|
+ search.setProviderType(SourceTypeEnum.TENANT);
|
|
|
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())));
|
|
|
+ return HttpResponseResult.succeed(records.getRecords().stream().map(o -> {
|
|
|
+ TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
|
|
|
+ tenantAlbumSheet.setId(o.getId().toString());
|
|
|
+ tenantAlbumSheet.setMusicSheetName(o.getMusicSheetName());
|
|
|
+ tenantAlbumSheet.setMusicTag(o.getMusicTag());
|
|
|
+ tenantAlbumSheet.setComposer(o.getComposer());
|
|
|
+ tenantAlbumSheet.setMusicSubject(o.getMusicSubject());
|
|
|
+ tenantAlbumSheet.setMusicSubjectName(o.getSubjectNames());
|
|
|
+ tenantAlbumSheet.setMusicTagName(o.getMusicTagNames());
|
|
|
+ return tenantAlbumSheet;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
}
|
|
|
- List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
|
|
|
- groupByType.forEach((key, value) -> {
|
|
|
- value.sort(Comparator.comparing(TenantAlbumMusic::getSortNumber));
|
|
|
- TenantAlbumWrapper.MusicSheetData sheetData = new TenantAlbumWrapper.MusicSheetData();
|
|
|
- sheetData.setSubjectType(key);
|
|
|
- List<TenantAlbumWrapper.TenantAlbumSheet> tenantAlbumSheets = value.stream().map(next -> {
|
|
|
|
|
|
- TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
|
|
|
- BeanUtils.copyProperties(next, tenantAlbumSheet);
|
|
|
- Long musicSheetId = tenantAlbumSheet.getMusicSheetId();
|
|
|
- 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());
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- break;
|
|
|
- case MUSIC:
|
|
|
- case SUBJECT:
|
|
|
- case ENSEMBLE:
|
|
|
- {
|
|
|
- MusicSheetVo musicSheet = idMsMap.get(musicSheetId);
|
|
|
- if (musicSheet == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- tenantAlbumSheet.setMusicSheetName(musicSheet.getMusicSheetName());
|
|
|
- tenantAlbumSheet.setMusicTag(musicSheet.getMusicTag());
|
|
|
- tenantAlbumSheet.setComposer(musicSheet.getComposer());
|
|
|
- tenantAlbumSheet.setMusicSubject(musicSheet.getMusicSubject());
|
|
|
- tenantAlbumSheet.setMusicSubjectName(musicSheet.getSubjectNames());
|
|
|
- tenantAlbumSheet.setMusicTagName(musicSheet.getMusicTagNames());
|
|
|
-/*
|
|
|
- //设置对应标签名称
|
|
|
- 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);
|
|
|
- }*/
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
|
|
|
- return tenantAlbumSheet;
|
|
|
- }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ }
|
|
|
|
|
|
- sheetData.setTenantAlbumSheetList(tenantAlbumSheets);
|
|
|
- musicSheetData.add(sheetData);
|
|
|
- vo.setMusicSheetData(musicSheetData);
|
|
|
- });
|
|
|
+ /**
|
|
|
+ * 查询详情
|
|
|
+ *
|
|
|
+ * @param id 详情ID
|
|
|
+ * @return TenantAlbum
|
|
|
+ */
|
|
|
+ @PostMapping("/detail")
|
|
|
+ @ApiOperation(value = "查询详情", notes = "detail")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
|
|
|
+ public HttpResponseResult<TenantAlbumWrapper.TenantAlbum> detail(@RequestParam("id") Long id) {
|
|
|
+ TenantAlbum tenantAlbum = tenantAlbumService.detail(id);
|
|
|
+ if (tenantAlbum == null) {
|
|
|
+ throw new BizException("专辑信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(tenantAlbum),
|
|
|
+ TenantAlbumWrapper.TenantAlbum.class);
|
|
|
+
|
|
|
+ //查关联表
|
|
|
+ TenantAlbumRef one = tenantAlbumRefService.lambdaQuery().eq(TenantAlbumRef::getTenantAlbumId, id)
|
|
|
+ .last("limit 1").one();
|
|
|
+ vo.setTenantId(one.getTenantId().toString());
|
|
|
+ //查询曲目表
|
|
|
+
|
|
|
+ TenantInfo tenantInfo = tenantInfoService.getById(one.getTenantId());
|
|
|
+ vo.setTenantName(tenantInfo.getName());
|
|
|
|
|
|
return HttpResponseResult.succeed(vo);
|
|
|
}
|