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.dal.entity.ExtracurricularExercisesMessage;
import com.ym.mec.biz.service.ExtracurricularExercisesMessageService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Joburgess
 * @Date 2020/3/26
 */
@Api(tags = "课外训练评论服务")
@RequestMapping("extracurricularExercisesMessage")
@RestController
public class ExtracurricularExercisesMessageController extends BaseController {

    @Autowired
    private ExtracurricularExercisesMessageService extracurricularExercisesMessageService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation(value = "添加学生作业评论")
    @GetMapping("/addStudentExtraExerciseComment")
    public HttpResponseResult addStudentExtraExerciseComment(ExtracurricularExercisesMessage extracurricularExercisesMessage){
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed(HttpStatus.FORBIDDEN, "请登录");
        }
        extracurricularExercisesMessage.setUserId(sysUser.getId());
        extracurricularExercisesMessage.setRole("STUDENT");
        extracurricularExercisesMessageService.addStudentExtraExerciseComment(extracurricularExercisesMessage);
        return succeed();
    }

}
