package cn.axzo.workflow.server.controller.web.bpmn;

import cn.axzo.workflow.client.feign.bpmn.ProcessActivityApi;
import cn.axzo.workflow.core.service.BpmnProcessActivityService;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * 流程活动相关控制器
 *
 * @author wangli
 * @since 2023/11/17 16:33
 */
@Slf4j
@RequestMapping({"/web/v1/api/process/activity", "/api/process/activity"})
@RestController
@Validated
public class BpmnProcessActivityController implements ProcessActivityApi {

    @Resource
    private BpmnProcessActivityService bpmnProcessActivityService;

    @GetMapping("/trigger")
    @Override
    public CommonResponse<Boolean> trigger(@NotBlank(message = "活动 ID 不能为空") @RequestParam String processActivityId) {
        bpmnProcessActivityService.trigger(processActivityId);
        return CommonResponse.success(true);
    }
}
