package com.ruoyi.web.controller.client;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.MusicInfo;
import com.ruoyi.common.core.domain.entity.RecommendInfo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.IBannerInfoService;
import com.ruoyi.system.service.ICategoryInfoService;
import com.ruoyi.system.service.IMusicInfoService;
import com.ruoyi.system.service.IRecommendInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/client/index")
@RestController
public class IndexController extends BaseController {

    @Autowired
    private IBannerInfoService bannerInfoService;
    @Autowired
    private ICategoryInfoService categoryInfoService;
    @Autowired
    private IMusicInfoService musicInfoService;
    @Autowired
    private IRecommendInfoService recommendInfoService;

    /**
     * @return com.ruoyi.common.core.domain.AjaxResult
     * 获取banner
     */
    @RequestMapping("/getBanner")
    public AjaxResult getBanner(){
        return AjaxResult.success(bannerInfoService.getEnableBanner());
    }

    // 获取分类
    @GetMapping("/getCategory")
    public AjaxResult getCategory(){
        return AjaxResult.success(categoryInfoService.getCategory());
    }

    // 根据分类获取分类音乐
    @GetMapping("/cate/music/{categoryId}")
    public TableDataInfo getCategoryMusic(@PathVariable String categoryId){
        startPage();
        List<MusicInfo> list = musicInfoService.selectMusicInfoByCid(categoryId);
        return getDataTable(list);
    }

    // 获取推荐绑定音乐
    public RecommendInfo getRecommendMusic(){
        recommendInfoService.findRecommendMusic();
        return null;
    }


}
