Commit 038d27d7 authored by yanzg's avatar yanzg

Merge branch 'ver1.1' of http://192.168.0.204/yzg/yzg-util

parents 7b578beb 001cb613
...@@ -109,7 +109,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -109,7 +109,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 获取结果状态码 * 获取结果状态码
* *
* @return * @return 状态码
*/ */
public String getCode() { public String getCode() {
return code; return code;
...@@ -118,7 +118,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -118,7 +118,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 设置请求结果状态码 * 设置请求结果状态码
* *
* @param code * @param code 状态码
*/ */
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
...@@ -127,7 +127,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -127,7 +127,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 获取结果消息 * 获取结果消息
* *
* @return * @return 消息内容
*/ */
public String getMessage() { public String getMessage() {
return message; return message;
...@@ -136,7 +136,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -136,7 +136,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 设置结果消息 * 设置结果消息
* *
* @param message * @param message 消息
*/ */
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
...@@ -145,7 +145,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -145,7 +145,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 获取数据 * 获取数据
* *
* @return * @return 数据
*/ */
public T getData() { public T getData() {
return data; return data;
...@@ -154,7 +154,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -154,7 +154,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 设置数据 * 设置数据
* *
* @param data * @param data 数据
*/ */
public void setData(T data) { public void setData(T data) {
this.data = data; this.data = data;
...@@ -172,7 +172,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -172,7 +172,7 @@ public class ResponseResult<T> extends BaseVo {
/** /**
* 设置数据源 * 设置数据源
* *
* @param target * @param target 目标
*/ */
public void setTarget(Object target) { public void setTarget(Object target) {
this.target = target; this.target = target;
...@@ -203,7 +203,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -203,7 +203,7 @@ public class ResponseResult<T> extends BaseVo {
* @param <T> 数据类型 * @param <T> 数据类型
* @return 一个请求成功的数据集合 * @return 一个请求成功的数据集合
*/ */
public static <T extends Object> ResponseResult<T> result(T data) { public static <T> ResponseResult<T> result(T data) {
return result(data, false); return result(data, false);
} }
...@@ -214,7 +214,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -214,7 +214,7 @@ public class ResponseResult<T> extends BaseVo {
* @param <T> 数据类型 * @param <T> 数据类型
* @return 一个请求成功的数据集合 * @return 一个请求成功的数据集合
*/ */
public static <T extends Object> ResponseResult<T> resultAllowNull(T data) { public static <T> ResponseResult<T> resultAllowNull(T data) {
return result(data, true); return result(data, true);
} }
...@@ -227,14 +227,14 @@ public class ResponseResult<T> extends BaseVo { ...@@ -227,14 +227,14 @@ public class ResponseResult<T> extends BaseVo {
* @param <T> 数据类型 * @param <T> 数据类型
* @return 一个请求成功的数据集合 * @return 一个请求成功的数据集合
*/ */
public static <T extends Object> ResponseResult<T> result(T data, boolean allowNull) { public static <T> ResponseResult<T> result(T data, boolean allowNull) {
ResponseResult<T> ret = new ResponseResult<T>(); ResponseResult<T> ret = new ResponseResult<>();
ret.setData(data); ret.setData(data);
initDataStatus(ret, data, allowNull); initDataStatus(ret, data, allowNull);
return ret; return ret;
} }
protected static void initDataStatus(ResponseResult ret, Object data, boolean allowNull) { protected static void initDataStatus(ResponseResult<?> ret, Object data, boolean allowNull) {
if (!allowNull && StringHelper.isEmpty(data)) { if (!allowNull && StringHelper.isEmpty(data)) {
ret.setCode(ResultConstants.RESULT_EMPTY); ret.setCode(ResultConstants.RESULT_EMPTY);
ret.setMessage("结果为空"); ret.setMessage("结果为空");
...@@ -244,7 +244,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -244,7 +244,7 @@ public class ResponseResult<T> extends BaseVo {
} }
} }
public static final ResponseResult<Object> OK = new ResponseResult(); public static final ResponseResult<?> OK = new ResponseResult<>();
/** /**
* 处理错误 * 处理错误
...@@ -252,7 +252,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -252,7 +252,7 @@ public class ResponseResult<T> extends BaseVo {
* @param target 错误源对象 * @param target 错误源对象
* @return 处理的错误 * @return 处理的错误
*/ */
public static final ResponseResult<Object> error(Object target) { public static ResponseResult<?> error(Object target) {
return error(ResultConstants.UNKNOW_ERROR, "未知异常", target); return error(ResultConstants.UNKNOW_ERROR, "未知异常", target);
} }
...@@ -263,7 +263,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -263,7 +263,7 @@ public class ResponseResult<T> extends BaseVo {
* @param message 错误消息 * @param message 错误消息
* @return 处理的错误 * @return 处理的错误
*/ */
public static final ResponseResult<Object> error(String code, String message) { public static ResponseResult<?> error(String code, String message) {
return error(code, message, null); return error(code, message, null);
} }
...@@ -274,7 +274,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -274,7 +274,7 @@ public class ResponseResult<T> extends BaseVo {
* @param target 错误标记 * @param target 错误标记
* @return 处理的错误 * @return 处理的错误
*/ */
public static final ResponseResult<Object> error(String message, Object target) { public static ResponseResult<?> error(String message, Object target) {
return error(ResultConstants.UNKNOW_ERROR, message, target); return error(ResultConstants.UNKNOW_ERROR, message, target);
} }
...@@ -284,7 +284,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -284,7 +284,7 @@ public class ResponseResult<T> extends BaseVo {
* @param ex 错误消息 * @param ex 错误消息
* @return 处理的错误 * @return 处理的错误
*/ */
public static final ResponseResult error(Exception ex) { public static ResponseResult<?> error(Exception ex) {
return ExceptionHelper.getError(ex); return ExceptionHelper.getError(ex);
} }
...@@ -296,7 +296,7 @@ public class ResponseResult<T> extends BaseVo { ...@@ -296,7 +296,7 @@ public class ResponseResult<T> extends BaseVo {
* @param target 错误标记 * @param target 错误标记
* @return 处理的错误 * @return 处理的错误
*/ */
public static final ResponseResult<Object> error(String code, String message, Object target) { public static ResponseResult<?> error(String code, String message, Object target) {
return new ResponseResult<>(code, message, null, target); return new ResponseResult<>(code, message, null, target);
} }
...@@ -305,11 +305,11 @@ public class ResponseResult<T> extends BaseVo { ...@@ -305,11 +305,11 @@ public class ResponseResult<T> extends BaseVo {
* *
* @param ex 异常信息 * @param ex 异常信息
* @param cls 返回类型 * @param cls 返回类型
* @param <T> * @param <T> 处理空数据的类型
* @param <M> * @param <M> 异常类型
* @return * @return 正常空数据
*/ */
public static final <T, M extends Exception> T isEmpty(M ex, Class<T> cls) throws M { public static <T, M extends Exception> T isEmpty(M ex, Class<T> cls) throws M {
if (ex instanceof CodeException) { if (ex instanceof CodeException) {
CodeException codeException = (CodeException) ex; CodeException codeException = (CodeException) ex;
if (StringHelper.compare(codeException.getCode(), ResultConstants.RESULT_EMPTY)) { if (StringHelper.compare(codeException.getCode(), ResultConstants.RESULT_EMPTY)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment