|
|
@@ -63,7 +63,7 @@ public class R<T> implements Serializable {
|
|
|
*/
|
|
|
public static boolean isSuccess(@Nullable R<?> result) {
|
|
|
return Optional.ofNullable(result)
|
|
|
- .map(x -> ObjectUtils.nullSafeEquals(ResultCode.SUCCESS.code, x.code))
|
|
|
+ .map(x -> ObjectUtils.nullSafeEquals(ResultCode.SUCCESS.code, x.code) && x.isSuccess())
|
|
|
.orElse(Boolean.FALSE);
|
|
|
}
|
|
|
|
|
|
@@ -158,6 +158,20 @@ public class R<T> implements Serializable {
|
|
|
return new R<>(ResultCode.FAILURE, msg);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 业务失败但 body 中 {@code code} 仍为 HTTP 200({@link APPConstant#SC_OK}),与部分移动端约定一致:
|
|
|
+ * 仅当 {@code success=false} 时表示失败;拦截器在 {@code code==200} 时仍 resolve 整包 JSON,便于展示 {@code msg}。
|
|
|
+ *
|
|
|
+ * @param msg 提示文案(如「当前店铺已删除。」)
|
|
|
+ */
|
|
|
+ public static <T> R<T> failWithOkStatus(String msg) {
|
|
|
+ R<T> r = new R<>();
|
|
|
+ r.setCode(APPConstant.SC_OK);
|
|
|
+ r.setSuccess(false);
|
|
|
+ r.setData(null);
|
|
|
+ r.setMsg(msg);
|
|
|
+ return r;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 返回R
|