package com.yonge.cooleshow.teacher.controller;

import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import com.yonge.cooleshow.biz.dal.service.TeacherAuthMusicianRecordService;

@RestController
@RequestMapping("/teacherAuthMusicianRecord")
@Api(value = "老师音乐人审核表", tags = "老师音乐人审核表")
public class TeacherAuthMusicianRecordController extends BaseController {
    @Autowired
    private TeacherAuthMusicianRecordService teacherAuthMusicianRecordService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    /**
     * 获取音乐人审核状态
     */
    @GetMapping("/getMusicianAuthStatus")
    @ApiOperation(value = "获取音乐人审核状态")
    public HttpResponseResult<AuthStatusEnum> getMusicianAuthStatus() {
        SysUser user = sysUserFeignService.queryUserInfo();
        if (user == null || null == user.getId()) {
            return failed(HttpStatus.FORBIDDEN, "请登录");
        }
        AuthStatusEnum musicianAuthStatus = teacherAuthMusicianRecordService.getMusicianAuthStatus(user.getId());
        return succeed(musicianAuthStatus);
    }

    @PostMapping("/doApply")
    @ApiOperation(value = "提交申请", notes = "传入teacherAuthEntryRecord")
    public HttpResponseResult<Boolean> doApply() {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        //处理老师申请逻辑
        return teacherAuthMusicianRecordService.doApply(sysUser.getId());
    }

}