package com.bonus.core.device.mq;


import com.bonus.core.common.constant.LeMqConstant;
import com.bonus.core.device.manage.dto.DeviceMqPersonalUpdateMessageDTO;
import com.bonus.core.device.manage.dto.MacMqBatchMsgDTO;
import com.bonus.core.device.manage.dto.DeviceMqPersonalUpdateMessageDTO;
import com.bonus.core.order.mq.MqUtil;

public class MacMessage {
   public static <T> void updatePersonBatch(MacMqBatchMsgDTO payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_UPDATE_PERSON_BATCH, machineSn);
   }

   public static <T> void updateDeviceBasicSetting(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_UPDATE_DEVICE_BASICSETTING, machineSn);
   }

   public static <T> void updateDeviceBasicSettingTeantV2(T payload) {
      sendToTenant(payload, LeMqConstant.Topic.DEVICE_UPDATE_DEVICE_BASICSETTING_V2);
   }

   public static <T> void updateDevicePersonalInfoTeantV2() {
      DeviceMqPersonalUpdateMessageDTO deviceMqPersonalUpdateMessageDTO = new DeviceMqPersonalUpdateMessageDTO();
      deviceMqPersonalUpdateMessageDTO.setUpdatePerson(1);
      sendToTenant(deviceMqPersonalUpdateMessageDTO, LeMqConstant.Topic.DEVICE_UPDATE_PERSONALINFO_V2);
   }

   public static <T> void deviceOnlineReportTeantV2(T payload) {
      sendToTenant(payload, LeMqConstant.Topic.DEVICE_ONLINE_REPORT_V2);
   }

   public static <T> void updateDevicePersonalInfoFeatureTeantV2() {
      DeviceMqPersonalUpdateMessageDTO deviceMqPersonalUpdateMessageDTO = new DeviceMqPersonalUpdateMessageDTO();
      deviceMqPersonalUpdateMessageDTO.setUpdatePersonPhoto(1);
      sendToTenant(deviceMqPersonalUpdateMessageDTO, LeMqConstant.Topic.DEVICE_UPDATE_PERSONALINFO_V2);
   }

   public static <T> void timeCalibrationV2(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_TIME_CALIBRATION_V2, machineSn);
   }

   public static <T> void switchDeviceMenu(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_SWITCH_DEVICE_MENU_V2, machineSn);
   }

   public static <T> void switchDeviceMenuPriceMenu(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_SWITCH_DEVICE_MENU_PRICE_V2, machineSn);
   }

   public static <T> void updateDeviceBasicSettingV2(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_UPDATE_DEVICE_BASICSETTING_V2, machineSn);
   }

   public static <T> void updateDeviceMetadataV2Setting(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_UPDATE_DEVICE_METADATASETTING_V2, machineSn);
   }

   public static <T> void deviceStallUpdateWeightinfoV2(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_STALL_UPDATE_WEIGHTINFO_V2, machineSn);
   }

   public static <T> void distributeRecipe(T payload, String machineSn) {
      sendToClient(payload, LeMqConstant.Topic.DEVICE_DISTRIBUTE_RECIPE_V2, machineSn);
   }

   public static <T> void sendToClient(T payload, LeMqConstant.Topic topic, String machineSn) {
      MqUtil.pushToSingleDevice(payload, topic, machineSn);
   }

   public static <T> void sendToClient(T payload, LeMqConstant.Topic topic, String machineSn, Long merchantId) {
      MqUtil.pushToSingleDevice(payload, topic, machineSn, merchantId);
   }

   public static <T> void sendRouteKeyToClient(T payload, LeMqConstant.Topic topic, String machineSn) {
      MqUtil.pushToSingleDevice(payload, topic.getKey(), machineSn);
   }

   public static <T> void sendRouteKeyToClient(T payload, LeMqConstant.Topic topic) {
      MqUtil.pushToSingleDevice(payload, (String)topic.getKey(), (String)null);
   }

   public static <T> void sendToTenant(T payload, LeMqConstant.Topic topic) {
      MqUtil.pushToTenantAllDevice(payload, topic);
   }

   public static <T> void sendToAll(T payload, LeMqConstant.Topic topic) {
      MqUtil.pushToAllDevice(payload, topic);
   }
}
