package org.springblade.common.auth.producer;

import org.springblade.common.notify.rocketmq.producer.RocketMqProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;


/**
 * 消息生产者
 *
 * @author wpp
 * @date 2019/10/14 18:25
 */
@Slf4j
@Component
@ConditionalOnProperty(name = "cas.support.flag", havingValue = "true", matchIfMissing = false)
public class OperationLogProducer {

    @Value("${ali.mq.topic.add.operation.log}")
    private String statusChangeTopic;
    @Value("${ali.mq.tag.add.operation.log}")
    private String operationLogTag;
    @Autowired
    private RocketMqProducer rocketMqProducer;

    /**
     * 发送消息通知idms服务新增操作日志
     *
     * @param message
     */
    public void sendOperationLogMessage(String message) {
        log.info("发送消息通知idms服务新增操作日志，明细messsage：{}", message);
        rocketMqProducer.sendAsyncMessage(statusChangeTopic, operationLogTag, message, null);
    }
}
