|
|
|
@ -1,18 +1,12 @@
|
|
|
|
|
package com.luoo.music.service;
|
|
|
|
|
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import com.luoo.music.dao.ArtistAlbumDao;
|
|
|
|
|
import com.luoo.music.dao.ArtistAlbumSongDao;
|
|
|
|
|
import com.luoo.music.dao.SongInfoDao;
|
|
|
|
|
import com.luoo.music.dao.SongTagDao;
|
|
|
|
|
import com.luoo.music.dao.*;
|
|
|
|
|
import com.luoo.music.dto.response.AlbumAddDTO;
|
|
|
|
|
import com.luoo.music.dto.response.AlbumSearchDTO;
|
|
|
|
|
import com.luoo.music.dto.response.AlbumSongAddDTO;
|
|
|
|
|
import com.luoo.music.dto.response.AlbumUpdateDTO;
|
|
|
|
|
import com.luoo.music.pojo.ArtistAlbum;
|
|
|
|
|
import com.luoo.music.pojo.ArtistAlbumSong;
|
|
|
|
|
import com.luoo.music.pojo.SongInfo;
|
|
|
|
|
import com.luoo.music.pojo.SongTag;
|
|
|
|
|
import com.luoo.music.pojo.*;
|
|
|
|
|
import com.luoo.music.util.Constants;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import enums.AlbumStateEnum;
|
|
|
|
@ -38,7 +32,9 @@ import javax.persistence.criteria.Root;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: yawei.huang
|
|
|
|
@ -51,6 +47,8 @@ import java.util.Objects;
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class AlbumService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private TagDao tagDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ArtistAlbumDao artistAlbumDao;
|
|
|
|
@ -171,7 +169,56 @@ public class AlbumService {
|
|
|
|
|
if (artistAlbum == null) {
|
|
|
|
|
throw new RuntimeException("专辑不存在,请刷新后重试");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 整个数据库所有的tag
|
|
|
|
|
List<Tag> tagAllList = tagDao.findAll();
|
|
|
|
|
Map<String, Tag> tagMap = tagAllList.stream().collect(Collectors.toMap(Tag::getId, item -> item));
|
|
|
|
|
log.info("------tagMap:{}",tagMap);
|
|
|
|
|
|
|
|
|
|
// 处理album基础信息
|
|
|
|
|
if(StringUtils.isNotBlank(artistAlbum.getMainStyle())) {
|
|
|
|
|
List<Tag> style = new ArrayList<>();
|
|
|
|
|
String[] mainStyleArr = artistAlbum.getMainStyle().split(",");
|
|
|
|
|
for (String s : mainStyleArr) {
|
|
|
|
|
if(StringUtils.isNotBlank(s)) {
|
|
|
|
|
style.add(tagMap.get(s));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
artistAlbum.setStyle(style);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理歌曲list
|
|
|
|
|
List<SongInfo> songInfoList = songInfoDao.findByAlbumId(id);
|
|
|
|
|
for (SongInfo songInfo : songInfoList) {
|
|
|
|
|
String songInfoId = songInfo.getId();
|
|
|
|
|
List<Tag> language = new ArrayList<>();
|
|
|
|
|
List<Tag> style = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 查询所有的tagId
|
|
|
|
|
List<String> tagIdsBySongId = songTagDao.findTagIdsBySongId(songInfoId);
|
|
|
|
|
for (String tagId : tagIdsBySongId) {
|
|
|
|
|
Tag currentTag = tagMap.get(tagId);
|
|
|
|
|
if (StringUtils.isNotBlank(currentTag.getParentId())) {
|
|
|
|
|
// 二级标签
|
|
|
|
|
Tag parentTag = tagMap.get(currentTag.getParentId());
|
|
|
|
|
if (ObjectUtils.notEqual("Language", parentTag.getNameEn())) {
|
|
|
|
|
style.add(currentTag);
|
|
|
|
|
} else {
|
|
|
|
|
language.add(currentTag);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 一级标签
|
|
|
|
|
if (ObjectUtils.notEqual("Language", currentTag.getNameEn())) {
|
|
|
|
|
style.add(currentTag);
|
|
|
|
|
} else {
|
|
|
|
|
language.add(currentTag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
songInfo.setLanguage(language);
|
|
|
|
|
songInfo.setStyle(style);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
artistAlbum.setSongList(songInfoList);
|
|
|
|
|
return artistAlbum;
|
|
|
|
|
}
|
|
|
|
|