package com.ym.mec.web.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.page.CourseReviewQueryInfo;
import com.ym.mec.biz.service.CourseReviewService;
import com.ym.mec.biz.service.OrganizationService;
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.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;

@RequestMapping("courseReview")
@Api(tags = "课程评价")
@RestController
public class CourseReviewController extends BaseController {

    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private OrganizationService organizationService;
    @Autowired
    private CourseReviewService courseReviewService;


    @ApiOperation(value = "网管课课程评论管理")
    @GetMapping("getPracticeGroup")
    @PreAuthorize("@pcs.hasPermissions('courseReview/getPracticeGroup')")
    public Object getPracticeGroup(CourseReviewQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        return succeed(courseReviewService.findPracticeGroupReviews(queryInfo));
    }

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

    @ApiOperation(value = "获取老师评价和学生评价")
    @GetMapping("getStuAndTeaReview")
    @PreAuthorize("@pcs.hasPermissions('courseReview/getStuAndTeaReview')")
    public HttpResponseResult getStuAndTeaReview(Long courseId) {
        return succeed(courseReviewService.getStuAndTeaReview(courseId));
    }

    @ApiOperation(value = "VIP课课程评论管理")
    @GetMapping("getVipGroup")
    @PreAuthorize("@pcs.hasPermissions('courseReview/getVipGroup')")
    public Object getVipGroup(CourseReviewQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        return succeed(courseReviewService.getVipCourseReviews(queryInfo));
    }

}
