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.dto.req.TeacherApplyDetailReq;
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.TeacherAuthEntryRecordService;

import javax.validation.Valid;

@RestController
@RequestMapping("/teacherAuthEntryRecord")
@Api(value = "老师入驻审核表", tags = "老师入驻审核表")
public class TeacherAuthEntryRecordController extends BaseController {
    @Autowired
    private TeacherAuthEntryRecordService teacherAuthEntryRecordService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @PostMapping("/doApply")
    @ApiOperation(value = "提交申请", notes = "传入teacherAuthEntryRecord")
    public HttpResponseResult<Boolean> doApply(@Valid @RequestBody TeacherApplyDetailReq teacherApplyDetailDto) throws Exception {
        SysUser user = sysUserFeignService.queryUserInfo();
        if (user == null || null == user.getId()) {
            return failed(HttpStatus.FORBIDDEN, "请登录");
        }
        //处理老师申请逻辑
        return teacherAuthEntryRecordService.doApply(teacherApplyDetailDto, user);
    }
}