From 7076deb2b6da9ab0a8b599c61150ec2bd5a926f8 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 20 五月 2021 13:23:12 +0800
Subject: [PATCH] update 请求响应对象 与 分页对象 结构修改 适配接口文档配置

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java |  249 ++++++++++++++++++++++---------------------------
 1 files changed, 111 insertions(+), 138 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
index a7d2297..7c388c5 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
@@ -1,161 +1,134 @@
 package com.ruoyi.common.core.domain;
 
-import cn.hutool.core.lang.Validator;
 import cn.hutool.http.HttpStatus;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
-
-import java.util.HashMap;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
 
 /**
  * 鎿嶄綔娑堟伅鎻愰啋
- * 
- * @author ruoyi
+ *
+ * @author Lion Li
  */
-public class AjaxResult<T> extends HashMap<String, Object>
-{
-    private static final long serialVersionUID = 1L;
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ApiModel("璇锋眰鍝嶅簲瀵硅薄")
+public class AjaxResult<T> {
 
-    /** 鐘舵�佺爜 */
-    public static final String CODE_TAG = "code";
+	private static final long serialVersionUID = 1L;
 
-    /** 杩斿洖鍐呭 */
-    public static final String MSG_TAG = "msg";
+	/**
+	 * 鐘舵�佺爜
+	 */
+	@ApiModelProperty("娑堟伅鐘舵�佺爜")
+	private int code;
 
-    /** 鏁版嵁瀵硅薄 */
-    public static final String DATA_TAG = "data";
+	/**
+	 * 杩斿洖鍐呭
+	 */
+	@ApiModelProperty("娑堟伅鍐呭")
+	private String msg;
 
-    public Integer getCode(){
-        return (Integer) super.get(CODE_TAG);
-    }
+	/**
+	 * 鏁版嵁瀵硅薄
+	 */
+	@ApiModelProperty("鏁版嵁瀵硅薄")
+	private T data;
 
-    public String getMsg(){
-        return (String) super.get(MSG_TAG);
-    }
-    public T getData(){
-        return (T) super.get(DATA_TAG);
-    }
+	/**
+	 * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
+	 *
+	 * @param code 鐘舵�佺爜
+	 * @param msg  杩斿洖鍐呭
+	 */
+	public AjaxResult(int code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
 
-    /**
-     * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄锛屼娇鍏惰〃绀轰竴涓┖娑堟伅銆�
-     */
-    public AjaxResult()
-    {
-    }
+	/**
+	 * 杩斿洖鎴愬姛娑堟伅
+	 *
+	 * @return 鎴愬姛娑堟伅
+	 */
+	public static AjaxResult<Void> success() {
+		return AjaxResult.success("鎿嶄綔鎴愬姛");
+	}
 
-    /**
-     * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
-     * 
-     * @param code 鐘舵�佺爜
-     * @param msg 杩斿洖鍐呭
-     */
-    public AjaxResult(int code, String msg)
-    {
-        super.put(CODE_TAG, code);
-        super.put(MSG_TAG, msg);
-    }
+	/**
+	 * 杩斿洖鎴愬姛鏁版嵁
+	 *
+	 * @return 鎴愬姛娑堟伅
+	 */
+	public static <T> AjaxResult<T> success(T data) {
+		return AjaxResult.success("鎿嶄綔鎴愬姛", data);
+	}
 
-    /**
-     * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
-     * 
-     * @param code 鐘舵�佺爜
-     * @param msg 杩斿洖鍐呭
-     * @param data 鏁版嵁瀵硅薄
-     */
-    public AjaxResult(int code, String msg, T data)
-    {
-        super.put(CODE_TAG, code);
-        super.put(MSG_TAG, msg);
-        if (Validator.isNotNull(data))
-        {
-            super.put(DATA_TAG, data);
-        }
-    }
+	/**
+	 * 杩斿洖鎴愬姛娑堟伅
+	 *
+	 * @param msg 杩斿洖鍐呭
+	 * @return 鎴愬姛娑堟伅
+	 */
+	public static AjaxResult<Void> success(String msg) {
+		return AjaxResult.success(msg, null);
+	}
 
-    /**
-     * 杩斿洖鎴愬姛娑堟伅
-     * 
-     * @return 鎴愬姛娑堟伅
-     */
-    public static AjaxResult<Void> success()
-    {
-        return AjaxResult.success("鎿嶄綔鎴愬姛");
-    }
+	/**
+	 * 杩斿洖鎴愬姛娑堟伅
+	 *
+	 * @param msg  杩斿洖鍐呭
+	 * @param data 鏁版嵁瀵硅薄
+	 * @return 鎴愬姛娑堟伅
+	 */
+	public static <T> AjaxResult<T> success(String msg, T data) {
+		return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data);
+	}
 
-    /**
-     * 杩斿洖鎴愬姛鏁版嵁
-     * 
-     * @return 鎴愬姛娑堟伅
-     */
-    public static <T> AjaxResult<T> success(T data)
-    {
-        return AjaxResult.success("鎿嶄綔鎴愬姛", data);
-    }
+	/**
+	 * 杩斿洖閿欒娑堟伅
+	 *
+	 * @return
+	 */
+	public static AjaxResult<Void> error() {
+		return AjaxResult.error("鎿嶄綔澶辫触");
+	}
 
-    /**
-     * 杩斿洖鎴愬姛娑堟伅
-     * 
-     * @param msg 杩斿洖鍐呭
-     * @return 鎴愬姛娑堟伅
-     */
-    public static AjaxResult<Void> success(String msg)
-    {
-        return AjaxResult.success(msg, null);
-    }
+	/**
+	 * 杩斿洖閿欒娑堟伅
+	 *
+	 * @param msg 杩斿洖鍐呭
+	 * @return 璀﹀憡娑堟伅
+	 */
+	public static AjaxResult<Void> error(String msg) {
+		return AjaxResult.error(msg, null);
+	}
 
-    /**
-     * 杩斿洖鎴愬姛娑堟伅
-     * 
-     * @param msg 杩斿洖鍐呭
-     * @param data 鏁版嵁瀵硅薄
-     * @return 鎴愬姛娑堟伅
-     */
-    public static <T> AjaxResult<T> success(String msg, T data)
-    {
-        return new AjaxResult(HttpStatus.HTTP_OK, msg, data);
-    }
+	/**
+	 * 杩斿洖閿欒娑堟伅
+	 *
+	 * @param msg  杩斿洖鍐呭
+	 * @param data 鏁版嵁瀵硅薄
+	 * @return 璀﹀憡娑堟伅
+	 */
+	public static <T> AjaxResult<T> error(String msg, T data) {
+		return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
+	}
 
-    /**
-     * 杩斿洖閿欒娑堟伅
-     * 
-     * @return
-     */
-    public static AjaxResult<Void> error()
-    {
-        return AjaxResult.error("鎿嶄綔澶辫触");
-    }
+	/**
+	 * 杩斿洖閿欒娑堟伅
+	 *
+	 * @param code 鐘舵�佺爜
+	 * @param msg  杩斿洖鍐呭
+	 * @return 璀﹀憡娑堟伅
+	 */
+	public static AjaxResult<Void> error(int code, String msg) {
+		return new AjaxResult<>(code, msg, null);
+	}
 
-    /**
-     * 杩斿洖閿欒娑堟伅
-     * 
-     * @param msg 杩斿洖鍐呭
-     * @return 璀﹀憡娑堟伅
-     */
-    public static AjaxResult<Void> error(String msg)
-    {
-        return AjaxResult.error(msg, null);
-    }
-
-    /**
-     * 杩斿洖閿欒娑堟伅
-     * 
-     * @param msg 杩斿洖鍐呭
-     * @param data 鏁版嵁瀵硅薄
-     * @return 璀﹀憡娑堟伅
-     */
-    public static <T> AjaxResult<T> error(String msg, T data)
-    {
-        return new AjaxResult(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
-    }
-
-    /**
-     * 杩斿洖閿欒娑堟伅
-     * 
-     * @param code 鐘舵�佺爜
-     * @param msg 杩斿洖鍐呭
-     * @return 璀﹀憡娑堟伅
-     */
-    public static AjaxResult<Void> error(int code, String msg)
-    {
-        return new AjaxResult(code, msg, null);
-    }
 }

--
Gitblit v1.9.3