64 lines
2.2 KiB
Java
64 lines
2.2 KiB
Java
package top.baogutang.music.controller;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import top.baogutang.music.domain.Results;
|
|
import top.baogutang.music.domain.req.search.MusicSearchReq;
|
|
import top.baogutang.music.domain.res.search.*;
|
|
import top.baogutang.music.service.IMusicService;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
/**
|
|
*
|
|
* @description:
|
|
*
|
|
* @author: N1KO
|
|
* @date: 2024/12/10 : 21:06
|
|
*/
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("/api/v1/music/search")
|
|
public class MusicSearchController {
|
|
|
|
@Resource
|
|
private IMusicService musicService;
|
|
|
|
@GetMapping
|
|
public Results<MusicSearchRes> search(MusicSearchReq req) {
|
|
MusicSearchRes res = musicService.getMusicService(req.getChannel()).search(req);
|
|
return Results.ok(res);
|
|
}
|
|
|
|
@GetMapping("/playlist")
|
|
public Results<MusicPlaylistRes> playlist(@RequestParam(name = "channel") Integer channel,
|
|
@RequestParam(name = "id") Long id) {
|
|
MusicPlaylistRes res = musicService.getMusicService(channel).playList(id);
|
|
return Results.ok(res);
|
|
}
|
|
|
|
@GetMapping("/album")
|
|
public Results<MusicAlbumRes> album(@RequestParam(name = "channel") Integer channel,
|
|
@RequestParam(name = "id") Long id) {
|
|
MusicAlbumRes res = musicService.getMusicService(channel).album(id);
|
|
return Results.ok(res);
|
|
}
|
|
|
|
@GetMapping("/artist")
|
|
public Results<MusicArtistRes> artist(@RequestParam(name = "channel") Integer channel,
|
|
@RequestParam(name = "id") Long id) {
|
|
MusicArtistRes res = musicService.getMusicService(channel).artist(id);
|
|
return Results.ok(res);
|
|
}
|
|
|
|
@GetMapping("/detail")
|
|
public Results<MusicDetailRes> detail(@RequestParam(name = "channel") Integer channel,
|
|
@RequestParam(name = "id") Long id) {
|
|
MusicDetailRes res = musicService.getMusicService(channel).detail(id);
|
|
return Results.ok(res);
|
|
}
|
|
}
|