|
|
|
@ -58,9 +58,10 @@ public class SongController {
|
|
|
|
|
@ApiOperation(value = "1.根据期刊号查询歌曲信息", notes = "若为游客,期刊号须在最新10期内")
|
|
|
|
|
@GetMapping("/getByJournalNo/{journalNo}")
|
|
|
|
|
@GlobalInterceptor
|
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(@RequestHeader(value = "token", required = false) String token,
|
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(
|
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
@PathVariable String journalNo) {
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
|
|
|
|
|
if (null == user && !isLatest10(journalNo)) {
|
|
|
|
|
return Result.unauthorized(null);
|
|
|
|
|
}
|
|
|
|
@ -82,7 +83,9 @@ public class SongController {
|
|
|
|
|
@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,
|
|
|
|
|
public Result<PageResult<SongRespDTO>> collectPage(
|
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
@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);
|
|
|
|
@ -98,10 +101,11 @@ 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 = "Authorization", required = false) String authorization,
|
|
|
|
|
@PathVariable @VerifyParam(required = true, regex = VerifyRegexEnum.RANDOM_SONG_LIMIT) Integer limit) {
|
|
|
|
|
List<Song> songs = songService.random(limit);
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
|
|
|
|
|
Set<String> songCollectSet = null == user ? Collections.emptySet()
|
|
|
|
|
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.SONG);
|
|
|
|
|
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s, songCollectSet))
|
|
|
|
@ -112,9 +116,9 @@ public class SongController {
|
|
|
|
|
@ApiOperation(value = "4.根据歌曲id查询歌曲信息")
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
@GlobalInterceptor
|
|
|
|
|
public Result<SongRespDTO> findById(@RequestHeader(value = "token", required = false) String token,
|
|
|
|
|
public Result<SongRespDTO> findById(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) String id) {
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
|
|
|
|
|
Song song = songService.findById(id);
|
|
|
|
|
Set<String> songCollectSet = null == user ? Collections.emptySet()
|
|
|
|
|
: userCollectService.getCollectSet(user.getUserId(), CollectTypeEnum.SONG);
|
|
|
|
@ -154,99 +158,72 @@ public class SongController {
|
|
|
|
|
* @param size 页大小
|
|
|
|
|
* @return 分页结果
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/search/{page}/{size}")
|
|
|
|
|
public Result<PageResult<Song>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
|
|
|
|
@PathVariable int size) {
|
|
|
|
|
Page<Song> pageList = songService.findSearch(searchMap, page, size);
|
|
|
|
|
return Result.success(new PageResult<Song>(pageList.getTotalElements(), pageList.getContent()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/init")
|
|
|
|
|
public Result<Void> init(@RequestBody Map map) {
|
|
|
|
|
List<Map> data = (List) map.get("data");
|
|
|
|
|
System.out.println(data.size());
|
|
|
|
|
Song song = new Song();
|
|
|
|
|
Set<Article> set = new HashSet<Article>();
|
|
|
|
|
|
|
|
|
|
int temp = 0;
|
|
|
|
|
int num = 0;
|
|
|
|
|
for (Map dataMap : data) {
|
|
|
|
|
Article article = new Article();
|
|
|
|
|
article.setVolid(dataMap.get("id") + "");
|
|
|
|
|
article.setTitle(dataMap.get("title") + "");
|
|
|
|
|
String avatar = "0000" + dataMap.get("id");
|
|
|
|
|
String substring = avatar.substring(avatar.length() - 5);
|
|
|
|
|
System.out.println(substring);
|
|
|
|
|
article.setImage(substring + "/00.jpg");
|
|
|
|
|
if (temp == (int) dataMap.get("id")) {
|
|
|
|
|
num = num + 1;
|
|
|
|
|
} else {
|
|
|
|
|
num = 0;
|
|
|
|
|
}
|
|
|
|
|
temp = (int) dataMap.get("id");
|
|
|
|
|
String numstr = "0000" + (num + 1);
|
|
|
|
|
System.out.println(numstr.substring(numstr.length() - 2));
|
|
|
|
|
|
|
|
|
|
song.setAlbum(dataMap.get("album") + "");
|
|
|
|
|
song.setArtist(dataMap.get("artist") + "");
|
|
|
|
|
song.setName(dataMap.get("name") + "");
|
|
|
|
|
song.setVolid(dataMap.get("id") + "");
|
|
|
|
|
song.setUrl(substring + "/" + numstr.substring(numstr.length() - 2) + ".mp3");
|
|
|
|
|
song.setSongno(num + 1);
|
|
|
|
|
|
|
|
|
|
songService.add(song);
|
|
|
|
|
set.add(article);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(set.size());
|
|
|
|
|
|
|
|
|
|
for (Article pojo : set) {
|
|
|
|
|
// articleService.add(pojo);
|
|
|
|
|
}
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/*
|
|
|
|
|
* @PostMapping("/search/{page}/{size}") public Result<PageResult<Song>>
|
|
|
|
|
* findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
|
|
|
|
*
|
|
|
|
|
* @PathVariable int size) { Page<Song> pageList =
|
|
|
|
|
* songService.findSearch(searchMap, page, size); return Result.success(new
|
|
|
|
|
* PageResult<Song>(pageList.getTotalElements(), pageList.getContent())); }
|
|
|
|
|
*
|
|
|
|
|
* @PostMapping("/init") public Result<Void> init(@RequestBody Map map) {
|
|
|
|
|
* List<Map> data = (List) map.get("data"); System.out.println(data.size());
|
|
|
|
|
* Song song = new Song(); Set<Article> set = new HashSet<Article>();
|
|
|
|
|
*
|
|
|
|
|
* int temp = 0; int num = 0; for (Map dataMap : data) { Article article = new
|
|
|
|
|
* Article(); article.setVolid(dataMap.get("id") + "");
|
|
|
|
|
* article.setTitle(dataMap.get("title") + ""); String avatar = "0000" +
|
|
|
|
|
* dataMap.get("id"); String substring = avatar.substring(avatar.length() - 5);
|
|
|
|
|
* System.out.println(substring); article.setImage(substring + "/00.jpg"); if
|
|
|
|
|
* (temp == (int) dataMap.get("id")) { num = num + 1; } else { num = 0; } temp =
|
|
|
|
|
* (int) dataMap.get("id"); String numstr = "0000" + (num + 1);
|
|
|
|
|
* System.out.println(numstr.substring(numstr.length() - 2));
|
|
|
|
|
*
|
|
|
|
|
* song.setAlbum(dataMap.get("album") + "");
|
|
|
|
|
* song.setArtist(dataMap.get("artist") + ""); song.setName(dataMap.get("name")
|
|
|
|
|
* + ""); song.setVolid(dataMap.get("id") + ""); song.setUrl(substring + "/" +
|
|
|
|
|
* numstr.substring(numstr.length() - 2) + ".mp3"); song.setSongno(num + 1);
|
|
|
|
|
*
|
|
|
|
|
* songService.add(song); set.add(article); } System.out.println(set.size());
|
|
|
|
|
*
|
|
|
|
|
* for (Article pojo : set) { // articleService.add(pojo); } return
|
|
|
|
|
* Result.success(); }
|
|
|
|
|
*
|
|
|
|
|
*//**
|
|
|
|
|
* 根据条件查询
|
|
|
|
|
*
|
|
|
|
|
* @param searchMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/search")
|
|
|
|
|
public Result<List<Song>> findSearch(@RequestBody Map searchMap) {
|
|
|
|
|
return Result.success(songService.findSearch(searchMap));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/*
|
|
|
|
|
* @PostMapping("/search") public Result<List<Song>> findSearch(@RequestBody Map
|
|
|
|
|
* searchMap) { return Result.success(songService.findSearch(searchMap)); }
|
|
|
|
|
*
|
|
|
|
|
*//**
|
|
|
|
|
* 增加
|
|
|
|
|
*
|
|
|
|
|
* @param song
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping
|
|
|
|
|
public Result<Void> add(@RequestBody Song song) {
|
|
|
|
|
songService.add(song);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/*
|
|
|
|
|
* @PostMapping public Result<Void> add(@RequestBody Song song) {
|
|
|
|
|
* songService.add(song); return Result.success(); }
|
|
|
|
|
*
|
|
|
|
|
*//**
|
|
|
|
|
* 修改
|
|
|
|
|
*
|
|
|
|
|
* @param song
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
|
public Result<Void> update(@RequestBody Song song, @PathVariable String id) {
|
|
|
|
|
song.setId(id);
|
|
|
|
|
songService.update(song);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/*
|
|
|
|
|
* @PutMapping("/{id}") public Result<Void> update(@RequestBody Song
|
|
|
|
|
* song, @PathVariable String id) { song.setId(id); songService.update(song);
|
|
|
|
|
* return Result.success(); }
|
|
|
|
|
*
|
|
|
|
|
*//**
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*//*
|
|
|
|
|
* @DeleteMapping("/{id}") public Result<Void> delete(@PathVariable String id) {
|
|
|
|
|
* songService.deleteById(id); return Result.success(); }
|
|
|
|
|
*/
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|
public Result<Void> delete(@PathVariable String id) {
|
|
|
|
|
songService.deleteById(id);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|