|
|
@ -1,10 +1,11 @@
|
|
|
|
package com.luoo.music.controller;
|
|
|
|
package com.luoo.music.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.music.dto.response.SongRespDTO;
|
|
|
|
import com.luoo.music.dto.response.SongRespDTO;
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
import com.luoo.music.pojo.Song;
|
|
|
|
import com.luoo.music.pojo.Song;
|
|
|
|
import com.luoo.music.service.SongService;
|
|
|
|
import com.luoo.music.service.SongService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import annotation.GlobalInterceptor;
|
|
|
|
import api.PageResult;
|
|
|
|
import api.PageResult;
|
|
|
|
import api.Result;
|
|
|
|
import api.Result;
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.Constants;
|
|
|
@ -25,147 +26,167 @@ import java.util.stream.Collectors;
|
|
|
|
@RequestMapping("/song")
|
|
|
|
@RequestMapping("/song")
|
|
|
|
public class SongController {
|
|
|
|
public class SongController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private SongService songService;
|
|
|
|
private SongService songService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询全部数据
|
|
|
|
* 查询全部数据
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
* @return
|
|
|
|
@GetMapping
|
|
|
|
*/
|
|
|
|
public Result<List<Song>> findAll(){
|
|
|
|
@GetMapping
|
|
|
|
return Result.success(songService.findAll());
|
|
|
|
public Result<List<Song>> findAll() {
|
|
|
|
}
|
|
|
|
return Result.success(songService.findAll());
|
|
|
|
@ApiOperation(value = "1.根据期刊号查询歌曲信息")
|
|
|
|
}
|
|
|
|
@GetMapping("/getByJournalNo/{journalNo}")
|
|
|
|
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(@PathVariable String journalNo){
|
|
|
|
@ApiOperation(value = "1.根据期刊号查询歌曲信息")
|
|
|
|
List<Song> songs=songService.findByVolid(journalNo);
|
|
|
|
@GetMapping("/getByJournalNo/{journalNo}")
|
|
|
|
List<SongRespDTO> results=songs.stream().map(s->getSongRespDTO(s)).collect(Collectors.toList());
|
|
|
|
@GlobalInterceptor(checkLogin = true)
|
|
|
|
return Result.success(results);
|
|
|
|
public Result<List<SongRespDTO>> getByJournalNo(@RequestHeader(value = "token", required = false) String token,
|
|
|
|
}
|
|
|
|
@PathVariable String journalNo) {
|
|
|
|
|
|
|
|
List<Song> songs = songService.findByVolid(journalNo);
|
|
|
|
private SongRespDTO getSongRespDTO(Song song) {
|
|
|
|
List<SongRespDTO> results = songs.stream().map(s -> getSongRespDTO(s)).collect(Collectors.toList());
|
|
|
|
SongRespDTO songRespDTO = new SongRespDTO();
|
|
|
|
return Result.success(results);
|
|
|
|
songRespDTO.setJournalNo(song.getVolid());
|
|
|
|
}
|
|
|
|
songRespDTO.setAlbum(song.getAlbum());
|
|
|
|
|
|
|
|
songRespDTO.setArtist(song.getArtist());
|
|
|
|
/*
|
|
|
|
songRespDTO.setId(song.getId());
|
|
|
|
* @ApiOperation(value = "2.随机播放歌曲",notes="雀乐FM")
|
|
|
|
songRespDTO.setTitle(song.getName());
|
|
|
|
*
|
|
|
|
songRespDTO.setSrc(Constants.MUSIC_RESOURCE_PREFIX+song.getUrl());
|
|
|
|
* @GetMapping("/random/{limit}")
|
|
|
|
songRespDTO.setPic(Constants.MUSIC_RESOURCE_PREFIX+song.getUrl().replace(".mp3",".jpg"));
|
|
|
|
*
|
|
|
|
songRespDTO.setLrc(Constants.MUSIC_RESOURCE_PREFIX+song.getUrl().replace(".mp3",".lyric"));
|
|
|
|
* @GlobalInterceptor(checkLogin = true) public Result<List<SongRespDTO>>
|
|
|
|
songRespDTO.setSongNo(song.getSongno());
|
|
|
|
* getByJournalNo(@RequestHeader(value = "token", required = false) String
|
|
|
|
return songRespDTO;
|
|
|
|
* token) { List<Song> songs = songService.random(); List<SongRespDTO> results =
|
|
|
|
}
|
|
|
|
* songs.stream().map(s -> getSongRespDTO(s)).collect(Collectors.toList());
|
|
|
|
/**
|
|
|
|
* return Result.success(results); }
|
|
|
|
* 根据ID查询
|
|
|
|
*/
|
|
|
|
* @param id ID
|
|
|
|
|
|
|
|
* @return
|
|
|
|
private SongRespDTO getSongRespDTO(Song song) {
|
|
|
|
*/
|
|
|
|
SongRespDTO songRespDTO = new SongRespDTO();
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
songRespDTO.setJournalNo(song.getVolid());
|
|
|
|
public Result<Song> findById(@PathVariable String id){
|
|
|
|
songRespDTO.setAlbum(song.getAlbum());
|
|
|
|
return Result.success(songService.findById(id));
|
|
|
|
songRespDTO.setArtist(song.getArtist());
|
|
|
|
}
|
|
|
|
songRespDTO.setId(song.getId());
|
|
|
|
|
|
|
|
songRespDTO.setTitle(song.getName());
|
|
|
|
|
|
|
|
songRespDTO.setSrc(Constants.MUSIC_RESOURCE_PREFIX + song.getUrl());
|
|
|
|
/**
|
|
|
|
songRespDTO.setPic(Constants.MUSIC_RESOURCE_PREFIX + song.getUrl().replace(".mp3", ".jpg"));
|
|
|
|
* 分页+多条件查询
|
|
|
|
songRespDTO.setLrc(Constants.MUSIC_RESOURCE_PREFIX + song.getUrl().replace(".mp3", ".lyric"));
|
|
|
|
* @param searchMap 查询条件封装
|
|
|
|
songRespDTO.setSongNo(song.getSongno());
|
|
|
|
* @param page 页码
|
|
|
|
return songRespDTO;
|
|
|
|
* @param size 页大小
|
|
|
|
}
|
|
|
|
* @return 分页结果
|
|
|
|
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
@PostMapping("/search/{page}/{size}")
|
|
|
|
* 根据ID查询
|
|
|
|
public Result<PageResult<Song>> findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
|
|
|
|
*
|
|
|
|
Page<Song> pageList = songService.findSearch(searchMap, page, size);
|
|
|
|
* @param id ID
|
|
|
|
return Result.success(new PageResult<Song>(pageList.getTotalElements(), pageList.getContent()) );
|
|
|
|
* @return
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
|
|
|
public Result<Song> findById(@PathVariable String id) {
|
|
|
|
@PostMapping("/init")
|
|
|
|
return Result.success(songService.findById(id));
|
|
|
|
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>();
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param searchMap 查询条件封装
|
|
|
|
int temp=0;
|
|
|
|
* @param page 页码
|
|
|
|
int num=0;
|
|
|
|
* @param size 页大小
|
|
|
|
for (Map dataMap :data
|
|
|
|
* @return 分页结果
|
|
|
|
) {
|
|
|
|
*/
|
|
|
|
Article article = new Article();
|
|
|
|
@PostMapping("/search/{page}/{size}")
|
|
|
|
article.setVolid(dataMap.get("id")+"");
|
|
|
|
public Result<PageResult<Song>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
|
|
|
article.setTitle(dataMap.get("title")+"");
|
|
|
|
@PathVariable int size) {
|
|
|
|
String avatar = "0000"+dataMap.get("id");
|
|
|
|
Page<Song> pageList = songService.findSearch(searchMap, page, size);
|
|
|
|
String substring = avatar.substring(avatar.length() - 5);
|
|
|
|
return Result.success(new PageResult<Song>(pageList.getTotalElements(), pageList.getContent()));
|
|
|
|
System.out.println(substring);
|
|
|
|
}
|
|
|
|
article.setImage(substring+"/00.jpg");
|
|
|
|
|
|
|
|
if (temp== (int) dataMap.get("id")){
|
|
|
|
@PostMapping("/init")
|
|
|
|
num = num+1;
|
|
|
|
public Result<Void> init(@RequestBody Map map) {
|
|
|
|
}else {
|
|
|
|
List<Map> data = (List) map.get("data");
|
|
|
|
num = 0;
|
|
|
|
System.out.println(data.size());
|
|
|
|
}
|
|
|
|
Song song = new Song();
|
|
|
|
temp = (int) dataMap.get("id");
|
|
|
|
Set<Article> set = new HashSet<Article>();
|
|
|
|
String numstr = "0000"+(num+1);
|
|
|
|
|
|
|
|
System.out.println(numstr.substring(numstr.length()-2));
|
|
|
|
int temp = 0;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
song.setAlbum(dataMap.get("album")+"");
|
|
|
|
for (Map dataMap : data) {
|
|
|
|
song.setArtist(dataMap.get("artist")+"");
|
|
|
|
Article article = new Article();
|
|
|
|
song.setName(dataMap.get("name")+"");
|
|
|
|
article.setVolid(dataMap.get("id") + "");
|
|
|
|
song.setVolid(dataMap.get("id")+"");
|
|
|
|
article.setTitle(dataMap.get("title") + "");
|
|
|
|
song.setUrl(substring+"/"+numstr.substring(numstr.length()-2)+".mp3");
|
|
|
|
String avatar = "0000" + dataMap.get("id");
|
|
|
|
song.setSongno(num+1);
|
|
|
|
String substring = avatar.substring(avatar.length() - 5);
|
|
|
|
|
|
|
|
System.out.println(substring);
|
|
|
|
songService.add(song);
|
|
|
|
article.setImage(substring + "/00.jpg");
|
|
|
|
set.add(article);
|
|
|
|
if (temp == (int) dataMap.get("id")) {
|
|
|
|
}
|
|
|
|
num = num + 1;
|
|
|
|
System.out.println(set.size());
|
|
|
|
} else {
|
|
|
|
|
|
|
|
num = 0;
|
|
|
|
for (Article pojo : set) {
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
// articleService.add(pojo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据条件查询
|
|
|
|
* 根据条件查询
|
|
|
|
* @param searchMap
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @param searchMap
|
|
|
|
*/
|
|
|
|
* @return
|
|
|
|
@PostMapping("/search")
|
|
|
|
*/
|
|
|
|
public Result<List<Song>> findSearch( @RequestBody Map searchMap){
|
|
|
|
@PostMapping("/search")
|
|
|
|
return Result.success(songService.findSearch(searchMap));
|
|
|
|
public Result<List<Song>> findSearch(@RequestBody Map searchMap) {
|
|
|
|
}
|
|
|
|
return Result.success(songService.findSearch(searchMap));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 增加
|
|
|
|
* 增加
|
|
|
|
* @param song
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
* @param song
|
|
|
|
@PostMapping
|
|
|
|
*/
|
|
|
|
public Result<Void> add(@RequestBody Song song){
|
|
|
|
@PostMapping
|
|
|
|
songService.add(song);
|
|
|
|
public Result<Void> add(@RequestBody Song song) {
|
|
|
|
return Result.success();
|
|
|
|
songService.add(song);
|
|
|
|
}
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 修改
|
|
|
|
/**
|
|
|
|
* @param song
|
|
|
|
* 修改
|
|
|
|
*/
|
|
|
|
*
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
* @param song
|
|
|
|
public Result<Void> update(@RequestBody Song song, @PathVariable String id ){
|
|
|
|
*/
|
|
|
|
song.setId(id);
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
songService.update(song);
|
|
|
|
public Result<Void> update(@RequestBody Song song, @PathVariable String id) {
|
|
|
|
return Result.success();
|
|
|
|
song.setId(id);
|
|
|
|
}
|
|
|
|
songService.update(song);
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
/**
|
|
|
|
}
|
|
|
|
* 删除
|
|
|
|
|
|
|
|
* @param id
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
* 删除
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
*
|
|
|
|
public Result<Void> delete(@PathVariable String id ){
|
|
|
|
* @param id
|
|
|
|
songService.deleteById(id);
|
|
|
|
*/
|
|
|
|
return Result.success();
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
}
|
|
|
|
public Result<Void> delete(@PathVariable String id) {
|
|
|
|
|
|
|
|
songService.deleteById(id);
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|