package com.zcloud.primeport.web;


import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.primeport.api.VehicleAuditServiceI;
import com.zcloud.primeport.dto.VehicleAuditAddCmd;
import com.zcloud.primeport.dto.VehicleAuditPageQry;
import com.zcloud.primeport.dto.VehicleAuditUpdateCmd;
import com.zcloud.primeport.dto.clientobject.VehicleAuditCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:24
 */
@Api(tags = "车辆审批")
@RequestMapping("/${application.gateway}/vehicleAudit")
@RestController
@AllArgsConstructor
public class VehicleAuditController {
    private final VehicleAuditServiceI vehicleAuditService;

    //    @ApiOperation("新增")
//    @PostMapping("/save")
//    public SingleResponse<VehicleAuditCO> add(@Validated @RequestBody VehicleAuditAddCmd cmd) {
//        SSOUser ssoUser = AuthContext.getCurrentUser();
//        return vehicleAuditService.add(cmd);
//    }

    @ApiOperation("待审批数据分页")
    @PostMapping("/pendingApprovalList")
    public PageResponse<VehicleAuditCO> page(@RequestBody VehicleAuditPageQry qry) {
        return vehicleAuditService.listPage(qry);
    }

    @ApiOperation("车辆审批记录")
    @PostMapping("/carApprovalLogByvehicleApplyIdList")
    public PageResponse<VehicleAuditCO> carApprovalLogByvehicleApplyIdList(@RequestBody VehicleAuditPageQry qry) {
        return vehicleAuditService.carApprovalLogByvehicleApplyIdList(qry);
    }

    @ApiOperation("审批人审批")
    @PostMapping("/audit")
    public Response audit(@RequestBody VehicleAuditUpdateCmd cmd) {
        vehicleAuditService.audit(cmd);
        return Response.buildSuccess();
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<VehicleAuditCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(vehicleAuditService.getInfoById(id));
    }

}

