VersionUtil.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.ruoyi.common.utils.wechat;
  2. import com.ruoyi.common.constant.Constants;
  3. import com.ruoyi.common.core.domain.entity.SysDictData;
  4. import com.ruoyi.common.core.redis.RedisCache;
  5. import com.ruoyi.common.utils.StringUtils;
  6. import com.ruoyi.common.utils.spring.SpringUtils;
  7. import java.util.Collection;
  8. import java.util.List;
  9. /**
  10. * @Author ZhaoQian La
  11. * @Date 2021/6/16 9:40
  12. * @Version 1.0
  13. */
  14. /**
  15. * 版本控制工具类
  16. */
  17. public class VersionUtil {
  18. /**
  19. * 分隔符
  20. */
  21. public static final String SEPARATOR = ",";
  22. /**
  23. * 设置版本信息缓存
  24. *
  25. * @param key 参数键
  26. * @param dictDatas 版本信息数据列表
  27. */
  28. public static void setDictCache(String key, String dictDatas)
  29. {
  30. SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
  31. }
  32. /**
  33. * 获取字版本信息缓存
  34. *
  35. * @param key 参数键
  36. * @return dictDatas 版本信息数据列表
  37. */
  38. public static String getDictCache(String key)
  39. {
  40. String cacheObject = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
  41. if (StringUtils.isNotEmpty(cacheObject)){
  42. return cacheObject;
  43. }
  44. return null;
  45. }
  46. /**
  47. * 清空版本缓存
  48. */
  49. public static void clearDictCache(String configKey)
  50. {
  51. Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_VERSION_KEY + configKey);
  52. SpringUtils.getBean(RedisCache.class).deleteObject(keys);
  53. }
  54. /**
  55. * 设置cache key
  56. *
  57. * @param configKey 参数键
  58. * @return 缓存键key
  59. */
  60. public static String getCacheKey(String configKey)
  61. {
  62. return Constants.SYS_VERSION_KEY + configKey;
  63. }
  64. }