|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.teaching.backend.constant; |
|
|
|
|
|
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
@ -11,24 +12,25 @@ import java.util.Map; |
|
|
|
|
* @Description: |
|
|
|
|
*/ |
|
|
|
|
public enum ViewContentTypeEnum { |
|
|
|
|
DEFAULT("default","application/octet-stream"), |
|
|
|
|
PNG("png", "image/png"), |
|
|
|
|
JPEG("jpeg", "image/jpeg"), |
|
|
|
|
JPG("jpg", "image/jpeg"), |
|
|
|
|
GIF("gif", "image/gif"), |
|
|
|
|
WBMP("wbmp", "image/vnd.wap.wbmp"), |
|
|
|
|
TIFF("tiff", "image/tiff"), |
|
|
|
|
JFIF("jfif", "image/jpeg"), |
|
|
|
|
TIF("tif", "image/tiff"), |
|
|
|
|
FAX("fax", "image/fax"), |
|
|
|
|
JPE("jpe", "image/jpeg"), |
|
|
|
|
NET("net", "image/pnetvue"), |
|
|
|
|
RP("rp", "image/vnd.rn-realpix"), |
|
|
|
|
ICO("ico", "image/x-icon"); |
|
|
|
|
DEFAULT("default","application/octet-stream",0), |
|
|
|
|
PNG("png", "image/png",1), |
|
|
|
|
JPEG("jpeg", "image/jpeg",2), |
|
|
|
|
JPG("jpg", "image/jpeg",3), |
|
|
|
|
GIF("gif", "image/gif",4), |
|
|
|
|
WBMP("wbmp", "image/vnd.wap.wbmp", 5), |
|
|
|
|
TIFF("tiff", "image/tiff", 6), |
|
|
|
|
JFIF("jfif", "image/jpeg", 7), |
|
|
|
|
TIF("tif", "image/tiff", 8), |
|
|
|
|
FAX("fax", "image/fax", 9), |
|
|
|
|
JPE("jpe", "image/jpeg", 10), |
|
|
|
|
NET("net", "image/pnetvue", 11), |
|
|
|
|
RP("rp", "image/vnd.rn-realpix", 12), |
|
|
|
|
ICO("ico", "image/x-icon", 13); |
|
|
|
|
|
|
|
|
|
private String prefix; |
|
|
|
|
|
|
|
|
|
private String type; |
|
|
|
|
private Integer num; |
|
|
|
|
|
|
|
|
|
private static final Map<String, ViewContentTypeEnum> ENUM_MAP = new HashMap<>(); |
|
|
|
|
|
|
|
|
@ -59,9 +61,10 @@ public enum ViewContentTypeEnum { |
|
|
|
|
return DEFAULT.getType(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ViewContentTypeEnum(String prefix, String type) { |
|
|
|
|
ViewContentTypeEnum(String prefix, String type, int num) { |
|
|
|
|
this.prefix = prefix; |
|
|
|
|
this.type = type; |
|
|
|
|
this.num = num; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getPrefix() { |
|
|
|
@ -71,4 +74,30 @@ public enum ViewContentTypeEnum { |
|
|
|
|
public String getType() { |
|
|
|
|
return type; |
|
|
|
|
} |
|
|
|
|
public Integer getNum() { |
|
|
|
|
return num; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Integer getNumByPrefix(String prefix) { |
|
|
|
|
ViewContentTypeEnum viewContentTypeEnum = ENUM_MAP.get(prefix); |
|
|
|
|
if (viewContentTypeEnum == null) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return viewContentTypeEnum.getNum(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Integer getNumByName(String prefix) { |
|
|
|
|
if(StringUtils.isEmpty(prefix)){ |
|
|
|
|
return DEFAULT.getNum(); |
|
|
|
|
} |
|
|
|
|
prefix = prefix.substring(prefix.lastIndexOf(".") + 1); |
|
|
|
|
Integer num = getNumByPrefix(prefix); |
|
|
|
|
if (num != null) { |
|
|
|
|
return num; |
|
|
|
|
} |
|
|
|
|
return DEFAULT.getNum(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|