package com.ym.mec.web.controller.education;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dao.EmployeeDao;
import com.ym.mec.biz.dal.entity.CourseScheduleReview;
import com.ym.mec.biz.dal.entity.Employee;
import com.ym.mec.biz.dal.page.CourseReview4EduQueryInfo;
import com.ym.mec.biz.dal.page.CourseReviewQueryInfo;
import com.ym.mec.biz.service.CourseReviewService;
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.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RequestMapping("eduCourseReview")
@Api(tags = "教务端课程评价")
@RestController
public class EduCourseReviewController extends BaseController {

    @Autowired
    private SysUserFeignService sysUserFeignService;

    @Autowired
    private CourseReviewService courseReviewService;


    @ApiOperation(value = "网管课课程评论管理")
    @GetMapping("getPracticeGroup")
    public Object getPracticeGroup(CourseReview4EduQueryInfo queryInfo) {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed("用户信息获取失败");
        }
        queryInfo.setEduTeacherId(sysUser.getId());
        return succeed(courseReviewService.findPracticeGroupReviews4Edu(queryInfo));
    }

    @ApiOperation(value = "网管课评论详情")
    @GetMapping("getReviewInfo")
    public HttpResponseResult getReviewInfo(int id) {
        return succeed(courseReviewService.getReviewInfo(id));
    }

    @ApiOperation(value = "教务评论")
    @GetMapping("updateReviewInfo")
    public HttpResponseResult updateReviewInfo(CourseScheduleReview courseScheduleReview) {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed("用户信息获取失败");
        }
        return succeed(courseReviewService.updateReview(courseScheduleReview));
    }

}
