若依3.3

This commit is contained in:
RuoYi
2019-03-31 12:56:04 +08:00
parent 7e67c233dc
commit 87b7e8665a
88 changed files with 1738 additions and 619 deletions

View File

@ -81,7 +81,7 @@ public class Global
*/
public static String getVersion()
{
return StringUtils.nvl(getConfig("ruoyi.version"), "3.2.0");
return StringUtils.nvl(getConfig("ruoyi.version"), "3.3.0");
}
/**

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.InitBinder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.AjaxResult.Type;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
@ -156,9 +157,9 @@ public class BaseController
/**
* 返回错误码消息
*/
public AjaxResult error(int code, String message)
public AjaxResult error(Type type, String message)
{
return AjaxResult.error(code, message);
return new AjaxResult(type, message);
}
/**

View File

@ -1,6 +1,8 @@
package com.ruoyi.common.core.domain;
import java.util.HashMap;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 操作消息提醒
@ -11,63 +13,81 @@ public class AjaxResult extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
public static final String CODE_TAG = "code";
public static final String MSG_TAG = "msg";
public static final String DATA_TAG = "data";
/**
* 初始化一个新创建的 Message 对象
* 状态类型
*/
public enum Type
{
/** 成功 */
SUCCESS(0),
/** 警告 */
WARN(301),
/** 错误 */
ERROR(500);
private final int value;
Type(int value)
{
this.value = value;
}
public int value()
{
return this.value;
}
}
/** 状态类型 */
private Type type;
/** 状态码 */
private int code;
/** 返回内容 */
private String msg;
/** 数据对象 */
private Object data;
/**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
*/
public AjaxResult()
{
}
/**
* 返回错误消息
* 初始化一个新创建的 AjaxResult 对象
*
* @return 错误消息
* @param type 状态类型
* @param msg 返回内容
*/
public static AjaxResult error()
public AjaxResult(Type type, String msg)
{
return error(1, "操作失败");
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
}
/**
* 返回错误消息
* 初始化一个新创建的 AjaxResult 对象
*
* @param msg 内容
* @return 错误消息
* @param type 状态类型
* @param msg 返回内容
* @param data 数据对象
*/
public static AjaxResult error(String msg)
public AjaxResult(Type type, String msg, Object data)
{
return error(500, msg);
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
super.put(DATA_TAG, data);
}
/**
* 返回错误消息
*
* @param code 错误码
* @param msg 内容
* @return 错误消息
*/
public static AjaxResult error(int code, String msg)
{
AjaxResult json = new AjaxResult();
json.put("code", code);
json.put("msg", msg);
return json;
}
/**
* 返回成功消息
*
* @param msg 内容
* @return 成功消息
*/
public static AjaxResult success(String msg)
{
AjaxResult json = new AjaxResult();
json.put("msg", msg);
json.put("code", 0);
return json;
}
/**
* 返回成功消息
*
@ -81,14 +101,128 @@ public class AjaxResult extends HashMap<String, Object>
/**
* 返回成功消息
*
* @param key 键值
* @param value 内容
* @param msg 返回内容
* @return 成功消息
*/
@Override
public AjaxResult put(String key, Object value)
public static AjaxResult success(String msg)
{
super.put(key, value);
return this;
return AjaxResult.success(msg, null);
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data)
{
return new AjaxResult(Type.SUCCESS, msg, data);
}
/**
* 返回警告消息
*
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult warn(String msg)
{
return AjaxResult.warn(msg, null);
}
/**
* 返回警告消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult warn(String msg, Object data)
{
return new AjaxResult(Type.WARN, msg, data);
}
/**
* 返回错误消息
*
* @return
*/
public static AjaxResult error()
{
return AjaxResult.error("操作失败");
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(String msg)
{
return AjaxResult.error(msg, null);
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult error(String msg, Object data)
{
return new AjaxResult(Type.ERROR, msg, data);
}
public Type getType()
{
return type;
}
public void setType(Type type)
{
this.type = type;
}
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 getData()
{
return data;
}
public void setData(Object data)
{
this.data = data;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("code", getCode())
.append("msg", getMsg())
.append("data", getData())
.toString();
}
}