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.MusicGroupService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.security.AuthUser;
import com.ym.mec.common.security.SecurityUtils;
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("musicGroup")
@Api(tags = "乐团服务")
@RestController
public class MusicGroupController extends BaseController {

    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private MusicGroupService musicGroupService;

    @ApiOperation("获取学生所在乐团列表")
    @GetMapping(value = "/queryUserMusicGroups")
    public Object queryUserMusicGroups(){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null){
            return failed("获取用户信息失败");
        }
        return succeed(musicGroupService.queryUserMusicGroups(sysUser.getId()));
    }

    @ApiOperation("获取学生个人中心乐团信息")
    @GetMapping(value = "/queryPersonalMusicGroups")
    public Object queryPersonalMusicGroups(){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null){
            return failed("获取用户信息失败");
        }
        return succeed(musicGroupService.queryPersonalMusicGroups(sysUser.getId()));
    }

    @ApiOperation(value = "根据学员编号，获取有关联的老师列表")
    @GetMapping("/findTeachersByStuId")
    public Object findTeachersByStuId(){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null){
            return failed("获取用户信息失败");
        }
        return succeed(musicGroupService.findTeachersByStuId(sysUser.getId()));
    }
}
