New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum EmphasisEnum implements IntegerValueEnum { |
| | | /** |
| | | *立行整改 |
| | | */ |
| | | JZDLS(1, "建筑工地落实“六个百分百”"), |
| | | /** |
| | | *限期整改 |
| | | */ |
| | | JXHGK(2, "精细化管控"), |
| | | |
| | | ; |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | EmphasisEnum(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, ChangeEnum> valueMap = new HashMap<>(); |
| | | static { |
| | | for (ChangeEnum v : ChangeEnum.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static ChangeEnum getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | ChangeEnum result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |