/** * Copyright (c) 2018 人人开源 All rights reserved. *
* https://www.renren.io *
* 版权所有,侵权必究!
*/
package com.epmet.redis;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 客户app Redis
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Component
public class CustomerAppWxServiceUtil implements ApplicationRunner {
private Logger logger = LogManager.getLogger(CustomerAppWxServiceUtil.class);
/**
* 过期时长为30分钟,单位:秒
*/
private final static long MINUTE_THIRTY_EXPIRE = 60 * 60 * 24 * 7L;
private final static String JSON_STR = "JSON";
@Autowired
private RedisUtils redisUtils;
@Autowired
private RedisTemplate> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp();
logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp result:{}", JSON.toJSONString(configAllAppResult));
if (configAllAppResult == null || configAllAppResult.success()){
logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp fail");
return;
}
String appKey = RedisKeys.getCustomerAppKey();
SetOperations