package com.qmth.distributed.print.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qmth.boot.api.annotation.Aac;
import com.qmth.boot.api.annotation.BOOL;
import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.distributed.print.business.bean.result.WorkResult;
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
import com.qmth.distributed.print.business.service.ExamTaskService;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.entity.SysUser;
import com.qmth.teachcloud.common.util.Result;
import com.qmth.teachcloud.common.util.ResultUtil;
import com.qmth.teachcloud.common.util.ServletUtil;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Description: 工作台 前端控制器
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/4/8
 */
@Api(tags = "工作台Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.work}")
//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
public class WorkController {

    @Resource
    ExamTaskService examTaskService;

    //    @ApiOperation(value = "命题待办接口")
//    @RequestMapping(value = "/exam/task/ready", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskReady(@RequestParam(value = "pageNumber", required = true) Integer pageNumber,
//                                @RequestParam(value = "pageSize", required = true) Integer pageSize) {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryUserByMyWork(new Page<>(pageNumber, pageSize), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.READY.name(), ExamStatusEnum.STAGE.name()));
//    }
//
//    @ApiOperation(value = "命题待办计数接口")
//    @RequestMapping(value = "/exam/task/ready_count", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskReadyCount() {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryUserByMyWork(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.READY.name(), ExamStatusEnum.STAGE.name()).getRecords().size());
//    }
//
//    @ApiOperation(value = "命题分配待办接口")
//    @RequestMapping(value = "/exam/task/new", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskNew(@RequestParam(value = "pageNumber", required = true) Integer pageNumber,
//                              @RequestParam(value = "pageSize", required = true) Integer pageSize) {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryByMyWork(new Page<>(pageNumber, pageSize), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.NEW.name()));
//    }
//
//    @ApiOperation(value = "命题分配待办计数接口")
//    @RequestMapping(value = "/exam/task/new_count", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskNewCount() {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryByMyWork(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.NEW.name()).getRecords().size());
//    }
//
//    @ApiOperation(value = "审核待办接口")
//    @RequestMapping(value = "/exam/task/submit", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskSubmit(@RequestParam(value = "pageNumber", required = true) Integer pageNumber,
//                                 @RequestParam(value = "pageSize", required = true) Integer pageSize) {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryByMyWorkSubmit(new Page<>(pageNumber, pageSize), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.SUBMIT));
//    }
//
//    @ApiOperation(value = "审核待办计数接口")
//    @RequestMapping(value = "/exam/task/submit_count", method = RequestMethod.POST)
//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
//    public Result examTaskSubmitCount() {
//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
//        return ResultUtil.ok(examTaskService.queryByMyWorkSubmit(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), sysUser.getId(), sysUser.getSchoolId(), ExamStatusEnum.SUBMIT).getRecords().size());
//    }

    @ApiOperation(value = "获取待办接口")
    @RequestMapping(value = "/exam/task/ready", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
    public Result getFlowTaskReady(@ApiParam(value = "页码", required = true) @RequestParam Integer pageNumber,
                                   @ApiParam(value = "数量", required = true) @RequestParam Integer pageSize) {
        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
        return ResultUtil.ok(examTaskService.getFlowTaskReadyList(new Page<>(pageNumber, pageSize), SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), sysUser.getId()));
    }

    @ApiOperation(value = "获取待办计数接口")
    @RequestMapping(value = "/exam/task/ready_count", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = WorkResult.class)})
    public Result getFlowTaskReadyCount() {
        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
        return ResultUtil.ok(examTaskService.getFlowTaskReadyList(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), sysUser.getId()).getRecords().size());
    }
}

