From 3d7669b78c751f808d17b92be18b800cdf595844 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期一, 27 十一月 2023 15:38:39 +0800 Subject: [PATCH] 枚举类型转json --- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java index edc4a10..a4fd7e4 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java @@ -3,12 +3,16 @@ import com.baomidou.mybatisplus.annotation.EnumValue; import com.dy.common.mybatis.envm.IEnum; +import java.util.HashMap; +import java.util.Map; + /** * 琛屾斂鍖哄垝绾у埆 * Provinces, cities, counties, towns, and village groups */ public enum DistrictLevel implements IEnum { + Province((byte)0, "鐪�"), City((byte)1, "甯�"), County((byte)2, "鍘�"), Town((byte)3, "闀�"), @@ -23,6 +27,15 @@ this.name = name ; } + //鐢ㄦ潵杞琷son + public static Map<Byte, DistrictLevel> ObjMap = new HashMap<Byte, DistrictLevel>(); + static { + DistrictLevel[] all = DistrictLevel.values(); + for (DistrictLevel one : all) { + ObjMap.put(one.code, one); + } + } + @Override public Byte getCode() { return this.code ; @@ -34,7 +47,9 @@ } public static DistrictLevel get(Byte code){ - if(code.byteValue() == City.code.byteValue()){ + if(code.byteValue() == Province.code.byteValue()){ + return Province ; + }if(code.byteValue() == City.code.byteValue()){ return City ; }else if(code.byteValue() == County.code.byteValue()){ return County ; -- Gitblit v1.8.0