1.add Carousel 2.add find info by id for journal/song

main
Gary 10 months ago
parent 6ce581047b
commit b1fd675442

@ -61,7 +61,7 @@ public class JournalController {
}
Page<Article> pageList = articleService.queryPage(queryReq);
Set<String> journalCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.JOURNAL);
List<JournalRespDTO> list = pageList.stream().map(a -> getArticleRespDTO(a, journalCollectSet))
List<JournalRespDTO> list = pageList.stream().map(a -> getJournalRespDTO(a, journalCollectSet))
.collect(Collectors.toList());
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
}
@ -81,12 +81,23 @@ public class JournalController {
List<String> objectIds=userCollectService.getCollectList(userId,pageNum,pageSize,CollectTypeEnum.JOURNAL);
List<Article> pageList = articleService.orderByField(objectIds);
Set<String> journalCollectSet = objectIds.isEmpty()?Collections.emptySet(): new HashSet<>(objectIds);
List<JournalRespDTO> list = pageList.stream().map(a -> getArticleRespDTO(a, journalCollectSet))
List<JournalRespDTO> list = pageList.stream().map(a -> getJournalRespDTO(a, journalCollectSet))
.collect(Collectors.toList());
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
}
private JournalRespDTO getArticleRespDTO(Article article, Set<String> journalCollectSet) {
@ApiOperation(value = "3.根据期刊id查询期刊信息")
@GetMapping("/{id}")
@GlobalInterceptor
public Result<JournalRespDTO> findById(@RequestHeader(value = "token", required = false) String token,
@PathVariable @VerifyParam(required = true) String id) {
UserLoginDto user = jwtUtil.getUserLoginDto(token);
Article journal=articleService.findById(id);
Set<String> journalCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.JOURNAL);
return Result.success(getJournalRespDTO(journal, journalCollectSet));
}
private JournalRespDTO getJournalRespDTO(Article article, Set<String> journalCollectSet) {
JournalRespDTO journalRespDTO = new JournalRespDTO();
journalRespDTO.setId(article.getId());
journalRespDTO.setJournalNo(article.getVolid());

@ -1,5 +1,6 @@
package com.luoo.music.controller;
import com.luoo.music.dto.response.JournalRespDTO;
import com.luoo.music.dto.response.SongRespDTO;
import com.luoo.music.pojo.Article;
import com.luoo.music.pojo.Song;
@ -64,8 +65,10 @@ public class SongController {
return Result.unauthorized(null);
}
List<Song> songs = songService.findByVolid(journalNo);
Set<String> songCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.SONG);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet)).collect(Collectors.toList());
Set<String> songCollectSet = null == user ? Collections.emptySet()
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.SONG);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet))
.collect(Collectors.toList());
return Result.success(results);
}
@ -74,22 +77,20 @@ public class SongController {
}
@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<SongRespDTO>> collectPage(
@PathVariable @VerifyParam(required = true)String userId,
@PathVariable @VerifyParam(required = true)Integer pageNum,
@PathVariable @VerifyParam(required = true)Integer pageSize) {
List<String> objectIds=userCollectService.getCollectList(userId,pageNum,pageSize,CollectTypeEnum.SONG);
public Result<PageResult<SongRespDTO>> collectPage(@PathVariable @VerifyParam(required = true) String userId,
@PathVariable @VerifyParam(required = true) Integer pageNum,
@PathVariable @VerifyParam(required = true) Integer pageSize) {
List<String> objectIds = userCollectService.getCollectList(userId, pageNum, pageSize, CollectTypeEnum.SONG);
List<Song> songs = songService.orderByField(objectIds);
Set<String> songCollectSet = objectIds.isEmpty()?Collections.emptySet(): new HashSet<>(objectIds);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet)).collect(Collectors.toList());
Set<String> songCollectSet = objectIds.isEmpty() ? Collections.emptySet() : new HashSet<>(objectIds);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet))
.collect(Collectors.toList());
return Result.success(new PageResult<SongRespDTO>(Long.valueOf(results.size()), results));
}
@ -97,16 +98,29 @@ public class SongController {
@ApiImplicitParams({ @ApiImplicitParam(name = "limit", value = "随机歌曲数最少1首最多30首", required = false) })
@GetMapping("/random/{limit}")
@GlobalInterceptor
public Result<List<SongRespDTO>> random(
@RequestHeader(value = "token", required = false) String token,
public Result<List<SongRespDTO>> random(@RequestHeader(value = "token", required = false) String token,
@PathVariable @VerifyParam(required = true, regex = VerifyRegexEnum.RANDOM_SONG_LIMIT) Integer limit) {
List<Song> songs = songService.random(limit);
UserLoginDto user = jwtUtil.getUserLoginDto(token);
Set<String> songCollectSet = null==user?Collections.emptySet():userCollectService.getCollectSet(user.getUserId(),CollectTypeEnum.SONG);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet)).collect(Collectors.toList());
Set<String> songCollectSet = null == user ? Collections.emptySet()
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.SONG);
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet))
.collect(Collectors.toList());
return Result.success(results);
}
@ApiOperation(value = "4.根据歌曲id查询歌曲信息")
@GetMapping("/{id}")
@GlobalInterceptor
public Result<SongRespDTO> findById(@RequestHeader(value = "token", required = false) String token,
@PathVariable @VerifyParam(required = true) String id) {
UserLoginDto user = jwtUtil.getUserLoginDto(token);
Song song = songService.findById(id);
Set<String> songCollectSet = null == user ? Collections.emptySet()
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.SONG);
return Result.success(getSongRespDTO(song, songCollectSet));
}
private SongRespDTO getSongRespDTO(Song song, Set<String> songCollectSet) {
SongRespDTO songRespDTO = new SongRespDTO();
songRespDTO.setJournalNo(song.getVolid());
@ -122,16 +136,15 @@ public class SongController {
return songRespDTO;
}
/**
/* *//**
* ID
*
* @param id ID
* @return
*//*
* @GetMapping("/{id}") public Result<Song> findById(@PathVariable String id) {
* return Result.success(songService.findById(id)); }
*/
@GetMapping("/{id}")
public Result<Song> findById(@PathVariable String id) {
return Result.success(songService.findById(id));
}
/**
* +

@ -0,0 +1,30 @@
package com.luoo.user.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luoo.user.pojo.Carousel;
import com.luoo.user.service.CarouselService;
import api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "IndexController")
@RestController
@RequestMapping("/index")
public class IndexController {
@Resource
private CarouselService carouselService;
@ApiOperation(value = "1.获取轮播图", notes = "返回5个")
@GetMapping("/loadCarousel")
public Result<List<Carousel>> loadCarousel() {
List<Carousel> carouselList = carouselService.loadCarousel();
return Result.success(carouselList);
}
}

@ -0,0 +1,46 @@
package com.luoo.user.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
* app
*/
@Getter
@Setter
@Builder
public class Carousel{
/**
* ID
*/
@ApiModelProperty(value = "自增ID")
private Integer carouselId;
/**
*
*/
@ApiModelProperty(value = "图片")
private String imgPath;
/**
* 0: 1:
*/
@ApiModelProperty(value = "0:歌曲 1:期刊 2:外部连接")
private Integer objectType;
/**
* ID
*/
@ApiModelProperty(value = "对象ID")
private String objectId;
/**
*
*/
@ApiModelProperty(value = "外部连接")
private String outerLink;
}

@ -0,0 +1,24 @@
package com.luoo.user.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.luoo.user.pojo.Carousel;
@Service
public class CarouselService {
private static final List<Carousel> DEFAULT_CAROUSEL_LIST=new ArrayList<>();
static {
DEFAULT_CAROUSEL_LIST.add(Carousel.builder().carouselId(1).imgPath("http://cdn.indie.cn/music/10016/07.jpg").objectType(0).objectId("1643965109602750464").outerLink(null).build());
DEFAULT_CAROUSEL_LIST.add(Carousel.builder().carouselId(2).imgPath("http://cdn.indie.cn/music/00985/00.jpg").objectType(1).objectId("1635099768424370176").outerLink(null).build());
DEFAULT_CAROUSEL_LIST.add(Carousel.builder().carouselId(3).imgPath("http://cdn.indie.cn/music/00984/00.jpg").objectType(1).objectId("1635099812296790016").outerLink(null).build());
DEFAULT_CAROUSEL_LIST.add(Carousel.builder().carouselId(4).imgPath("http://cdn.indie.cn/music/00942/00.jpg").objectType(2).objectId(null).outerLink("http://116.62.145.60:3000/music").build());
DEFAULT_CAROUSEL_LIST.add(Carousel.builder().carouselId(5).imgPath("http://cdn.indie.cn/music/00982/00.jpg").objectType(1).objectId("1635099717706846208").outerLink(null).build());
}
public List<Carousel> loadCarousel() {
return DEFAULT_CAROUSEL_LIST;
}
}
Loading…
Cancel
Save