package com.bonus.canteen.core.device.constants;

import com.bonus.canteen.core.common.utils.TenantContextHolder;

public interface MachineConstant {
   String MAC_REDIS_KEY = "yst:[merchantId]:mac:[machineSn]";
   String MAC_SINGLE_REDIS_KEY = "yst:[merchantId]:mac-single:[machineSn]";
   /** @deprecated */
   String MAC_SLAVE_REDIS_KEY = "yst:[merchantId]:mac-slave:[machineId]";
   String MAC_FULL_REDIS_KEY = "yst:[merchantId]:mac-full:[machineSn]";
   String MAC_CHILD_REDIS_KEY = "yst:[merchantId]:mac-child:[machineSn]";
   String MAC_TYPE_REDIS_KEY = "yst:[merchantId]:mac-type:[deviceType]";
   String MACHINE_STATE_REDIS_KEY = "yst:mac:state:[machineSn]";
   String FIELD_MERCHANT_ID = "[merchantId]";
   String FIELD_MACHINE_SN = "[machineSn]";
   String FIELD_MACHINE_TYPE = "[deviceType]";
   String FIELD_MACHINE_ID = "[machineId]";
   String DEVICE_ONLINE_V4 = "yunshitang:%s:device:onlinev4:%s";
   String DEVICE_ONLINE_STATE = "yunshitang:%S:isonline:%S";

   static String getDeviceOnlineRedisKey(String deviceSn) {
      return "yunshitang:%S:isonline:%S".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[machineSn]", deviceSn);
   }

   static String getDeviceRedisKey(String deviceSn) {
      return "yst:[merchantId]:mac:[machineSn]".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[machineSn]", deviceSn);
   }

   static String getDeviceFullRedisKey(String deviceSn) {
      return "yst:[merchantId]:mac-full:[machineSn]".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[machineSn]", deviceSn);
   }

   static String getDeviceSingleRedisKey(String deviceSn) {
      return "yst:[merchantId]:mac-single:[machineSn]".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[machineSn]", deviceSn);
   }

   static String getDeviceStateRedisKey(String deviceSn) {
      return "yst:mac:state:[machineSn]".replace("[machineSn]", deviceSn);
   }

   static String getDeviceChildRedisKey(String deviceSn) {
      return "yst:[merchantId]:mac-child:[machineSn]".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[machineSn]", deviceSn);
   }

   static String getDeviceTypeFullRedisKey(Integer deviceType) {
      return "yst:[merchantId]:mac-type:[deviceType]".replace("[merchantId]", TenantContextHolder.getTenantId().toString()).replace("[deviceType]", String.valueOf(deviceType));
   }
}
