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