|
@@ -3,13 +3,27 @@ package com.yonge.cooleshow.biz.dal.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MusicTag;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
|
|
|
|
|
|
+
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collection;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 机构专辑曲目
|
|
* 机构专辑曲目
|
|
@@ -19,12 +33,25 @@ import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
|
|
@Service
|
|
@Service
|
|
public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMapper, TenantAlbumMusic> implements TenantAlbumMusicService {
|
|
public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMapper, TenantAlbumMusic> implements TenantAlbumMusicService {
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserTenantAlbumRecordService userTenantAlbumRecordService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MusicSheetService musicSheetService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SubjectService subjectService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MusicTagService musicTagService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 查询详情
|
|
* 查询详情
|
|
* @param id 详情ID
|
|
* @param id 详情ID
|
|
* @return TenantAlbumMusic
|
|
* @return TenantAlbumMusic
|
|
*/
|
|
*/
|
|
- @Override
|
|
|
|
|
|
+ @Override
|
|
public TenantAlbumMusic detail(Long id) {
|
|
public TenantAlbumMusic detail(Long id) {
|
|
|
|
|
|
return baseMapper.selectById(id);
|
|
return baseMapper.selectById(id);
|
|
@@ -41,15 +68,15 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
|
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 添加
|
|
* 添加
|
|
* @param tenantAlbumMusic TenantAlbumMusicWrapper.TenantAlbumMusic
|
|
* @param tenantAlbumMusic TenantAlbumMusicWrapper.TenantAlbumMusic
|
|
* @return Boolean
|
|
* @return Boolean
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Boolean add(TenantAlbumMusicWrapper.TenantAlbumMusic tenantAlbumMusic) {
|
|
|
|
-
|
|
|
|
|
|
+ public Boolean add(TenantAlbumMusicWrapper.TenantAlbumMusic tenantAlbumMusic) {
|
|
|
|
+
|
|
return this.save(JSON.parseObject(tenantAlbumMusic.jsonString(), TenantAlbumMusic.class));
|
|
return this.save(JSON.parseObject(tenantAlbumMusic.jsonString(), TenantAlbumMusic.class));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,4 +90,69 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
|
|
|
|
|
|
return this.updateById(JSON.parseObject(tenantAlbumMusic.jsonString(), TenantAlbumMusic.class));
|
|
return this.updateById(JSON.parseObject(tenantAlbumMusic.jsonString(), TenantAlbumMusic.class));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取机构专辑曲目查询条件
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public TenantAlbumMusicWrapper.TenantAlbumMusicSelectData getTenantAlbumMusicQuery(TenantAlbumMusicWrapper.TenantAlbumMusicSelect query) {
|
|
|
|
+
|
|
|
|
+ TenantAlbumMusicWrapper.TenantAlbumMusicSelectData data = new TenantAlbumMusicWrapper.TenantAlbumMusicSelectData();
|
|
|
|
+
|
|
|
|
+ // 获取学生的专辑
|
|
|
|
+ List<Long> albumIds = userTenantAlbumRecordService.getUseAlbumIdsByUserId(query.getUserId(), ClientEnum.STUDENT);
|
|
|
|
+ albumIds.add(1686291824928468993L);
|
|
|
|
+ if (CollectionUtils.isEmpty(albumIds)) {
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 专辑曲目关联数据
|
|
|
|
+ List<TenantAlbumMusic> list = this.lambdaQuery()
|
|
|
|
+ .in(TenantAlbumMusic::getTenantAlbumId, albumIds)
|
|
|
|
+ .eq(query.getSubjectType() !=null,TenantAlbumMusic::getSubjectType, query.getSubjectType())
|
|
|
|
+ .eq(TenantAlbumMusic::getDelFlag, false)
|
|
|
|
+ .list();
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Long> musicSheetIds = list.stream().map(o -> o.getMusicSheetId()).distinct().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ Collection<MusicSheet> musicSheets = musicSheetService.listByIds(musicSheetIds);
|
|
|
|
+
|
|
|
|
+ // 类型
|
|
|
|
+ List<String> types = list.stream().map(TenantAlbumMusic::getType).distinct().filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
|
|
|
+ data.setTypes(types);
|
|
|
|
+ // 级别
|
|
|
|
+ List<String> levels = list.stream().map(TenantAlbumMusic::getLevel).distinct().filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
|
|
|
+ data.setLevels(levels);
|
|
|
|
+
|
|
|
|
+ // 声部
|
|
|
|
+ List<Long> subjectIds = musicSheets.stream()
|
|
|
|
+ .map(MusicSheet::getMusicSubject)
|
|
|
|
+ .filter(StringUtils::isNotBlank).distinct()
|
|
|
|
+ .map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtils.isNotEmpty(subjectIds)) {
|
|
|
|
+ List<Subject> subjects = subjectService.findBySubjectByIdList(subjectIds);
|
|
|
|
+ data.setSubjects(subjects);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 标签
|
|
|
|
+ List<Long> musicTagIds = musicSheets.stream().flatMap(o -> {
|
|
|
|
+ if (StringUtils.isNotBlank(o.getMusicTag())) {
|
|
|
|
+ return Arrays.stream(o.getMusicTag().split(","));
|
|
|
|
+ }
|
|
|
|
+ return Stream.empty();
|
|
|
|
+
|
|
|
|
+ }).filter(StringUtils::isNotBlank).distinct().map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
+ if (!CollectionUtils.isEmpty(musicTagIds)) {
|
|
|
|
+
|
|
|
|
+ List<MusicTag> tagList = musicTagService.listByIds(musicTagIds).parallelStream().collect(Collectors.toList());
|
|
|
|
+ data.setTags(tagList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return data;
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|