完善 R

This commit is contained in:
卢春梦 2024-03-10 11:46:54 +08:00
parent 147288799a
commit 6af2daad18

View File

@ -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);
}
}