package cn.huge.base.common.constant;
|
|
/**
|
* @title: 附件类型枚举类
|
* @description: 附件类型枚举类
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
public enum FileCatEnum {
|
NULL("22_00017-0","未分类"),
|
AUDIO("22_00017-1", "音频"),
|
VIDEO("22_00017-2", "视频"),
|
IMAGE("22_00017-3", "图片"),
|
WORD("22_00017-4", "Word文档"),
|
EXCEL("22_00017-5", "Excel表格"),
|
PDF("22_00017-6", "PDF"),
|
TXT("22_00017-7", "txt文本"),
|
ZIP("22_00017--8", "压缩文件"),
|
POWERPOINT("22_00017-9", "PowerPoint"),
|
UNKNOWN("22_00017-99", "其它文件");
|
|
/**
|
* 代码编号
|
*/
|
private String index;
|
|
/**
|
* 名称
|
*/
|
private String des;
|
|
public String getIndex() {
|
return index;
|
}
|
|
public void setIndex(String index) {
|
this.index = index;
|
}
|
|
public String getDes() {
|
return des;
|
}
|
|
public void setDes(String des) {
|
this.des = des;
|
}
|
|
/**
|
* 构造方法
|
* @param index
|
* @param des
|
*/
|
FileCatEnum(String index, String des) {
|
this.index = index;
|
this.des = des;
|
}
|
|
/**
|
* 静态方法
|
* @param id
|
* @return
|
*/
|
public static FileCatEnum getById(final String index) {
|
switch (index) {
|
case "22_00017-0":
|
return NULL;
|
case "22_00017-1":
|
return AUDIO;
|
case "22_00017-2":
|
return VIDEO;
|
case "22_00017-3":
|
return IMAGE;
|
case "22_00017-4":
|
return WORD;
|
case "22_00017-5":
|
return EXCEL;
|
case "22_00017-6":
|
return PDF;
|
case "22_00017-7":
|
return TXT;
|
case "22_00017-8":
|
return ZIP;
|
case "22_00017-9":
|
return POWERPOINT;
|
default:
|
return UNKNOWN;
|
}
|
}
|
|
/**
|
* 根据后缀获取分类
|
* @param suffix 后缀
|
* @return String
|
*/
|
public static String getFileCat(String suffix) {
|
if (suffix.equalsIgnoreCase(FileConsts.mp3)) {
|
return FileCatEnum.AUDIO.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.mp4) ||
|
suffix.equalsIgnoreCase(FileConsts.avi) ||
|
suffix.equalsIgnoreCase(FileConsts.mp2)) {
|
return FileCatEnum.VIDEO.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.gif) ||
|
suffix.equalsIgnoreCase(FileConsts.jpeg) ||
|
suffix.equalsIgnoreCase(FileConsts.jpg) ||
|
suffix.equalsIgnoreCase(FileConsts.png) ||
|
suffix.equalsIgnoreCase(FileConsts.bmp)) {
|
return FileCatEnum.IMAGE.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.docx) ||
|
suffix.equalsIgnoreCase(FileConsts.doc)) {
|
return FileCatEnum.WORD.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.xla) ||
|
suffix.equalsIgnoreCase(FileConsts.xlc)||
|
suffix.equalsIgnoreCase(FileConsts.xlm)||
|
suffix.equalsIgnoreCase(FileConsts.xls)||
|
suffix.equalsIgnoreCase(FileConsts.xlt)||
|
suffix.equalsIgnoreCase(FileConsts.xlw)) {
|
return FileCatEnum.EXCEL.getIndex();
|
} else if (suffix.equalsIgnoreCase(FileConsts.pptx) ||
|
suffix.equalsIgnoreCase(FileConsts.ppt)) {
|
return FileCatEnum.POWERPOINT.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.pdf)) {
|
return FileCatEnum.PDF.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.zip) ||
|
suffix.equalsIgnoreCase(FileConsts.tar)) {
|
return FileCatEnum.ZIP.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.txt)) {
|
return FileCatEnum.TXT.getIndex();
|
}else if (suffix.equalsIgnoreCase(FileConsts.html) ||
|
suffix.equalsIgnoreCase(FileConsts.vsd)||
|
suffix.equalsIgnoreCase(FileConsts.xml)) {
|
return FileCatEnum.UNKNOWN.getIndex();
|
}else{
|
return FileCatEnum.NULL.getIndex();
|
}
|
}
|
}
|