|
|
|
@ -82,6 +82,7 @@ public class JournalController {
|
|
|
|
|
journalTagMap.put(segs[0], tags);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<String> getLines(String filePath) {
|
|
|
|
|
try (InputStream is = new ClassPathResource(filePath).getInputStream();
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(is));) {
|
|
|
|
@ -91,6 +92,7 @@ public class JournalController {
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "1.查询期刊信息", notes = "若authorization为空或authorization校验失败,默认返回最新的10期,期刊筛选条件对游客不可用")
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
@GlobalInterceptor
|
|
|
|
@ -105,22 +107,21 @@ public class JournalController {
|
|
|
|
|
queryReq.setPageSize(10);
|
|
|
|
|
}
|
|
|
|
|
Page<Article> pageList = articleService.queryPage(queryReq);
|
|
|
|
|
Set<String> journalCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.JOURNAL);
|
|
|
|
|
Set<String> journalCollectSet = null == user ? Collections.emptySet()
|
|
|
|
|
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.JOURNAL);
|
|
|
|
|
List<JournalRespDTO> list = pageList.stream().map(a -> getJournalRespDTO(a, journalCollectSet))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "2.查询收藏期刊信息")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)
|
|
|
|
|
})
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
|
@GetMapping("/collect/{userId}/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
|
public Result<PageResult<JournalRespDTO>> collectPage(
|
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) String userId,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
|
@ -138,11 +139,13 @@ public class JournalController {
|
|
|
|
|
@ApiOperation(value = "3.根据期刊id查询期刊信息")
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
@GlobalInterceptor
|
|
|
|
|
public Result<JournalRespDTO> findById(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
public Result<JournalRespDTO> findById(
|
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) String id) {
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
|
|
|
|
|
Article journal = articleService.findById(id);
|
|
|
|
|
Set<String> journalCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.JOURNAL);
|
|
|
|
|
Set<String> journalCollectSet = null == user ? Collections.emptySet()
|
|
|
|
|
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.JOURNAL);
|
|
|
|
|
return Result.success(getJournalRespDTO(journal, journalCollectSet));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -175,10 +178,12 @@ public class JournalController {
|
|
|
|
|
private List<String> getTags(String journalNo) {
|
|
|
|
|
return journalTagMap.computeIfAbsent(journalNo, a -> getTags());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> getTags() {
|
|
|
|
|
int limit = RandomSource.numberSource().randomInt(1, 3);
|
|
|
|
|
return tagDao.random(limit).stream().map(Tag::getNameCh).sorted().collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getEditDate(Article article) {
|
|
|
|
|
Date date = null == article.getUpdatetime() ? article.getCreatetime() : article.getUpdatetime();
|
|
|
|
|
return DateUtil.format(date, DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern());
|
|
|
|
|