package com.chushang.inspection.project.controller;

import com.chushang.common.core.web.AjaxResult;
import com.chushang.common.log.annotation.SysLog;
import com.chushang.common.log.enums.BusinessType;
import com.chushang.inspection.project.dto.AuditDTO;
import com.chushang.inspection.project.dto.PageAuditDTO;
import com.chushang.inspection.project.service.WrkAuditService;
import com.chushang.security.annotation.RequiresPermissions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @auther: zhao
 * @date: 2024/6/15 11:21
 */
@Slf4j
@RestController
@RequestMapping(value = "/project/audit")
public class WrkAuditController {

    @Resource
    WrkAuditService auditService;

    /**
     * 审核
     * 传递合同id
     */
    @PostMapping(value = "/audit/{contractId}")
    @RequiresPermissions("project:audit:audit")
    public AjaxResult audit(@PathVariable Long contractId,
                            @RequestBody@Validated AuditDTO auditDTO)
    {
        auditService.audit(contractId, auditDTO);
        return AjaxResult.success();
    }

    /**
     * 审核
     * 传递合同id
     */
    @PostMapping(value = "/revoke/{contractId}")
    @RequiresPermissions("project:audit:revoke")
    public AjaxResult revoke(@PathVariable Long contractId)
    {
        auditService.revoke(contractId);
        return AjaxResult.success();
    }

    /**
     * 获取合同详情
     */
    @GetMapping(value = "/contract/{contractId}")
    @RequiresPermissions(value = "inspection:contract:info")
    public AjaxResult getContractInfo(@PathVariable Long contractId){
        return AjaxResult.success(auditService.getContractInfo(contractId));
    }



}
