package cn.iocoder.yudao.module.bpm.api.oa;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent;
import cn.iocoder.yudao.module.bpm.api.oa.vo.contract.BpmOAContractDTO;
import cn.iocoder.yudao.module.bpm.api.oa.vo.contract.BpmOAContractVO;
import cn.iocoder.yudao.module.bpm.api.oa.vo.contract.ContractStatisticsDTO;
import cn.iocoder.yudao.module.bpm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 流程实例")
public interface BpmOAContractApi {

    String PREFIX = ApiConstants.PREFIX + "/oa/contract";

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建合同审批流程")
    @Idempotent(timeout = 10)
    CommonResult<Long> create(@RequestBody BpmOAContractDTO createReqVO);

    @GetMapping(PREFIX + "/get-contract-count")
    @Operation(summary = "获得当日合同统计 | 新增数量、新增金额")
    CommonResult<ContractStatisticsDTO> getContractCount(@RequestParam("relation") String relation);

    @GetMapping(PREFIX + "/get-contract-statistics")
    @Operation(summary = "获得指定用户的合同统计信息")
    CommonResult<List<ContractStatisticsDTO>> getContractStatistics(@RequestParam("userId") List<Long> userIds,
                                                                    @RequestParam(name = "createTime", required = false) LocalDateTime[] createTime);

    @PostMapping(PREFIX + "/getList")
    @Operation(summary = "获得合同列表")
    CommonResult<List<BpmOAContractDTO>> getContractList(@RequestBody BpmOAContractVO respVO);

    @PostMapping(PREFIX + "/updateSettlementFlagByIds")
    @Operation(summary = "批量更新合同结算状态")
    void updateSettlementFlagByIds(@RequestBody List<Long> contractIds);
}
