content: package cn.edu.seig.vibemusic.controller;
  
  
  import cn.edu.seig.vibemusic.model.dto.SongDTO;
  import cn.edu.seig.vibemusic.model.vo.SongDetailVO;
  import cn.edu.seig.vibemusic.model.vo.SongVO;
  import cn.edu.seig.vibemusic.result.PageResult;
  import cn.edu.seig.vibemusic.result.Result;
  import cn.edu.seig.vibemusic.service.ISongService;
  import jakarta.servlet.http.HttpServletRequest;
  import jakarta.validation.Valid;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  /**
   * <p>
   * 前端控制器
   * </p>
   *
   * @author sunpingli
   * @since 2025-01-09
   */
  @RestController
  @RequestMapping("/song")
  public class SongController {
  
      @Autowired
      private ISongService songService;
  
      /**
       * 获取所有歌曲
       *
       * @param songDTO songDTO
       * @return 歌曲列表
       */
      @PostMapping("/getAllSongs")
      public Result<PageResult<SongVO>> getAllSongs(@RequestBody @Valid SongDTO songDTO, HttpServletRequest request) {
          return songService.getAllSongs(songDTO, request);
      }
  
      /**
       * 获取推荐歌曲
       * 推荐歌曲的数量为 20
       *
       * @param request 请求
       * @return 推荐歌曲列表
       */
      @GetMapping("/getRecommendedSongs")
      public Result<List<SongVO>> getRecommendedSongs(HttpServletRequest request) {
          return songService.getRecommendedSongs(request);
      }
  
      /**
       * 获取歌曲详情
       *
       * @param songId 歌曲id
       * @return 歌曲详情
       */
      @GetMapping("/getSongDetail/{id}")
      public Result<SongDetailVO> getSongDetail(@PathVariable("id") Long songId, HttpServletRequest request) {
          return songService.getSongDetail(songId, request);
      }
  
  
  }
  