
package org.tio.sitexxx.service.model.main;

import org.tio.sitexxx.service.model.main.base.BaseFile;
import org.tio.sitexxx.service.vo.Const;

/**
 * Generated by JFinal.
 */
@SuppressWarnings("serial")
public class File extends BaseFile<File> {
	public static final File dao = new File().dao();

	private Short fileicontype;

	public Short getFileicontype() {
		this.fileicontype = iconType(getExt());
		return fileicontype;
	}

	public void setFileicontype(Short fileicontype) {
		this.fileicontype = fileicontype;
	}

	/**
	 * @param ext
	 * @return
	 * @author xufei
	 * 2020年9月18日 下午3:41:07
	 */
	public static Short iconType(String ext) {
		Short icon = Const.FileIconType.OTHER;
		switch (ext.toLowerCase()) {
		case "pdf":
			icon = Const.FileIconType.PDF;
			break;
		case "txt":
			icon = Const.FileIconType.TXT;
			break;
		case "doc":
		case "docx":
			icon = Const.FileIconType.DOC;
			break;
		case "xls":
		case "xlsx":
			icon = Const.FileIconType.XLS;
			break;
		case "ppt":
		case "pptx":
			icon = Const.FileIconType.PPT;
			break;
		case "apk":
			icon = Const.FileIconType.APK;
			break;
		case "jpg":
		case "png":
		case "gif":
		case "bmp":
		case "jpeg":
			icon = Const.FileIconType.IMG;
			break;
		case "zip":
		case "rar":
		case "7z":
		case "tar":
		case "jar":
			icon = Const.FileIconType.ZIP;
			break;
		case "mp4":
		case "mov":
		case "avi":
		case "wmv":
		case "3gp":
		case "flv":
		case "mpg":
		case "mpeg":
		case "rmvb":
		case "f4v":
		case "mkv":
		case "asf":
		case "m4v":
			icon = Const.FileIconType.VIDEO;
			break;
		case "mp3":
		case "wma":
		case "aac":
		case "aiff":
		case "amr":
		case "ac3":
		case "m4a":
		case "ogg":
		case "wav":
			icon = Const.FileIconType.AUDIO;
			break;
		default:
			icon = Const.FileIconType.OTHER;
			break;
		}
		return icon;
	}

}
