LectureCacheKey.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.goafanti.common.enums;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. public enum LectureCacheKey {
  5. BIG_SHOT_LECTURE_CACHE_KEY("big_shot_lecture_cache_key", "大咖说页面缓存"),
  6. LECTURE_DYNAMIC_LIST_CACHE_KEY("lecture_dynamic_list_cache_key", "科技明星页面缓存"),
  7. LECTURE_LIST_CACHE_KEY("lecture_list_cache_key", "科技讲堂页面缓存"),
  8. OTHER("", "未知参数");
  9. private String code;
  10. private String desc;
  11. private static Map<String, LectureCacheKey> status = new HashMap<String, LectureCacheKey>();
  12. private LectureCacheKey(String code, String desc) {
  13. this.code = code;
  14. this.desc = desc;
  15. }
  16. static {
  17. for (LectureCacheKey value : LectureCacheKey.values()) {
  18. status.put(value.getCode(), value);
  19. }
  20. }
  21. public static LectureCacheKey getField(String code) {
  22. if (containsType(code)) {
  23. return status.get(code);
  24. }
  25. return OTHER;
  26. }
  27. public static String getFieldDesc(String code) {
  28. return getField(code).getDesc();
  29. }
  30. public static boolean containsType(String code) {
  31. return status.containsKey(code);
  32. }
  33. public String getCode() {
  34. return code;
  35. }
  36. public String getDesc() {
  37. return desc;
  38. }
  39. }