package com.keao.edu.controller;


import com.keao.edu.auth.api.client.SysUserFeignService;
import com.keao.edu.auth.api.entity.SysUser;
import com.keao.edu.common.controller.BaseController;
import com.keao.edu.common.entity.HttpResponseResult;
import com.keao.edu.user.api.entity.Student;
import com.keao.edu.user.service.StudentService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统配置控制层
 */
@RestController
@Api(tags = "学员服务")
@RequestMapping(value = "student")
public class StudentController extends BaseController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation(value = "获取学生信息")
    @GetMapping(value = "getStudent")
    public HttpResponseResult<Student> getStudent() {
        SysUser user = sysUserFeignService.queryUserInfo();
        return succeed(studentService.getStudent(user.getId()));
    }

    @ApiOperation(value = "更新学员基本信息")
    @PostMapping(value = "updateInfo")
    public HttpResponseResult<Student> updateInfo(Student student) {
        SysUser user = sysUserFeignService.queryUserInfo();
        student.setUserId(user.getId());
        return succeed(studentService.updateInfo(student));
    }

}
