From cd10c6d8e9792d7ee776b6ff8583ffe29955a2a5 Mon Sep 17 00:00:00 2001 From: JH <935007339@qq.com> Date: Sun, 11 Feb 2024 15:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E4=B9=90=E5=88=97=E8=A1=A8=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=9C=9F=E5=88=8A=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/cms/JournalJumpRespDto.java | 39 +++++++++++++++++ .../dto/response/cms/SongListRespDto.java | 11 +++-- .../luoo/music/service/CMSSongService.java | 43 ++++++++++++++++--- 3 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 luoo_music/src/main/java/com/luoo/music/dto/response/cms/JournalJumpRespDto.java diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/cms/JournalJumpRespDto.java b/luoo_music/src/main/java/com/luoo/music/dto/response/cms/JournalJumpRespDto.java new file mode 100644 index 0000000..11ac4fb --- /dev/null +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/cms/JournalJumpRespDto.java @@ -0,0 +1,39 @@ +package com.luoo.music.dto.response.cms; + +import com.luoo.music.pojo.Journal; +import com.luoo.music.util.Constants; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.commons.lang.StringUtils; + +import java.util.List; + +/** + * @author locust + */ +@Data +@ApiModel(description = "音乐列表音乐关联期刊跳转") +public class JournalJumpRespDto { + + @ApiModelProperty(value = "主键ID") + private String id; + + @ApiModelProperty(value = "期刊编号") + private String journalNo; + + @ApiModelProperty(value = "期刊标题") + private String title; + + @ApiModelProperty(value = "标号标题拼接") + private String joint; + + public static JournalJumpRespDto convertPojo(Journal journal) { + JournalJumpRespDto response = new JournalJumpRespDto(); + response.setId(journal.getId()); + response.setJournalNo(journal.getJournalNo()); + response.setTitle(journal.getTitle()); + response.setJoint((Constants.JOURNAL_NO_PREF + journal.getJournalNo() + " " + journal.getTitle())); + return response; + } +} diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/cms/SongListRespDto.java b/luoo_music/src/main/java/com/luoo/music/dto/response/cms/SongListRespDto.java index 6c2b915..fb649b8 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/response/cms/SongListRespDto.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/cms/SongListRespDto.java @@ -58,12 +58,16 @@ public class SongListRespDto { @ApiModelProperty(value = "关联期刊") private List journal; + @ApiModelProperty(value = "关联期刊信息") + private List journals; + @ApiModelProperty(value = "歌曲风格") private List tags; public static SongListRespDto convertPojo(SongInfo song, - Map> songJournalMap, - Map> songTagMap) { + Map> songJournalMap1, + Map> songTagMap, + Map> songJournalMap) { SongListRespDto response = new SongListRespDto(); String id = song.getId(); response.setId(id); @@ -78,7 +82,8 @@ public class SongListRespDto { } response.setSize(CommonUtil.formatSongSize(song.getSize())); response.setDuration(CommonUtil.formatSongDuration(song.getDuration())); - response.setJournal(songJournalMap.get(id)); + response.setJournal(songJournalMap1.get(id)); + response.setJournals(songJournalMap.get(id)); if (Objects.isNull(song.getUpdateTime())) { response.setUpdateTime(""); } else { diff --git a/luoo_music/src/main/java/com/luoo/music/service/CMSSongService.java b/luoo_music/src/main/java/com/luoo/music/service/CMSSongService.java index 97d5e84..a421ea6 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/CMSSongService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/CMSSongService.java @@ -3,13 +3,10 @@ package com.luoo.music.service; import api.PageResult; import api.Result; import com.luoo.music.dao.*; +import com.luoo.music.dto.response.cms.*; import com.luoo.music.pojo.*; import com.luoo.music.dto.request.cms.SongAddModel; import com.luoo.music.dto.request.cms.SongQueryModel; -import com.luoo.music.dto.response.cms.SongBaseRespDto; -import com.luoo.music.dto.response.cms.SongListRespDto; -import com.luoo.music.dto.response.cms.SongLyricRespDto; -import com.luoo.music.dto.response.cms.SongRespDto; import com.luoo.music.util.CommonUtil; import com.luoo.music.util.Constants; import dto.UserLoginDto; @@ -84,11 +81,12 @@ public class CMSSongService { if (!CollectionUtils.isEmpty(content)) { List ids = content.stream().map(SongInfo::getId).collect(Collectors.toList()); // 查询歌曲对应的期刊信息 - Map> songJournalMap = buildSongJournalInfo(ids); + Map> songJournalMap = buildSongJournalInfos(ids); + Map> songJournalMap1 = buildSongJournalInfo(ids); // 查询歌曲对应的标签信息 Map> songTagMap = buildSongTagInfo(ids); for (SongInfo item : content) { - SongListRespDto response = SongListRespDto.convertPojo(item, songJournalMap, songTagMap); + SongListRespDto response = SongListRespDto.convertPojo(item, songJournalMap, songTagMap, songJournalMap1); result.add(response); } } @@ -132,7 +130,7 @@ public class CMSSongService { * @param ids * @return */ - private Map> buildSongJournalInfo(List ids) { + private Map> buildSongJournalInfos(List ids) { Map> result = new HashMap<>(); List journalSongList = journalSongDao.findBySongIds(ids); if (!CollectionUtils.isEmpty(journalSongList)) { @@ -158,6 +156,37 @@ public class CMSSongService { return result; } + /** + * 歌曲的期刊信息 + * @param ids + * @return + */ + private Map> buildSongJournalInfo(List ids) { + Map> result = new HashMap<>(); + List journalSongList = journalSongDao.findBySongIds(ids); + if (!CollectionUtils.isEmpty(journalSongList)) { + Set idSet = journalSongList.stream().map(JournalSong::getJournalNo).collect(Collectors.toSet()); + List journalList = journalDao.findByJournalNoIn(idSet); + Map idJournalMap = journalList.stream().collect(Collectors.toMap(Journal::getJournalNo, obj -> obj)); + for (JournalSong item : journalSongList) { + String songId = item.getSongId(); + String journalNo = item.getJournalNo(); + List list; + if (result.keySet().contains(songId)) { + list = result.get(songId); + } else { + list = new ArrayList<>(); + } + if (idJournalMap.keySet().contains(journalNo)) { + Journal journal = idJournalMap.get(journalNo); + list.add(JournalJumpRespDto.convertPojo(journal)); + } + result.put(songId, list); + } + } + return result; + } + /** * 歌曲的标签信息 * @param ids