From 7cd84085ee7cba65350171dab688bc776b8093ff Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 03 十二月 2024 12:21:32 +0800
Subject: [PATCH] 文件上传接口取消文件内容为空判断
---
src/main/java/com/mindskip/xzs/base/RestResponse.java | 64 +++++++++++--------------------
1 files changed, 23 insertions(+), 41 deletions(-)
diff --git a/src/main/java/com/mindskip/xzs/base/RestResponse.java b/src/main/java/com/mindskip/xzs/base/RestResponse.java
index 3f0b72b..4614a5e 100644
--- a/src/main/java/com/mindskip/xzs/base/RestResponse.java
+++ b/src/main/java/com/mindskip/xzs/base/RestResponse.java
@@ -1,12 +1,9 @@
package com.mindskip.xzs.base;
-/**
- * @version 3.3.0
- * @description: The type Rest response.
- * Copyright (C), 2020-2021, 姝︽眽鎬濈淮璺宠穬绉戞妧鏈夐檺鍏徃
- * @date 2021/5/25 10:45
- */
-public class RestResponse<T> {
+import java.util.HashMap;
+import java.util.Map;
+
+public class RestResponse<T> extends HashMap<String, Object> {
private int code;
private String message;
private T response;
@@ -18,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);
}
/**
@@ -29,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;
}
/**
@@ -65,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);
}
/**
@@ -74,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");
}
/**
@@ -92,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.
@@ -110,15 +92,15 @@
* @return the response
*/
public T getResponse() {
- return response;
+ return (T) this.get("response");
}
- /**
- * Sets response.
- *
- * @param response the response
- */
- public void setResponse(T response) {
- this.response = response;
+ public RestResponse() {
+ }
+
+ @Override
+ public RestResponse put(String key, Object value) {
+ super.put(key, value);
+ return this;
}
}
--
Gitblit v1.8.0