package cn.axzo.workflow.client.feign.bpmn;

import cn.axzo.workflow.client.config.CommonFeignConfiguration;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnActivitySetAssigneeDTO;
import cn.azxo.framework.common.model.CommonResponse;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
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 javax.validation.constraints.NotBlank;

/**
 * 流程活动的 API
 *
 * @author wangli
 * @since 2023/11/17 16:28
 */
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}", configuration = CommonFeignConfiguration.class)
public interface ProcessActivityApi {

    /**
     * 业务节点唤醒
     * <p>
     * TODO 接口需要合并，但需要考虑客户端与服务端不同版本间如何兼容
     */
    @GetMapping("/api/process/activity/old/trigger")
    CommonResponse<Boolean> trigger(@NotBlank(message = "触发 ID 不能为空") @RequestParam String triggerId);

    @Operation(summary = "业务节点唤醒")
    @GetMapping("/api/process/activity/trigger")
    CommonResponse<Boolean> trigger(@NotBlank(message = "触发 ID 不能为空") @RequestParam String triggerId,
                                    @RequestParam(required = false, defaultValue = "false") Boolean async);


    /**
     * 业务节点设置审批人, 不支持重复设置
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/process/activity/assignee/set")
    @Operation(summary = "业务节点设置审批人，不支持重复调用设置审批人，需一次性传入所有审批人")
    CommonResponse<Boolean> setAssignee(@Validated @RequestBody BpmnActivitySetAssigneeDTO dto);
}
