https://blog.csdn.net/cauchy6317/article/details/82313088(简历介绍)
https://blog.csdn.net/qq_27093465/article/details/52180865(学习了)
https://www.cnblogs.com/wrong5566/p/7132705.html(很简洁)
https://blog.csdn.net/newbie_907486852/article/details/81027512
package com.dictionary;
public enum CatalogTypeDictionary {
Article(1,"文章"),
Picture(2,"图片"),
Product(3,"产品"),
Resource(4,"资源"),
Mall(5,"商城"),
Video(6,"视频"),
Audio(7,"音频"),
Guestbook(8,"留言"),
Blog(9,"博客"),
Forum(10,"论坛"),
Community(11,"社圈");
private Integer value;
private String desc;
/**
* 获取值
* @return
*/
public Integer getValue() {
return value;
}
/**
* 设置值
* @param value
*/
public void setValue(Integer value) {
this.value=value;
}
/**
* 获取描述
* @return
*/
public String getDesc() {
return desc;
}
/**
* 设置描述
* @param desc
*/
public void setDesc(String desc) {
this.desc=desc;
}
/**
* 初始化频道类型
* @param value
* @param desc
*/
private CatalogTypeDictionary(Integer value,String desc) {
this.value=value;
this.desc=desc;
}
/**
*根参数 取得类型
* @param value
* @return
*/
public static CatalogTypeDictionary getTypeByValue(Integer value) {
CatalogTypeDictionary defaultType=CatalogTypeDictionary.Article;
for(CatalogTypeDictionary catalogType:CatalogTypeDictionary.values()) {
if(catalogType.value.equals(value)) {
return catalogType;
}
}
return defaultType;
}
/**
* 取得参数的类型描述
* @param value
* @return
*/
public static String getTypeByDesc(Integer value) {
return getTypeByValue(value).desc;
}
}
public @ResponseBody List<Map<String, String>>getCatalogType(){
List<Map<String, String>>catalogList=new ArrayList<Map<String,String>>();
for (CatalogTypeDictionary catalogType : CatalogTypeDictionary.values()) {
Map<String, String>typeMap=new HashMap<String, String>();
typeMap.put("typeName",catalogType.getDesc());
typeMap.put("typeValue",catalogType.getValue());
catalogList.add(typeMap);
}
return catalogList;
}