GovernmentInfoEnum.java 864 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.ruoyi.web.domain.enums;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import lombok.Getter;
  4. /**
  5. * 政务信息枚举类
  6. */
  7. @Getter
  8. public enum GovernmentInfoEnum {
  9. NON_PUBLISHED("未发布", 0),
  10. PUBLISHED("已发布", 1),
  11. REMOVED("下架",2);
  12. private final String text;
  13. private final int value;
  14. GovernmentInfoEnum(String text, int value) {
  15. this.text = text;
  16. this.value = value;
  17. }
  18. /**
  19. * 根据 value 获取枚举
  20. */
  21. public static GovernmentInfoEnum getEnumByValue(Integer value) {
  22. if (ObjectUtil.isEmpty(value)) {
  23. return null;
  24. }
  25. for (GovernmentInfoEnum villageServiceEnum : GovernmentInfoEnum.values()) {
  26. if (villageServiceEnum.value == value) {
  27. return villageServiceEnum;
  28. }
  29. }
  30. return null;
  31. }
  32. }