|
|
@@ -0,0 +1,65 @@
|
|
|
+package cn.reghao.oss.api.constant;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2023-06-13 15:09:09
|
|
|
+ */
|
|
|
+public enum ObjectType {
|
|
|
+ Dir(1000, "directory"),
|
|
|
+ Image(1001, "image"),
|
|
|
+ Video(1002, "video"),
|
|
|
+ Audio(1003, "audio"),
|
|
|
+ Text(1004, "text"),
|
|
|
+ Other(1005, "application");
|
|
|
+
|
|
|
+ private final int code;
|
|
|
+ private final String desc;
|
|
|
+ ObjectType(int code, String desc) {
|
|
|
+ this.code = code;
|
|
|
+ this.desc = desc;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Map<Integer, ObjectType> map = new HashMap<>();
|
|
|
+ static {
|
|
|
+ for (ObjectType type : ObjectType.values()) {
|
|
|
+ map.put(type.code, type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Map<Integer, String> descMap = new HashMap<>();
|
|
|
+ static {
|
|
|
+ for (ObjectType objectType : ObjectType.values()) {
|
|
|
+ descMap.put(objectType.code, objectType.desc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static ObjectType getByCode(int code) {
|
|
|
+ return map.get(code);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提供给 @ValidEnum 调用
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @date 2023-10-11 14:44:42
|
|
|
+ */
|
|
|
+ public int getValue() {
|
|
|
+ return this.code;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getCode() {
|
|
|
+ return code;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getDesc() {
|
|
|
+ return desc;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getDescByCode(int code) {
|
|
|
+ return descMap.get(code);
|
|
|
+ }
|
|
|
+}
|