|
@@ -1,12 +1,13 @@
|
|
|
package com.qs.mp.common.core.domain;
|
|
|
|
|
|
+import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
|
import java.util.HashMap;
|
|
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
|
|
|
|
/**
|
|
|
* 操作消息提醒
|
|
|
- *
|
|
|
+ *
|
|
|
* @author eepay
|
|
|
*/
|
|
|
public class AjaxResult extends HashMap<String, Object>
|
|
@@ -32,8 +33,8 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
ERROR(500),
|
|
|
/** 登陆超时 */
|
|
|
TIMEOUT(401);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private final int value;
|
|
|
|
|
|
Type(int value)
|
|
@@ -65,11 +66,11 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
public AjaxResult()
|
|
|
{
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 初始化一个新创建的 AjaxResult 对象
|
|
|
- *
|
|
|
+ *
|
|
|
* @param type 状态类型
|
|
|
* @param msg 返回内容
|
|
|
*/
|
|
@@ -81,7 +82,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 初始化一个新创建的 AjaxResult 对象
|
|
|
- *
|
|
|
+ *
|
|
|
* @param type 状态类型
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
@@ -92,10 +93,10 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
super.put(MSG_TAG, msg);
|
|
|
super.put(DATA_TAG, data);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 初始化一个新创建的 AjaxResult 对象
|
|
|
- *
|
|
|
+ *
|
|
|
* @param code 状态码
|
|
|
* @param msg 返回内容
|
|
|
*/
|
|
@@ -105,9 +106,9 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
super.put(MSG_TAG, msg);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
+ *
|
|
|
* @param code
|
|
|
* @param msg
|
|
|
* @param data
|
|
@@ -117,11 +118,11 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
super.put(CODE_TAG, code);
|
|
|
super.put(MSG_TAG, msg);
|
|
|
super.put(DATA_TAG, data);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 返回成功消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @return 成功消息
|
|
|
*/
|
|
|
public static AjaxResult success()
|
|
@@ -131,7 +132,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回成功消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @return 成功消息
|
|
|
*/
|
|
@@ -139,10 +140,10 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
{
|
|
|
return AjaxResult.success(msg, null);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 返回成功消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
|
* @return 成功消息
|
|
@@ -154,7 +155,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回成功消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
|
* @return 成功消息
|
|
@@ -166,7 +167,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回警告消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @return 警告消息
|
|
|
*/
|
|
@@ -177,7 +178,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回警告消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
|
* @return 警告消息
|
|
@@ -189,7 +190,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回错误消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public static AjaxResult error()
|
|
@@ -199,7 +200,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回错误消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @return 警告消息
|
|
|
*/
|
|
@@ -208,9 +209,14 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
return AjaxResult.error(msg, null);
|
|
|
}
|
|
|
|
|
|
+ public static AjaxResult error(ErrorCodeEnum errorCodeEnum)
|
|
|
+ {
|
|
|
+ return new AjaxResult(errorCodeEnum.getCode(), errorCodeEnum.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 返回错误消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
|
* @return 警告消息
|
|
@@ -219,30 +225,30 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
{
|
|
|
return new AjaxResult(Type.ERROR, msg, data);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static AjaxResult error(int code,String msg)
|
|
|
{
|
|
|
return new AjaxResult(code, msg);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static AjaxResult error(int code,String msg, Object data)
|
|
|
{
|
|
|
return new AjaxResult(code, msg, data);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 返回错误消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public static AjaxResult timeout()
|
|
|
{
|
|
|
return AjaxResult.timeout("登陆超时");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 返回警告消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @return 警告消息
|
|
|
*/
|
|
@@ -253,7 +259,7 @@ public class AjaxResult extends HashMap<String, Object>
|
|
|
|
|
|
/**
|
|
|
* 返回警告消息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param msg 返回内容
|
|
|
* @param data 数据对象
|
|
|
* @return 警告消息
|