package com.dy.pipIrrGlobal.util; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.annotation.JSONField; import com.baomidou.mybatisplus.annotation.EnumValue; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public enum Org { // Ym("ym", "元谋"), // Pj("pj", "片角镇"), Sp("sp", "沙盘"), Jyg("ym", "嘉峪关"); @EnumValue public String tag ; public String name ; Org(String tag, String name){ this.tag = tag ; this.name = name ; } //用来转json public static List OrgList = new ArrayList<>(); static { Org[] all = Org.values(); for (Org one : all) { Map objMap = new HashMap<>(); objMap.put("tag", one.tag); objMap.put("name", one.name); OrgList.add(objMap) ; } } public String getTag() { return this.tag ; } public String getName() { return this.name ; } public static Org get(String tag){ // if(tag.equals(Ym.tag) || tag.equals(Jyg.tag)){ // return Ym ; // }else if(tag.equals(Pj.tag)){ // return Pj ; // } if(tag.equals(Jyg.tag)){ return Jyg ; }else if(tag.equals(Sp.tag)) { return Sp; } return null ; } @JSONField public JSONObject toJson() { return JSONObject.of("tag", getTag(), "name", getName()); } }