1.fix swagger annatation 2.unify collect request fot both journal and song

main
Gary 9 months ago
parent aeb18e7e5d
commit 6d94c8dc94

@ -1,6 +1,5 @@
package com.luoo.music.controller;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -13,6 +12,7 @@ import java.util.stream.Collectors;
import com.luoo.music.dao.CommentDao;
import com.luoo.music.dto.mapper.CommentMapper;
import com.luoo.music.dto.mapper.JournalMapper;
import com.luoo.music.dto.request.CollectQueryReq;
import com.luoo.music.dto.request.JournalQueryReq;
import com.luoo.music.dto.response.CommentDTO;
import com.luoo.music.dto.response.JournalFilterDTO;
@ -21,10 +21,8 @@ import com.luoo.music.dto.response.TagDTO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.*;
import com.luoo.music.pojo.Journal;
import com.luoo.music.pojo.Tag;
@ -125,19 +123,13 @@ public class JournalController {
return set;
}
@ApiOperation(value = "2.查询收藏期刊信息")
@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true),
@ApiImplicitParam(name = "pageNum", value = "分页: 页码以1开始", required = true),
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
@GetMapping("/collect/{userId}/{pageNum}/{pageSize}")
@ApiOperation(value = "2.查询收藏期刊信息", notes = "pageNum/pageSize不传或者小于1则返回所有收藏刊")
@GetMapping("/collect")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<PageResult<JournalRespDTO>> collectPage(
public Result<PageResult<JournalRespDTO>> collectJournals(
@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) {
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
List<String> objectIds=userCollectInfoService.findByUserIdAndCollectType(userId, CollectTypeEnum.JOURNAL, pageable);
@VerifyParam CollectQueryReq queryReq) {
List<String> objectIds= getObjectIds(queryReq);
if (objectIds.isEmpty()) {
return Result.success(new PageResult<JournalRespDTO>(0L, Collections.emptyList()));
}
@ -148,6 +140,14 @@ public class JournalController {
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
}
private List<String> getObjectIds(CollectQueryReq queryReq) {
if(null==queryReq.getPageNum()||queryReq.getPageNum()<1||null==queryReq.getPageSize()||queryReq.getPageSize()<1) {
return userCollectInfoService.findByUserIdAndCollectType(queryReq.getUserId(), CollectTypeEnum.JOURNAL);
}
PageRequest pageRequest = PageRequest.of(queryReq.getPageNum()-1, queryReq.getPageSize());
return userCollectInfoService.findByUserIdAndCollectType(queryReq.getUserId(), CollectTypeEnum.JOURNAL, pageRequest);
}
@ApiOperation(value = "3.根据期刊id查询期刊信息")
@GetMapping("/{id}")
@GlobalInterceptor

@ -78,9 +78,6 @@ public class SongController {
}
@ApiOperation(value = "2.查询收藏歌曲信息", notes = "pageNum/pageSize不传或者小于1则返回所有收藏歌曲")
@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true),
@ApiImplicitParam(name = "pageNum", value = "分页: 页码", required = false),
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = false) })
@GetMapping("/collect")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<PageResult<SongRespDTO>> collectSongs(

@ -61,7 +61,7 @@ public class JournalMapper {
journalRespDTO.setJournalNo(journal.getJournalNo());
journalRespDTO.setTitle(journal.getTitle());
journalRespDTO.setImage(Constants.MUSIC_RESOURCE_PREFIX + journal.getImage());
journalRespDTO.setDate(getEditDate(journal));
journalRespDTO.setDate(getPublishDate(journal));
journalRespDTO.setHaveCollect(journalCollectSet.contains(journalRespDTO.getId()));
journalRespDTO.setIpLocation("广东");
@ -104,8 +104,8 @@ public class JournalMapper {
return journalTagMap.getOrDefault(journalNo, Collections.emptyList());
}
private static String getEditDate(Journal journal) {
LocalDateTime date = null == journal.getUpdateTime() ? journal.getCreateTime() : journal.getUpdateTime();
private static String getPublishDate(Journal journal) {
LocalDateTime date = null == journal.getPubTime() ? journal.getCreateTime() : journal.getPubTime();
return DateUtil.format(date, DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern());
}
}

@ -15,7 +15,7 @@ import annotation.VerifyParam;
public class CollectQueryReq implements Serializable {
private static final long serialVersionUID = 1L;
@VerifyParam(required = true)
@ApiModelProperty(value = "用户id")
@ApiModelProperty(value = "用户id", required = true)
private String userId;
@VerifyParam(required = false)
@ApiModelProperty(value = "分页: 页码", example = "1")

Loading…
Cancel
Save