Pre Merge pull request !310 from 郑/master
This commit is contained in:
commit
9b17bc5e75
15
pom.xml
15
pom.xml
|
|
@ -10,7 +10,7 @@
|
|||
<name>ruoyi</name>
|
||||
<url>http://www.ruoyi.vip</url>
|
||||
<description>若依管理系统</description>
|
||||
|
||||
|
||||
<properties>
|
||||
<ruoyi.version>4.7.0</ruoyi.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
<bitwalker.version>1.21</bitwalker.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<swagger.version>3.0.0</swagger.version>
|
||||
<swagger-annotations.version>1.6.2</swagger-annotations.version>
|
||||
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
|
||||
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
||||
<fastjson.version>1.2.78</fastjson.version>
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- SpringBoot的依赖配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -46,14 +47,14 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 验证码 -->
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
|
|
@ -81,7 +82,7 @@
|
|||
<artifactId>shiro-ehcache</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- thymeleaf模板引擎和shiro框架的整合 -->
|
||||
<dependency>
|
||||
<groupId>com.github.theborakompanioni</groupId>
|
||||
|
|
@ -182,7 +183,7 @@
|
|||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
|
|
@ -276,4 +277,4 @@
|
|||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Shiro使用EhCache缓存框架 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
|
|
@ -100,7 +100,12 @@
|
|||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,46 +1,95 @@
|
|||
package com.ruoyi.common.core.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 操作消息提醒
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class AjaxResult extends HashMap<String, Object>
|
||||
{
|
||||
public class AjaxResult<T> extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 状态码 */
|
||||
public static final String CODE_TAG = "code";
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@ApiModelProperty(value = "code : 返回代码,0表示OK,其它的都有对应问题")
|
||||
public int code;
|
||||
|
||||
/** 返回内容 */
|
||||
public static final String MSG_TAG = "msg";
|
||||
/**
|
||||
* 返回内容
|
||||
*/
|
||||
@ApiModelProperty(value = "msg : 如果code!=0,错误信息")
|
||||
public String msg;
|
||||
|
||||
/** 数据对象 */
|
||||
public static final String DATA_TAG = "data";
|
||||
@ApiModelProperty(value = "如果code!=0,message的补充信息")
|
||||
private Object exception;
|
||||
|
||||
/**
|
||||
* 数据对象
|
||||
*/
|
||||
@ApiModelProperty(value = "code为0时返回结果集")
|
||||
public T data = (T) new Object();
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Object getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void setException(Object exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态类型
|
||||
*/
|
||||
public enum Type
|
||||
{
|
||||
/** 成功 */
|
||||
public enum Type {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(0),
|
||||
/** 警告 */
|
||||
/**
|
||||
* 警告
|
||||
*/
|
||||
WARN(301),
|
||||
/** 错误 */
|
||||
/**
|
||||
* 错误
|
||||
*/
|
||||
ERROR(500);
|
||||
private final int value;
|
||||
|
||||
Type(int value)
|
||||
{
|
||||
Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,49 +97,56 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
public AjaxResult()
|
||||
{
|
||||
public AjaxResult() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param type 状态类型
|
||||
* @param msg 返回内容
|
||||
* @param msg 返回内容
|
||||
*/
|
||||
public AjaxResult(Type type, String msg)
|
||||
{
|
||||
super.put(CODE_TAG, type.value);
|
||||
super.put(MSG_TAG, msg);
|
||||
public AjaxResult(Type type, String msg) {
|
||||
super.put(String.valueOf(code), type.value);
|
||||
super.put(msg, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param type 状态类型
|
||||
* @param msg 返回内容
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
*/
|
||||
public AjaxResult(Type type, String msg, Object data)
|
||||
{
|
||||
super.put(CODE_TAG, type.value);
|
||||
super.put(MSG_TAG, msg);
|
||||
if (StringUtils.isNotNull(data))
|
||||
{
|
||||
super.put(DATA_TAG, data);
|
||||
public AjaxResult(Type type, String msg, Object data) {
|
||||
super.put(String.valueOf(code), type.value);
|
||||
super.put(msg, msg);
|
||||
if (StringUtils.isNotNull(data)) {
|
||||
super.put((String) data, data);
|
||||
}
|
||||
}
|
||||
|
||||
public AjaxResult(String errorMsg) {
|
||||
this.msg = errorMsg;
|
||||
this.code = 500;
|
||||
this.data = (T) new Object();
|
||||
}
|
||||
|
||||
public AjaxResult(String errorMsg, int code) {
|
||||
this.msg = errorMsg;
|
||||
this.code = code;
|
||||
this.data = (T) new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 数据对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value)
|
||||
{
|
||||
public AjaxResult put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
|
@ -100,9 +156,11 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success()
|
||||
{
|
||||
return AjaxResult.success("操作成功");
|
||||
public static AjaxResult success() {
|
||||
AjaxResult result = new AjaxResult<>();
|
||||
result.setCode(Type.SUCCESS.value);
|
||||
result.setMsg("操作成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,9 +168,10 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(Object data)
|
||||
{
|
||||
return AjaxResult.success("操作成功", data);
|
||||
public static AjaxResult success(Object data) {
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,21 +180,24 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* @param msg 返回内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg)
|
||||
{
|
||||
return AjaxResult.success(msg, null);
|
||||
public static AjaxResult success(String msg) {
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(Type.SUCCESS, msg, data);
|
||||
public static AjaxResult success(String msg, Object data) {
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.setData(data);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,21 +206,24 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult warn(String msg)
|
||||
{
|
||||
return AjaxResult.warn(msg, null);
|
||||
public static AjaxResult warn(String msg) {
|
||||
AjaxResult result = new AjaxResult();
|
||||
result.setCode(Type.WARN.value);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult warn(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(Type.WARN, msg, data);
|
||||
public static AjaxResult warn(String msg, Object data) {
|
||||
AjaxResult result = AjaxResult.warn(msg);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -166,9 +231,11 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public static AjaxResult error()
|
||||
{
|
||||
return AjaxResult.error("操作失败");
|
||||
public static AjaxResult error() {
|
||||
AjaxResult result = new AjaxResult<>();
|
||||
result.setCode(Type.ERROR.value);
|
||||
result.setMsg("操作失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -177,20 +244,23 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg)
|
||||
{
|
||||
return AjaxResult.error(msg, null);
|
||||
public static AjaxResult error(String msg) {
|
||||
AjaxResult result = AjaxResult.error();
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(Type.ERROR, msg, data);
|
||||
public static AjaxResult error(String msg, Object data) {
|
||||
AjaxResult result = AjaxResult.error();
|
||||
result.setMsg(msg);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue