1.add find journal song by journal id

main
Gary 9 months ago
parent 43a1af546b
commit 3e6800ea4c

@ -76,6 +76,13 @@ public class SongController {
return Result.success(results); return Result.success(results);
} }
@ApiOperation(value = "1.1 根据期刊id查询歌曲信息", notes = "仅用于外部分享")
@GetMapping("/journalId/{journalId}")
@GlobalInterceptor
public Result<List<SongRespDTO>> getByJournalId(@PathVariable String journalId) {
return Result.success(journalSongService.findByJournalId(journalId));
}
private void updateCollectStatus(List<SongRespDTO> results, Set<String> songCollectSet) { private void updateCollectStatus(List<SongRespDTO> results, Set<String> songCollectSet) {
results.forEach(s->{ results.forEach(s->{
s.setHaveCollect(songCollectSet.contains(s.getId())); s.setHaveCollect(songCollectSet.contains(s.getId()));

@ -59,4 +59,7 @@ public interface JournalSongDao extends JpaRepository<JournalSong,String>, JpaSp
@Query(value = "select * from tb_journal_song where match(name, artist, album) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true) @Query(value = "select * from tb_journal_song where match(name, artist, album) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true)
List<JournalSong> fuzzySearch(String keyword,int offset, int limit); List<JournalSong> 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<JournalSong> findByJournalId(String journalId);
} }

@ -115,15 +115,26 @@ public class JournalSongService {
} }
public JournalSong findByJournalNoSongId(String id) { 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<SongRespDTO> findByJournalNo(String journalNo) { public List<SongRespDTO> findByJournalNo(String journalNo) {
return (List<SongRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo, key -> getSongRespDTO(journalNo) , true).getValue() ; return (List<SongRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalNo, key -> getSongRespDTOByJournalNo(journalNo) , false).getValue() ;
} }
private List<SongRespDTO> getSongRespDTO(String journalNo) { public List<SongRespDTO> findByJournalId(String journalId) {
return (List<SongRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_SONG_LIST, journalId, key -> getSongRespDTOByJournalId(journalId) , false).getValue();
}
private List<SongRespDTO> getSongRespDTOByJournalId(String journalId) {
List<JournalSong> songs = journalSongDao.findByJournalId(journalId);
List<SongRespDTO> results= songs.stream().map(s -> SongMapper.getSongRespDTO(s))
.collect(Collectors.toList());
return results.isEmpty()?null:results;
}
private List<SongRespDTO> getSongRespDTOByJournalNo(String journalNo) {
List<JournalSong> songs = findByVolid(journalNo); List<JournalSong> songs = findByVolid(journalNo);
return songs.stream().map(s -> SongMapper.getSongRespDTO(s)) return songs.stream().map(s -> SongMapper.getSongRespDTO(s))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -155,4 +166,6 @@ public class JournalSongService {
} }
}; };
} }
} }

Loading…
Cancel
Save