package com.bonus.canteen.core.order.mq;

import com.bonus.canteen.core.common.constant.LeMqConstant;
import com.bonus.canteen.core.common.utils.LogUtil;
import com.bonus.canteen.core.common.utils.TenantContextHolder;

public class MqPayload<T> {
   private Long tenantId;
   private String traceId;
   private LeMqConstant.Topic topic;
   private String routingKey;
   private T data;

   public String destination() {
      String var10000 = this.topic.getKey();
      return var10000 + "." + this.tenantId;
   }

   public static <T> MqPayload<T> of(T data, LeMqConstant.Topic topic, String routingKey) {
      MqPayload<T> payload = new MqPayload();
      payload.setData(data);
      payload.setTopic(topic);
      payload.setRoutingKey(routingKey);
      payload.setTenantId(TenantContextHolder.getTenantId());
      payload.setTraceId(LogUtil.getCurrentTraceId());
      return payload;
   }

   public Long getTenantId() {
      return this.tenantId;
   }

   public String getTraceId() {
      return this.traceId;
   }

   public LeMqConstant.Topic getTopic() {
      return this.topic;
   }

   public String getRoutingKey() {
      return this.routingKey;
   }

   public T getData() {
      return this.data;
   }

   public void setTenantId(final Long tenantId) {
      this.tenantId = tenantId;
   }

   public void setTraceId(final String traceId) {
      this.traceId = traceId;
   }

   public void setTopic(final LeMqConstant.Topic topic) {
      this.topic = topic;
   }

   public void setRoutingKey(final String routingKey) {
      this.routingKey = routingKey;
   }

   public void setData(final T data) {
      this.data = data;
   }
}
