|
@@ -1,10 +1,14 @@
|
|
|
package org.ssssssss.magicapi.model;
|
|
|
|
|
|
+import org.apache.commons.lang3.time.DateUtils;
|
|
|
import org.ssssssss.magicapi.modules.RequestModule;
|
|
|
+import org.ssssssss.script.functions.ObjectConvertExtension;
|
|
|
import org.ssssssss.script.reflection.JavaInvoker;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import static org.ssssssss.script.reflection.JavaReflection.findInvoker;
|
|
|
|
|
@@ -14,6 +18,7 @@ import static org.ssssssss.script.reflection.JavaReflection.findInvoker;
|
|
|
* @author mxd
|
|
|
*/
|
|
|
public enum DataType {
|
|
|
+
|
|
|
/**
|
|
|
* Object 类型
|
|
|
*/
|
|
@@ -61,6 +66,11 @@ public enum DataType {
|
|
|
*/
|
|
|
Short(true, findInvoker(BigDecimal.class, "shortValue"), "number"),
|
|
|
|
|
|
+ /**
|
|
|
+ * Date类型
|
|
|
+ */
|
|
|
+ Date(findInvoker(DataType.class, "parseDate", new Class<?>[]{String.class}), false, true, "string"),
|
|
|
+
|
|
|
/**
|
|
|
* MultipartFile 类型
|
|
|
*/
|
|
@@ -82,6 +92,8 @@ public enum DataType {
|
|
|
|
|
|
private String javascriptType;
|
|
|
|
|
|
+ public static String[] DATE_PATTERNS;
|
|
|
+
|
|
|
DataType(boolean isNumber, JavaInvoker<Method> invoker, boolean needName, boolean needValue, String javascriptType) {
|
|
|
this.isNumber = isNumber;
|
|
|
this.invoker = invoker;
|
|
@@ -122,4 +134,8 @@ public enum DataType {
|
|
|
public java.lang.String getJavascriptType() {
|
|
|
return javascriptType;
|
|
|
}
|
|
|
+
|
|
|
+ public static java.util.Date parseDate(String value) throws ParseException {
|
|
|
+ return DateUtils.parseDate(value, DATE_PATTERNS);
|
|
|
+ }
|
|
|
}
|