|
|
|
@ -2,6 +2,7 @@ package com.luoo.music.service;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
@ -13,6 +14,7 @@ import javax.persistence.criteria.Root;
|
|
|
|
|
|
|
|
|
|
import api.Result;
|
|
|
|
|
import constants.Constants;
|
|
|
|
|
import enums.CollectTypeEnum;
|
|
|
|
|
import enums.JournalPublishEnum;
|
|
|
|
|
import enums.JournalStatusEnum;
|
|
|
|
|
import net.oschina.j2cache.CacheChannel;
|
|
|
|
@ -57,8 +59,6 @@ public class JournalService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private JournalSongDao journalSongDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IdWorker idWorker;
|
|
|
|
|
@Autowired
|
|
|
|
|
private JournalTagDao journalTagDao;
|
|
|
|
|
@Autowired
|
|
|
|
@ -72,7 +72,7 @@ public class JournalService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CommentDao commentDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<Integer,List<String>> JOURNAL_RANGE_MAP=new HashMap<>();
|
|
|
|
|
/*
|
|
|
|
|
* public void updateState(String id) { journalDao.updateState(id); }
|
|
|
|
@ -119,18 +119,7 @@ public class JournalService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Journal findById(String id) {
|
|
|
|
|
|
|
|
|
|
Journal journal = (Journal) redisTemplate.opsForValue().get("journal_"+id);
|
|
|
|
|
|
|
|
|
|
if (journal==null) {
|
|
|
|
|
Optional<Journal> optional=journalDao.findById(id);
|
|
|
|
|
if(optional.isPresent()) {
|
|
|
|
|
journal =optional.get();
|
|
|
|
|
redisTemplate.opsForValue().set("journal_"+id,journal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return journal;
|
|
|
|
|
return journalDao.findById(id).orElse(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -387,4 +376,18 @@ public class JournalService {
|
|
|
|
|
List<Journal> pageList = queryPage(queryReq);
|
|
|
|
|
return pageList.stream().map(journal -> JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao)).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JournalRespDTO queryJournalById(String id) {
|
|
|
|
|
return (JournalRespDTO) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_ID, id, key -> getJournalRespDTOById(id), false).getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JournalRespDTO getJournalRespDTOById(String id) {
|
|
|
|
|
Journal journal=this.findById(id);
|
|
|
|
|
if(null==journal) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|