|
|
@ -1,11 +1,16 @@
|
|
|
|
package com.luoo.music.controller;
|
|
|
|
package com.luoo.music.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.apifan.common.random.RandomSource;
|
|
|
|
|
|
|
|
import com.apifan.common.random.entity.Poem;
|
|
|
|
|
|
|
|
import com.luoo.music.dao.TagDao;
|
|
|
|
import com.luoo.music.dto.request.JournalQueryReq;
|
|
|
|
import com.luoo.music.dto.request.JournalQueryReq;
|
|
|
|
import com.luoo.music.dto.response.JournalRespDTO;
|
|
|
|
import com.luoo.music.dto.response.JournalRespDTO;
|
|
|
|
|
|
|
|
|
|
|
@ -13,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
|
|
|
|
import com.luoo.music.pojo.Tag;
|
|
|
|
import com.luoo.music.service.ArticleService;
|
|
|
|
import com.luoo.music.service.ArticleService;
|
|
|
|
import com.luoo.music.service.UserCollectService;
|
|
|
|
import com.luoo.music.service.UserCollectService;
|
|
|
|
|
|
|
|
|
|
|
@ -44,6 +50,10 @@ public class JournalController {
|
|
|
|
private UserCollectService userCollectService;
|
|
|
|
private UserCollectService userCollectService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ArticleService articleService;
|
|
|
|
private ArticleService articleService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private TagDao tagDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
@ -107,6 +117,13 @@ public class JournalController {
|
|
|
|
journalRespDTO.setImage(Constants.MUSIC_RESOURCE_PREFIX + article.getImage());
|
|
|
|
journalRespDTO.setImage(Constants.MUSIC_RESOURCE_PREFIX + article.getImage());
|
|
|
|
journalRespDTO.setDate(getEditDate(article));
|
|
|
|
journalRespDTO.setDate(getEditDate(article));
|
|
|
|
journalRespDTO.setHaveCollect(journalCollectSet.contains(journalRespDTO.getId()));
|
|
|
|
journalRespDTO.setHaveCollect(journalCollectSet.contains(journalRespDTO.getId()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int limit = RandomSource.numberSource().randomInt(1, 3);
|
|
|
|
|
|
|
|
List<String> tags=tagDao.random(limit).stream().map(Tag::getNameCh).sorted().collect(Collectors.toList());
|
|
|
|
|
|
|
|
journalRespDTO.setTags(tags);
|
|
|
|
|
|
|
|
Poem poem=RandomSource.languageSource().randomTangPoem();
|
|
|
|
|
|
|
|
journalRespDTO.setEditor(poem.getAuthor());
|
|
|
|
|
|
|
|
journalRespDTO.setContent(Arrays.stream(poem.getContent()).collect(Collectors.joining("\r\n")));
|
|
|
|
return journalRespDTO;
|
|
|
|
return journalRespDTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|