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