|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
package com.luoo.music.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.music.dto.response.SongRespDTO;
|
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
|
import com.luoo.music.pojo.Song;
|
|
|
|
|
import com.luoo.music.service.SongService;
|
|
|
|
|
|
|
|
|
|
import annotation.GlobalInterceptor;
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import api.Result;
|
|
|
|
|
import constants.Constants;
|
|
|
|
@ -30,20 +31,36 @@ public class SongController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询全部数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping
|
|
|
|
|
public Result<List<Song>> findAll() {
|
|
|
|
|
return Result.success(songService.findAll());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "1.根据期刊号查询歌曲信息")
|
|
|
|
|
@GetMapping("/getByJournalNo/{journalNo}")
|
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(@PathVariable String journalNo){
|
|
|
|
|
@GlobalInterceptor(checkLogin = true)
|
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(@RequestHeader(value = "token", required = false) String token,
|
|
|
|
|
@PathVariable String journalNo) {
|
|
|
|
|
List<Song> songs = songService.findByVolid(journalNo);
|
|
|
|
|
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s)).collect(Collectors.toList());
|
|
|
|
|
return Result.success(results);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @ApiOperation(value = "2.随机播放歌曲",notes="雀乐FM")
|
|
|
|
|
*
|
|
|
|
|
* @GetMapping("/random/{limit}")
|
|
|
|
|
*
|
|
|
|
|
* @GlobalInterceptor(checkLogin = true) public Result<List<SongRespDTO>>
|
|
|
|
|
* getByJournalNo(@RequestHeader(value = "token", required = false) String
|
|
|
|
|
* token) { List<Song> songs = songService.random(); List<SongRespDTO> results =
|
|
|
|
|
* songs.stream().map(s -> getSongRespDTO(s)).collect(Collectors.toList());
|
|
|
|
|
* return Result.success(results); }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private SongRespDTO getSongRespDTO(Song song) {
|
|
|
|
|
SongRespDTO songRespDTO = new SongRespDTO();
|
|
|
|
|
songRespDTO.setJournalNo(song.getVolid());
|
|
|
|
@ -57,8 +74,10 @@ public class SongController {
|
|
|
|
|
songRespDTO.setSongNo(song.getSongno());
|
|
|
|
|
return songRespDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据ID查询
|
|
|
|
|
*
|
|
|
|
|
* @param id ID
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -67,21 +86,21 @@ public class SongController {
|
|
|
|
|
return Result.success(songService.findById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页+多条件查询
|
|
|
|
|
*
|
|
|
|
|
* @param searchMap 查询条件封装
|
|
|
|
|
* @param page 页码
|
|
|
|
|
* @param size 页大小
|
|
|
|
|
* @return 分页结果
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/search/{page}/{size}")
|
|
|
|
|
public Result<PageResult<Song>> findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int 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");
|
|
|
|
@ -91,8 +110,7 @@ public class SongController {
|
|
|
|
|
|
|
|
|
|
int temp = 0;
|
|
|
|
|
int num = 0;
|
|
|
|
|
for (Map dataMap :data
|
|
|
|
|
) {
|
|
|
|
|
for (Map dataMap : data) {
|
|
|
|
|
Article article = new Article();
|
|
|
|
|
article.setVolid(dataMap.get("id") + "");
|
|
|
|
|
article.setTitle(dataMap.get("title") + "");
|
|
|
|
@ -129,6 +147,7 @@ public class SongController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件查询
|
|
|
|
|
*
|
|
|
|
|
* @param searchMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -137,9 +156,9 @@ public class SongController {
|
|
|
|
|
return Result.success(songService.findSearch(searchMap));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 增加
|
|
|
|
|
*
|
|
|
|
|
* @param song
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping
|
|
|
|
@ -150,6 +169,7 @@ public class SongController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改
|
|
|
|
|
*
|
|
|
|
|
* @param song
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
@ -161,6 +181,7 @@ public class SongController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|