package com.yuchen.saas.flow.api.feign;

import com.yuchen.saas.flow.api.dto.FlowTaskQuery;
import com.yuchen.saas.flow.api.dto.NodeUser;
import com.yuchen.saas.flow.api.dto.ProcessInstanceParamDTO;
import com.yuchen.saas.flow.api.dto.TaskParamDTO;
import com.yuchen.saas.flow.api.dto.req.customerFlow.SyncFlowToCustomerReqDTO;
import com.yuchen.saas.flow.api.entity.SaasFlowProcessInstanceRecord;
import org.nest.springwrap.core.launch.app.AppNameConstant;
import org.nest.springwrap.core.tool.api.R;
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.util.List;
import java.util.Map;


@FeignClient(
        value = AppNameConstant.SAAS_FLOW,
        fallbackFactory = CustomerFlowFallback.class
)
public interface CustomerFlowFeign {

    @PostMapping("/customerFlow/syncFlowToCustomer")
    R syncFlowToCustomer(@RequestBody SyncFlowToCustomerReqDTO reqDTO);

    /**
     * 完成任务
     * @param paramDTO
     * @return
     */
    @PostMapping("/customerFlow/customerCompleteTask")
    R<SaasFlowProcessInstanceRecord> customerCompleteTask(@RequestBody TaskParamDTO paramDTO);

    /**
     * 启动流程
     * @param paramDTO
     * @return
     */
    @PostMapping("/customerFlow/startProcessInstance")
    R<SaasFlowProcessInstanceRecord> startProcessInstance(@RequestBody ProcessInstanceParamDTO paramDTO);

    @PostMapping("/customerFlow/checkApplyDimensionality")
    R<List<Map<String, NodeUser>>> checkApplyDimensionality(@RequestBody ProcessInstanceParamDTO paramDTO);

    @PostMapping("/customerFlow/listByAssetsIds")
    R<List<SaasFlowProcessInstanceRecord>> listByAssetsIds(@RequestBody List<String> ids);

    @PostMapping("/customerFlow/stopProcessInstance")
    R stopProcessInstance(@RequestBody TaskParamDTO paramDTO);

    @PostMapping("/customerFlow/getRuTaskById")
    R<String> getRuTaskById(@RequestBody String taskId);

    @PostMapping("/customerFlow/updateFormVariables")
    R<Boolean> updateFormVariables(@RequestBody TaskParamDTO paramDTO);

    @PostMapping("/customerFlow/rollBackApproval")
    R<Boolean> rollBackApproval(@RequestBody TaskParamDTO paramDTO);

    @PostMapping("/customerFlow/flowQueryMineTaskByType")
    R<List<String>> flowQueryMineTaskByType(@RequestBody FlowTaskQuery paramDTO);

    @GetMapping("/customerFlow/gerRuTaskByDataId")
    R<String> gerRuTaskByDataId(@RequestParam String processInstanceId);

    @PostMapping("/customerFlow/getRuTaskCount")
    R<Long> getRuTaskCount(@RequestBody FlowTaskQuery paramDTO);

    @PostMapping("/customerFlow/getAllRuTaskCount")
    R<Long> getAllRuTaskCount(@RequestBody FlowTaskQuery paramDTO);
}
