package cn.axzo.workflow.server.mq;

import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventProducer;
import cn.axzo.workflow.core.common.enums.FlowableEventModuleEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author wangli
 * @since 2023/9/4 10:31
 */
@RequestMapping("/web/v1/test")
@RestController
public class TestController {

    @Autowired
    private EventProducer eventProducer;

    @GetMapping("/producer")
    public void producer() {
        eventProducer.send(Event.builder()
                .shardingKey(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
                .targetId("1")
                .targetType(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
                .eventCode(FlowableEventModuleEnum.PROCESS_CREATED.getEventCode())
                .eventModule(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
                .eventName(FlowableEventModuleEnum.PROCESS_CREATED.getTag())
                .data("自定义数据")
                .build());
    }
}
