package com.yonge.cooleshow.teacher.task;

import com.yonge.cooleshow.biz.dal.entity.TeacherTotal;
import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
import com.yonge.cooleshow.biz.dal.service.TeacherTotalService;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @Author: liweifan
 * @Data: 2022/3/28 15:50
 */
@RestController
@RequestMapping("/task")
@ApiIgnore
public class TaskController extends BaseController {
    @Autowired
    private TeacherTotalService teacherTotalService;
    @Autowired
    private CourseGroupService courseGroupService;
    @Autowired
    private CourseScheduleService scheduleService;
    @Autowired
    private LiveRoomService liveRoomService;


    /***
     * 查询所有老师统计数据
     * @author liweifan
     * @updateTime 2022/3/28 10:12
     * @return: com.yonge.cooleshow.common.entity.HttpResponseResult<java.util.List < com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo>>
     */
    @GetMapping("/queryTeacherTotal")
    public HttpResponseResult<List<TeacherTotal>> queryTeacherTotal() {
        return succeed(teacherTotalService.queryTeacherTotal());
    }

    /**
     * <p>定时将符合开售日期的未开售的直播课课程组修改为报名中状态-每隔10分钟执行一次
     * <p>定时将符合结束售卖日期的在售卖中的直播课课程组修改为取消或者成课状态状态-每隔10分钟执行一次
     */
    @GetMapping("/opsCourseGroup")
    public HttpResponseResult<Object> opsCourseGroup() {
        courseGroupService.opsCourseGroup();
        return HttpResponseResult.succeed();
    }

    @ApiOperation("定时任务-销毁房间-直播间")
    @GetMapping("/destroyExpiredLiveRoom")
    public void destroyExpiredLiveRoom() {
        liveRoomService.destroyExpiredLiveRoom();
    }

    @ApiOperation("定时任务-创建房间-直播间")
    @GetMapping("/createCourseLiveRoom")
    public void createCourseLiveRoom() {
        liveRoomService.createCourseLiveRoom();
    }

    @GetMapping("/getRedisValueByKey")
    public HttpResponseResult<Object> getRedisValueByKey(String key) {
        return succeed(teacherTotalService.getRedisValueByKey(key));
    }

    @GetMapping("/courseRemind")
    public HttpResponseResult<Object> courseRemind() {
        scheduleService.courseRemind();
        return HttpResponseResult.succeed();
    }

    @GetMapping("/courseStatus")
    public HttpResponseResult<Object> courseStatus() {
        scheduleService.scheduleTask();
        return HttpResponseResult.succeed();
    }

    @GetMapping("/teacherSalary")
    public HttpResponseResult<Object> teacherSalary() {
        scheduleService.teacherSalaryTask();
        return HttpResponseResult.succeed();
    }
}
