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", "片角镇") ; @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)){ return Ym ; }else if(tag.equals(Pj.tag)){ return Pj ; } return null ; } @JSONField public JSONObject toJson() { return JSONObject.of("tag", getTag(), "name", getName()); } }