|
|
|
@ -41,8 +41,12 @@ import com.luoo.music.dao.JournalTagDao;
|
|
|
|
|
import com.luoo.music.dao.TagDao;
|
|
|
|
|
import com.luoo.music.dto.mapper.JournalMapper;
|
|
|
|
|
import com.luoo.music.dto.request.JournalQueryReq;
|
|
|
|
|
import com.luoo.music.dto.response.JournalFilterDTO;
|
|
|
|
|
import com.luoo.music.dto.response.JournalRespDTO;
|
|
|
|
|
import com.luoo.music.dto.response.SearchCategoryDTO;
|
|
|
|
|
import com.luoo.music.dto.response.TagDTO;
|
|
|
|
|
import com.luoo.music.pojo.Journal;
|
|
|
|
|
import com.luoo.music.pojo.Tag;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 服务层
|
|
|
|
@ -53,6 +57,7 @@ import com.luoo.music.pojo.Journal;
|
|
|
|
|
@Service
|
|
|
|
|
public class JournalService {
|
|
|
|
|
private static final Pattern NUMBER_PATTERN = Pattern.compile("[0-9]*");
|
|
|
|
|
private static final int JOURNAL_FILTER_NUMBER_RANGE=100;
|
|
|
|
|
@Autowired
|
|
|
|
|
private JournalDao journalDao;
|
|
|
|
|
|
|
|
|
@ -73,13 +78,9 @@ 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); }
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* public void addThumbup(String id){ journalDao.addThumbup(id); }
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private TagService tagService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询全部列表
|
|
|
|
|
* @return
|
|
|
|
@ -270,10 +271,6 @@ public class JournalService {
|
|
|
|
|
public List<String> getJournalNoList(int journalFilterNumberRange) {
|
|
|
|
|
//获取最大的期刊号
|
|
|
|
|
int maxJournalNo=journalDao.getMaxJournalNo();
|
|
|
|
|
if(JOURNAL_RANGE_MAP.containsKey(maxJournalNo)) {
|
|
|
|
|
return JOURNAL_RANGE_MAP.get(maxJournalNo);
|
|
|
|
|
}
|
|
|
|
|
JOURNAL_RANGE_MAP.clear();
|
|
|
|
|
List<String> journalNoList=new ArrayList<>();
|
|
|
|
|
int i=1;
|
|
|
|
|
int start=1;
|
|
|
|
@ -292,7 +289,6 @@ public class JournalService {
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
Collections.reverse(journalNoList);
|
|
|
|
|
JOURNAL_RANGE_MAP.put(maxJournalNo, journalNoList);
|
|
|
|
|
return journalNoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -402,4 +398,23 @@ public class JournalService {
|
|
|
|
|
}
|
|
|
|
|
return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JournalFilterDTO getJournalFilterDTO() {
|
|
|
|
|
return (JournalFilterDTO) this.cacheChannel.get("default", "journal_filter", key -> getJournalFilter(), false).getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JournalFilterDTO getJournalFilter() {
|
|
|
|
|
JournalFilterDTO journalFilterDTO=new JournalFilterDTO();
|
|
|
|
|
journalFilterDTO.setJournalNoList(getJournalNoList(JOURNAL_FILTER_NUMBER_RANGE));
|
|
|
|
|
journalFilterDTO.setLanguageList(tagService.getLanguageList().stream().map(this::getTagDTO).collect(Collectors.toList()));
|
|
|
|
|
journalFilterDTO.setStyleList(tagService.getStyleList().stream().map(this::getTagDTO).collect(Collectors.toList()));
|
|
|
|
|
return journalFilterDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TagDTO getTagDTO(Tag tag) {
|
|
|
|
|
TagDTO tagDTO=new TagDTO();
|
|
|
|
|
tagDTO.setName(tag.getNameCh());
|
|
|
|
|
tagDTO.setId(tag.getId());
|
|
|
|
|
return tagDTO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|