parent
e4ce453df5
commit
f3cced18d5
@ -99,8 +99,7 @@ public class BizAssertions {
|
||||
|
||||
public static <T> T assertResponse(CommonResponse<T> response, String message, Object... args) {
|
||||
if (response == null || response.getCode() != HttpStatus.HTTP_OK) {
|
||||
ServiceException e = new ServiceException(messageOrTemplateMessage(
|
||||
response == null ? null : response.getMsg(), message, args));
|
||||
ServiceException e = new ServiceException(MessageFormatter.arrayFormat(message, args).getMessage());
|
||||
log.warn("remote call response with error", e);
|
||||
throw e;
|
||||
}
|
||||
@ -113,7 +112,7 @@ public class BizAssertions {
|
||||
|
||||
public static <T> T assertResponse(ApiResult<T> response, String message, Object... args) {
|
||||
if (!response.isSuccess()) {
|
||||
ServiceException e = new ServiceException(messageOrTemplateMessage(response.getMsg(), message, args));
|
||||
ServiceException e = new ServiceException(MessageFormatter.arrayFormat(message, args).getMessage());
|
||||
log.warn("remote call response with error", e);
|
||||
throw e;
|
||||
}
|
||||
@ -126,18 +125,11 @@ public class BizAssertions {
|
||||
|
||||
public static <T> List<T> assertResponse(ApiListResult<T> response, String message, Object... args) {
|
||||
if (!response.isSuccess()) {
|
||||
ServiceException e = new ServiceException(messageOrTemplateMessage(response.getMsg(), message, args));
|
||||
ServiceException e = new ServiceException(MessageFormatter.arrayFormat(message, args).getMessage());
|
||||
log.warn("remote call response with error", e);
|
||||
throw e;
|
||||
}
|
||||
return response.getData();
|
||||
}
|
||||
|
||||
private static String messageOrTemplateMessage(String message, String template, Object... args) {
|
||||
if (message != null) {
|
||||
return message;
|
||||
}
|
||||
return MessageFormatter.arrayFormat(template, args).getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user