1.update random song need auth token 2.add found journal by journalNo

main
Gary 11 months ago
parent 8de5e5b376
commit 5cd9494eba

@ -12,6 +12,7 @@ public class Constants {
public static final String J2CACHE_REGION_JOURNAL_QUERY_PAGE = "journal_query_page";
public static final String J2CACHE_REGION_JOURNAL_ID = "journal_id";
public static final String J2CACHE_REGION_JOURNAL_NO = "journal_no";
public static final String J2CACHE_REGION_JOURNAL_SONG_KEY = "journal_song_key";
public static final String J2CACHE_REGION_JOURNAL_SONG_LIST = "journal_song_list";

@ -46,7 +46,7 @@ public class SaticScheduleTask {
private TagDao tagDao;
// 1.凌晨4点执行更新期刊tag
@Scheduled(cron="0 0 4 * * ?")
@Scheduled(cron="0 0 4 * * *")
private void updateJouranlTag() {
AtomicLong updateCounter = new AtomicLong();
journalDao.findValidJournals().parallelStream().forEach(j -> updateJouranlTag(j, updateCounter));
@ -56,7 +56,7 @@ public class SaticScheduleTask {
}
// 2.凌晨4:20点执行更新分词
@Scheduled(cron="0 20 4 * * ?")
@Scheduled(cron="0 20 4 * * *")
private void updateAutoComplete() {
List<Journal> validJournals = journalDao.findValidJournals();
validJournals.parallelStream().forEach(j -> {

@ -191,7 +191,28 @@ public class JournalController {
return Result.success(journalRespDTO);
}
@ApiOperation(value = "3.1 根据期刊id查询评论信息")
@ApiOperation(value = "3.1 根据期刊号查询期刊信息")
@GetMapping("/journalNo/{journalNo}")
@GlobalInterceptor
public Result<JournalRespDTO> findByJournalNo(
@RequestHeader(value = "Authorization", required = false) String authorization,
@PathVariable @VerifyParam(required = true) String journalNo) {
JournalRespDTO journalRespDTO=journalService.queryJournalByJournalNo(journalNo);
if(null==journalRespDTO) {
return Result.failed(StatusCode.MUSIC_COMMON_FAILED,"根据期刊号无法找到期刊, 期刊号: "+journalNo);
}
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
if (null == user && !isLatest10(journalNo)) {
return Result.unauthorized(null);
}
boolean isCollect=null == user ? false:userCollectInfoService.isCollect(user.getUserId(),journalRespDTO.getId(), CollectTypeEnum.JOURNAL);
journalRespDTO.setHaveCollect(isCollect);
return Result.success(journalRespDTO);
}
private boolean isLatest10(String journalNo) {
return journalService.isLatest10ByJournalNo(journalNo);
}
@ApiOperation(value = "3.2 根据期刊id查询评论信息")
@GetMapping("/comment/{id}")
@GlobalInterceptor
public Result<CommentDTO> findCommentById(

@ -137,9 +137,9 @@ public class SongController {
@ApiOperation(value = "3.随机播放歌曲", notes = "雀乐FM")
@ApiImplicitParams({ @ApiImplicitParam(name = "limit", value = "随机歌曲数最少1首最多30首", required = false) })
@GetMapping("/random/{limit}")
@GlobalInterceptor
@GlobalInterceptor(checkAppUserLogin = true)
public Result<List<SongRespDTO>> random(
@RequestHeader(value = "Authorization", required = false) String authorization,
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable @VerifyParam(required = true, regex = VerifyRegexEnum.RANDOM_SONG_LIMIT) Integer limit) {
List<JournalSong> songs = journalSongService.random(limit);
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);

@ -390,4 +390,16 @@ public class JournalService {
}
return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao);
}
public JournalRespDTO queryJournalByJournalNo(String journalNo) {
return (JournalRespDTO) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_NO, journalNo, key -> getJournalRespDTOByJournalNo(journalNo), false).getValue();
}
private JournalRespDTO getJournalRespDTOByJournalNo(String journalNo) {
Journal journal=journalDao.findValidJournalByJournalNo(journalNo);
if(null==journal) {
return null;
}
return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao);
}
}

@ -1,5 +1,6 @@
default: 1000, 2h
journal_query_page: 10000, 6h
journal_id: 2000, 6h
journal_no: 2000, 6h
journal_song_key: 10000, 6h
journal_song_list: 2000, 6h
Loading…
Cancel
Save