package com.yingpaipay.business.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.yingpaipay.business.domain.bo.*;
import com.yingpaipay.business.domain.vo.*;
import com.yingpaipay.business.service.IDocumentQcTaskDetailService;
import com.yingpaipay.business.service.IDocumentQcTaskService;
import com.yingpaipay.business.service.IDocumentService;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/home/taskCenter")
public class TaskCenterController extends BaseController {

    private final IDocumentService documentService;
    private final IDocumentQcTaskDetailService qcTaskDetailService;

    @SaCheckPermission("taskCenter:submission:list")
    @GetMapping("/submission/list")
    public TableDataInfo<TaskCenterSubmissionListVo> listSubmission(TaskCenterSubmissionListBo bo, PageQuery pageQuery) {
        return documentService.listOnSubmission(bo, pageQuery);
    }

    @SaCheckPermission("taskCenter:submission:submit")
    @Log(title = "文档", businessType = BusinessType.UPDATE)
    @PutMapping("/submission/submit")
    public R<Void> submitssionSubmit(@RequestBody DocumentSubmitBo bo) {
        return toAjax(documentService.submit(bo));
    }

    @SaCheckPermission("taskCenter:submission:send")
    @Log(title = "文档", businessType = BusinessType.UPDATE)
    @PutMapping("/submission/send")
    public R<Void> submissionSend(@RequestBody DocumentSendBo bo) {
        return toAjax(documentService.send(bo));
    }

    @SaCheckPermission("taskCenter:submission:logAudit")
    @GetMapping("/logAudit")
    public TableDataInfo<DocumentAuditLogVo> logAudit(DocumentAuditLogBo bo, PageQuery pageQuery) {
        return documentService.logAudit(bo, pageQuery);
    }

    @SaCheckPermission("taskCenter:audit:list")
    @GetMapping("/audit/list")
    public TableDataInfo<TaskCenterAuditListVo> listAudit(TaskCenterAuditListBo bo, PageQuery pageQuery) {
        return documentService.listOnAudit(bo, pageQuery);
    }

    @SaCheckPermission("taskCenter:audit:audit")
    @Log(title = "任务中心", businessType = BusinessType.UPDATE)
    @PutMapping("/audit/audit")
    public R<Void> auditAudit(@RequestBody DocumentAuditBo bo) {
        return toAjax(documentService.audit(bo));
    }

    @SaCheckPermission("taskCenter:filing:list")
    @GetMapping("/filing/list")
    public TableDataInfo<TaskCenterFilingListVo> listFiling(TaskCenterFilingListBo bo, PageQuery pageQuery) {
        return documentService.listOnFiling(bo, pageQuery);
    }

    @SaCheckPermission("taskCenter:filing:filing")
    @Log(title = "任务中心", businessType = BusinessType.UPDATE)
    @PutMapping("/filing/filing")
    public R<Void> filingFiling(@RequestBody DocumentFilingBo bo) {
        return toAjax(documentService.filing(bo));
    }

    @SaCheckPermission("taskCenter:qc:list")
    @GetMapping("/qc/list")
    public TableDataInfo<TaskCenterQcListVo> listQc(TaskCenterQcListBo bo, PageQuery pageQuery) {
        return qcTaskDetailService.listOnTaskCenter(bo, pageQuery);
    }

    @SaCheckPermission("taskCenter:qc:submit")
    @Log(title = "任务中心", businessType = BusinessType.UPDATE)
    @PutMapping("/qc/submit")
    public R<Void> qcSubmit(@RequestBody TaskCenterQcSubmitBo bo) {
        return toAjax(qcTaskDetailService.submit(bo));
    }

    @SaCheckPermission("taskCenter:qc:audit")
    @Log(title = "任务中心", businessType = BusinessType.UPDATE)
    @PutMapping("/qc/audit")
    public R<Void> qcAudit(@RequestBody DocumentQcAuditBo bo) {
        return toAjax(qcTaskDetailService.audit(bo));
    }

}
