package com.yuchen.saas.park.service.controller.work;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.work.SaasWorkOrderDelayApprovalDto;
import com.yuchen.saas.park.api.dto.work.SaasWorkOrderDelayApprovalQueryDto;
import com.yuchen.saas.park.api.dto.work.WorkOrderDelayApplyDto;
import com.yuchen.saas.park.api.vo.work.SaasWorkOrderDelayApprovalStatisticsVo;
import com.yuchen.saas.park.api.vo.work.SaasWorkOrderDelayApprovalVo;
import com.yuchen.saas.park.service.service.work.ISaasWorkOrderDelayApprovalService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 工单延迟审批表 前端控制器
 * </p>
 *
 * @author caiwq
 * @since 2024-04-07
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/workOrderDelayApproval")
public class SaasWorkOrderDelayApprovalController {

    private final ISaasWorkOrderDelayApprovalService baseService;

    /**
     * 工单延时申请
     * @param workOrderDelayApplyDto 工单延时申请Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/apply")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "工单延时申请", notes = "工单延时申请")
    public R<Boolean> delayApply(@RequestBody @Validated WorkOrderDelayApplyDto workOrderDelayApplyDto) {
        return R.data(baseService.delayApply(workOrderDelayApplyDto));
    }

    /**
     * 工单延时审批
     * @param workOrderDelayApprovalDto 工单延时审批Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/approval")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "工单延时审批", notes = "工单延时审批")
    public R<Boolean> delayApproval(@RequestBody @Validated SaasWorkOrderDelayApprovalDto workOrderDelayApprovalDto) {
        return R.data(baseService.delayApproval(workOrderDelayApprovalDto));
    }

    /**
     * 工单延时审批列表数量统计
     * @return 延时审批列表数量统计Vo
     */
    @GetMapping("/statisticsAuditCount")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "工单延时审批列表数量统计", notes = "工单延时审批列表数量统计")
    public R<SaasWorkOrderDelayApprovalStatisticsVo> statisticsAuditCount() {
        return R.data(baseService.statisticsAuditCount());
    }

    /**
     * 工单延时审批列表(分页)
     * @param queryDto 工单类型列表查询参数
     * @return 消息列表Vo
     */
    @PostMapping("/list")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "工单延时审批列表(分页)", notes = "工单延时审批列表(分页)")
    public R<NestPage<SaasWorkOrderDelayApprovalVo>> list(@RequestBody SaasWorkOrderDelayApprovalQueryDto queryDto) {
        return R.data(baseService.list(queryDto));
    }

}
