From 3ec909b27b3eba956aa9d00cc7a94c179bd04bbf Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期三, 03 七月 2024 18:29:31 +0800
Subject: [PATCH] feat:新增随机时间题目配置

---
 src/main/java/com/mindskip/xzs/base/RestResponse.java |   54 ++++++++++++++++++------------------------------------
 1 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/base/RestResponse.java b/src/main/java/com/mindskip/xzs/base/RestResponse.java
index 8c7a0ac..4614a5e 100644
--- a/src/main/java/com/mindskip/xzs/base/RestResponse.java
+++ b/src/main/java/com/mindskip/xzs/base/RestResponse.java
@@ -15,8 +15,8 @@
      * @param message the message
      */
     public RestResponse(int code, String message) {
-        this.code = code;
-        this.message = message;
+        this.put("code", code);
+        this.put("message", message);
     }
 
     /**
@@ -26,10 +26,12 @@
      * @param message  the message
      * @param response the response
      */
-    public RestResponse(int code, String message, T response) {
-        this.code = code;
-        this.message = message;
-        this.response = response;
+    public static RestResponse response(int code, String message, Object response) {
+        RestResponse restResponse = new RestResponse();
+        restResponse.put("code", code);
+        restResponse.put("message", message);
+        restResponse.put("response", response);
+        return restResponse;
     }
 
     /**
@@ -62,7 +64,7 @@
      */
     public static <F> RestResponse<F> ok(F response) {
         SystemCode systemCode = SystemCode.OK;
-        return new RestResponse<>(systemCode.getCode(), systemCode.getMessage(), response);
+        return RestResponse.response(systemCode.getCode(), systemCode.getMessage(), response);
     }
 
     /**
@@ -71,16 +73,7 @@
      * @return the code
      */
     public int getCode() {
-        return code;
-    }
-
-    /**
-     * Sets code.
-     *
-     * @param code the code
-     */
-    public void setCode(int code) {
-        this.code = code;
+        return (int) this.get("code");
     }
 
     /**
@@ -89,17 +82,9 @@
      * @return the message
      */
     public String getMessage() {
-        return message;
+        return (String) this.get("message");
     }
 
-    /**
-     * Sets message.
-     *
-     * @param message the message
-     */
-    public void setMessage(String message) {
-        this.message = message;
-    }
 
     /**
      * Gets response.
@@ -107,18 +92,15 @@
      * @return the response
      */
     public T getResponse() {
-        return response;
-    }
-
-    /**
-     * Sets response.
-     *
-     * @param response the response
-     */
-    public void setResponse(T response) {
-        this.response = response;
+        return (T) this.get("response");
     }
 
     public RestResponse() {
     }
+
+    @Override
+    public RestResponse put(String key, Object value) {
+        super.put(key, value);
+        return this;
+    }
 }

--
Gitblit v1.8.0