1.remove restriction latest 10 in journal find by id

main
Gary 9 months ago
parent 31a4146441
commit 24fa4a5a42

@ -33,6 +33,7 @@ import annotation.GlobalInterceptor;
import annotation.VerifyParam; import annotation.VerifyParam;
import api.PageResult; import api.PageResult;
import api.Result; import api.Result;
import api.StatusCode;
import constants.Constants; import constants.Constants;
import dto.UserLoginDto; import dto.UserLoginDto;
import enums.CollectTypeEnum; import enums.CollectTypeEnum;
@ -154,11 +155,12 @@ public class JournalController {
public Result<JournalRespDTO> findById( public Result<JournalRespDTO> findById(
@RequestHeader(value = "Authorization", required = false) String authorization, @RequestHeader(value = "Authorization", required = false) String authorization,
@PathVariable @VerifyParam(required = true) String id) { @PathVariable @VerifyParam(required = true) String id) {
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
if (null == user && !journalService.isLatest10ByJournalId(id)) {
return Result.unauthorized(null);
}
Journal journal = journalService.findById(id); Journal journal = journalService.findById(id);
if(null==journal) {
return Result.failed(StatusCode.MUSIC_COMMON_FAILED,"根据id无法找到期刊, id: "+id);
}
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
JournalRespDTO journalRespDTO=JournalMapper.getJournalRespDTO(journal, Collections.emptySet(),mongoTemplate,redisTemplate,commentDao); JournalRespDTO journalRespDTO=JournalMapper.getJournalRespDTO(journal, Collections.emptySet(),mongoTemplate,redisTemplate,commentDao);
boolean isCollect=null == user ? false:userCollectInfoService.isCollect(user.getUserId(),id, CollectTypeEnum.JOURNAL); boolean isCollect=null == user ? false:userCollectInfoService.isCollect(user.getUserId(),id, CollectTypeEnum.JOURNAL);
journalRespDTO.setHaveCollect(isCollect); journalRespDTO.setHaveCollect(isCollect);

@ -98,8 +98,11 @@ public class JournalService {
Journal journal = (Journal) redisTemplate.opsForValue().get("journal_"+id); Journal journal = (Journal) redisTemplate.opsForValue().get("journal_"+id);
if (journal==null) { if (journal==null) {
journal =journalDao.findById(id).get(); Optional<Journal> optional=journalDao.findById(id);
redisTemplate.opsForValue().set("journal_"+id,journal); if(optional.isPresent()) {
journal =optional.get();
redisTemplate.opsForValue().set("journal_"+id,journal);
}
} }
return journal; return journal;

Loading…
Cancel
Save