package com.usky.oa.controller.web;


import com.usky.common.core.bean.CommonPage;
import com.usky.oa.domain.OaApproval;
import com.usky.oa.domain.OaDocument;
import com.usky.oa.service.OaApprovalService;
import com.usky.oa.service.vo.OaApprovalCountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 审批表 前端控制器
 * </p>
 *
 * @author fu
 * @since 2024-12-10
 */
@RestController
@RequestMapping("/oaApproval")
public class OaApprovalController {

    @Autowired
    private OaApprovalService oaApprovalService;

    /**
     * @description: 审批数量统计
     * @author: fyc
     * @email yuchuan.fu@chinausky.com
     * @date: 2024/12/30 16:19
     * @param: []
     * @return: void
     **/
    @GetMapping("/count")
    public OaApprovalCountVO approvalCount() {
        return oaApprovalService.approvalCount();
    }

    /**
     * @description: 我的待办-分页列表
     * @author: fyc
     * @email yuchuan.fu@chinausky.com
     * @date: 2024/12/30 16:19
     * @param: queryType 查询类型(1:待处理，2:已处理，3:我收到，4:我发出)
     * @param: docNo 单据号
     * @param: formSign 表单标识
     * @param: approvalStatus 审批状态 1：审批中 2：审批通过 3：不通过
     * @param: startTime 开始时间
     * @param: endTime 结束时间
     * @param: pageNum 页码
     * @param: pageSize 每页条数
     * @return: com.usky.common.core.bean.CommonPage<com.usky.oa.domain.OaApproval>
     **/
    @GetMapping("/pageList")
    public CommonPage<OaApproval> pageList(@RequestParam(value = "queryType") Integer queryType,
                                           @RequestParam(value = "docNo", required = false) String docNo,
                                           @RequestParam(value = "formSign", required = false) String formSign,
                                           @RequestParam(value = "approvalStatus", required = false) Integer approvalStatus,
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                           @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                           @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return oaApprovalService.pageList(queryType, docNo, formSign, approvalStatus, startTime, endTime, pageNum, pageSize);
    }

    /**
     * @description: 审批
     * @author: fyc
     * @email yuchuan.fu@chinausky.com
     * @date: 2025/1/17 17:32
     * @param: [oaApproval]
     * @return: void
     **/
    @PutMapping("/approve")
    public void add(@RequestParam(value = "id") Integer id,
                    @RequestParam(value = "approvalStatus") Integer approvalStatus,
                    @RequestParam(value = "opinion", required = false, defaultValue = "无") String opinion) {
        oaApprovalService.approve(id, approvalStatus, opinion);
    }

    // xml 流程解析测试
/*    @GetMapping("/analysisTest")
    public void analysisTest(@RequestParam(value = "id") Integer id) {
        oaApprovalService.analysisTest(id);
    }*/

}

