package cn.teammodel.controller.admin.controller;

import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.AdminIndexDutyService;
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
import cn.teammodel.model.dto.admin.teacher.TeacherDto;
import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
import cn.teammodel.model.vo.admin.DutyIndexData;
import cn.teammodel.model.vo.admin.DutyNodeRankVo;
import cn.teammodel.model.vo.admin.DutyRankPo;
import cn.teammodel.model.vo.weekDuty.DutyRecordVo;
import cn.teammodel.service.DutyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @author winter
 * @create 2024-01-09 17:59
 */
@RestController
@RequestMapping("admin/duty")
@Api(tags = "管理员端-值周巡检")
public class AdminDutyController {
    @Resource
    private DutyService dutyService;

    @Resource
    private AdminIndexDutyService adminIndexDutyService;

    @PostMapping("records")
    @ApiOperation("获取班级评价数据")
    public R<List<DutyRecordVo>> findRecords(@Valid @RequestBody AdminFindDutyRecordDto adminFindDutyRecordDto) {
        List<DutyRecordVo> res = dutyService.findAdminRecords(adminFindDutyRecordDto);
        return R.success(res);
    }

    @PostMapping("index")
    @ApiOperation("获取首页数据")
    public R<DutyIndexData> index(@Valid @RequestBody TimeRangeDto timeRangeDto){
        DutyIndexData dutyIndexData = adminIndexDutyService.getIndexData(timeRangeDto);
        return R.success(dutyIndexData);
    }

    @PostMapping("classRank")
    @ApiOperation("班级评价活跃排行榜: Top10")
    public R<List<DutyRankPo>> classRank(@Valid @RequestBody TimeRangeDto timeRangeDto) {
        List<DutyRankPo> res = adminIndexDutyService.classRank(timeRangeDto);
        return R.success(res);
    }

    @PostMapping("teacherRank")
    @ApiOperation("老师评价活跃排行榜: Top10")
    public R<List<DutyRankPo>> teacherRank(@Valid @RequestBody TimeRangeDto timeRangeDto) {
        List<DutyRankPo> res = adminIndexDutyService.teacherRank(timeRangeDto);
        return R.success(res);
    }
    @PostMapping("dutyNodeRank")
    @ApiOperation("评价指标活跃排行榜: Top10")
    public R<List<DutyNodeRankVo>> appraiseNodeRank(@Valid @RequestBody TimeRangeDto timeRangeDto) {
        List<DutyNodeRankVo> res = adminIndexDutyService.appraiseNodeRank(timeRangeDto);
        return R.success(res);
    }
    @PostMapping("getLessonRecord")
    @ApiOperation("获取课堂记录")
    public R<Map<String, Object> > appraiseNodeRank(@Valid @RequestBody LessonRecordDto lessonRecordDto , HttpServletRequest request) {
        Map<String, Object> res = adminIndexDutyService.getLessonRecord(lessonRecordDto,request);
        return R.success(res);
    }
    @PostMapping("getTeachingQuality")
    @ApiOperation("获取教学质量")
    public R<List<Map<String, Object>> > getTeachingQuality(@Valid @RequestBody TeacherDto teacherDto , HttpServletRequest request) {
        List<Map<String, Object>> res = adminIndexDutyService.getTeachingQuality(teacherDto,request);
        return R.success(res);
    }
}
