|
|
@@ -1,6 +1,5 @@
|
|
|
package cn.reghao.jutil.jdk.result;
|
|
|
|
|
|
-import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
|
|
|
import java.util.UUID;
|
|
|
@@ -25,6 +24,13 @@ public class WebResult<T> {
|
|
|
this.requestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
}
|
|
|
|
|
|
+ private WebResult(ResultStatus resultStatus) {
|
|
|
+ this.code = resultStatus.getCode();
|
|
|
+ this.msg = resultStatus.getMsg();
|
|
|
+ this.timestamp = System.currentTimeMillis();
|
|
|
+ this.requestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ }
|
|
|
+
|
|
|
public int getCode() {
|
|
|
return code;
|
|
|
}
|
|
|
@@ -80,6 +86,11 @@ public class WebResult<T> {
|
|
|
return JsonConverter.objectToJson(webBody);
|
|
|
}
|
|
|
|
|
|
+ public static <T> String notFound() {
|
|
|
+ WebResult<T> webBody = new WebResult<>(ResultStatus.NOTFOUND);
|
|
|
+ return JsonConverter.objectToJson(webBody);
|
|
|
+ }
|
|
|
+
|
|
|
public static <T> String error() {
|
|
|
WebResult<T> webBody = new WebResult<>(ResultStatus.ERROR.getCode(), ResultStatus.ERROR.getMsg());
|
|
|
return JsonConverter.objectToJson(webBody);
|