Skip to content

Commit

Permalink
refactor: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
pupilcc committed Jun 14, 2022
1 parent 52ef8db commit 4f910c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/pupilcc/pushbot/extension/ApiResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public static <T> ApiResult<T> failed(IErrorCode errorCode) {
return restResult(null, errorCode);
}

public boolean ok() {
return ApiErrorCode.SUCCESS.getCode() == this.code;
public boolean failed() {
return ApiErrorCode.SUCCESS.getCode() != this.code;
}

/**
* 服务间调用非业务正常,异常直接释放
*/
public T serviceData() {
if (!this.ok()) {
if (!this.failed()) {
throw new ApiException(this.msg);
} else {
return this.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ApiResult<Object> sendMessage(SendMessageDTO dto, String chatToken) {

// 参数校验
ApiResult apiResult = checkParameter(dto);
if (!apiResult.ok()) {
if (apiResult.failed()) {
return apiResult;
}
boolean isSend;
Expand Down

0 comments on commit 4f910c6

Please sign in to comment.