package com.ym.mec.student.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.service.ClassGroupService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("course")
@Api(tags = "课程服务")
@RestController
public class CourseController extends BaseController {

    @Autowired
    private ClassGroupService classGroupService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation("获取学生所购买课程列表")
    @GetMapping(value = "/queryUserMusicGroups")
    public Object queryCoursePage(){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null){
            return failed("获取用户信息失败");
        }
        return succeed(classGroupService.queryCoursePage(sysUser.getId()));
    }

    @ApiOperation("获取学员所有群组")
    @GetMapping(value = "/queryUserGroups")
    public Object queryUserGroups(){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null){
            return failed("获取用户信息失败");
        }
        return succeed(classGroupService.queryUserGroups(sysUser.getId()));
    }
}
