package com.bonus.canteen.core.customer.utils;

import com.alibaba.fastjson.JSON;
import com.bonus.canteen.core.common.redis.RedisUtil;
import com.bonus.canteen.core.customer.constants.CustCacheKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class CustomerCacheUtil {
   private static final Logger log = LoggerFactory.getLogger(CustomerCacheUtil.class);

   public static Map<Long, Integer> getCustomerNumBelongOrgMapCache() {
      return (Map)JSON.parseObject(RedisUtil.getString(CustCacheKey.getTenantKey("customer:customerNum:belongOrg")), HashMap.class);
   }

   public static void insertCustomerNumBelongOrgMapCache(Map<Long, Integer> cacheOrgId_customerNum) {
      String key = CustCacheKey.getTenantKey("customer:customerNum:belongOrg");
      RedisUtil.setString(key, JSON.toJSONString(cacheOrgId_customerNum), 2592000L);
   }

   public static void deleteCustomerNumBelongOrgMapCache() {
      RedisUtil.delete(CustCacheKey.getTenantKey("customer:customerNum:belongOrg"));
   }
}
