diff --git a/luoo_music/src/main/java/com/luoo/music/controller/SongController.java b/luoo_music/src/main/java/com/luoo/music/controller/SongController.java index cf2a9d1..cd2996a 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/SongController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/SongController.java @@ -75,6 +75,13 @@ public class SongController { updateCollectStatus(results,songCollectSet); return Result.success(results); } + + @ApiOperation(value = "1.1 根据期刊id查询歌曲信息", notes = "仅用于外部分享") + @GetMapping("/journalId/{journalId}") + @GlobalInterceptor + public Result> getByJournalId(@PathVariable String journalId) { + return Result.success(journalSongService.findByJournalId(journalId)); + } private void updateCollectStatus(List results, Set songCollectSet) { results.forEach(s->{ diff --git a/luoo_music/src/main/java/com/luoo/music/dao/JournalSongDao.java b/luoo_music/src/main/java/com/luoo/music/dao/JournalSongDao.java index 12dd828..a9fe958 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/JournalSongDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/JournalSongDao.java @@ -59,4 +59,7 @@ public interface JournalSongDao extends JpaRepository, JpaSp @Query(value = "select * from tb_journal_song where match(name, artist, album) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true) List fuzzySearch(String keyword,int offset, int limit); + + @Query(value = "select * from tb_journal_song tjs where journal_no = (select journal_no from tb_journal where id=?1) order by song_no", nativeQuery = true) + List findByJournalId(String journalId); } diff --git a/luoo_music/src/main/java/com/luoo/music/service/JournalSongService.java b/luoo_music/src/main/java/com/luoo/music/service/JournalSongService.java index 9fa2c23..0d66399 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/JournalSongService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/JournalSongService.java @@ -115,15 +115,26 @@ public class JournalSongService { } public JournalSong findByJournalNoSongId(String id) { - return (JournalSong) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, id, key -> journalSongDao.findByJournalNoSongId(id) , true).getValue() ; + return (JournalSong) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, id, key -> journalSongDao.findByJournalNoSongId(id) , false).getValue() ; } public List findByJournalNo(String journalNo) { - return (List) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo, key -> getSongRespDTO(journalNo) , true).getValue() ; + return (List) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo, key -> getSongRespDTOByJournalNo(journalNo) , false).getValue() ; } - private List getSongRespDTO(String journalNo) { + public List findByJournalId(String journalId) { + return (List) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalId, key -> getSongRespDTOByJournalId(journalId) , false).getValue(); + } + + private List getSongRespDTOByJournalId(String journalId) { + List songs = journalSongDao.findByJournalId(journalId); + List results= songs.stream().map(s -> SongMapper.getSongRespDTO(s)) + .collect(Collectors.toList()); + return results.isEmpty()?null:results; + } + + private List getSongRespDTOByJournalNo(String journalNo) { List songs = findByVolid(journalNo); return songs.stream().map(s -> SongMapper.getSongRespDTO(s)) .collect(Collectors.toList()); @@ -155,4 +166,6 @@ public class JournalSongService { } }; } + + }