mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 20:29:27 +08:00
✨ 完善 R
This commit is contained in:
parent
147288799a
commit
6af2daad18
@ -130,6 +130,16 @@ public class R<T> implements Serializable {
|
||||
return new R<>(code, data, data == null ? BladeConstant.DEFAULT_NULL_MESSAGE : msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*
|
||||
* @param <T> 泛型标记
|
||||
* @return Result
|
||||
*/
|
||||
public static <T> R<T> success() {
|
||||
return new R<>(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回R
|
||||
*
|
||||
@ -222,4 +232,16 @@ public class R<T> implements Serializable {
|
||||
return flag ? success(BladeConstant.DEFAULT_SUCCESS_MESSAGE) : fail(BladeConstant.DEFAULT_FAILURE_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态返回成功或者失败
|
||||
*
|
||||
* @param status 状态
|
||||
* @param msg 异常msg
|
||||
* @param <T> 泛型标记
|
||||
* @return Result
|
||||
*/
|
||||
public static <T> R<T> status(boolean status, String msg) {
|
||||
return status ? R.success() : R.fail(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user