-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2024 Apollo Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.ctrip.framework.apollo.common.http; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class SearchResponseEntity<T> { | ||
Check warning on line 21 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L21
|
||
|
||
private T body; | ||
private boolean hasMoreData; | ||
private Object message; | ||
private int code; | ||
|
||
public static <T> SearchResponseEntity<T> ok(T body){ | ||
SearchResponseEntity<T> SearchResponseEntity = new SearchResponseEntity<>(); | ||
SearchResponseEntity.message = HttpStatus.OK.getReasonPhrase(); | ||
SearchResponseEntity.code = HttpStatus.OK.value(); | ||
SearchResponseEntity.body = body; | ||
SearchResponseEntity.hasMoreData = false; | ||
return SearchResponseEntity; | ||
Check warning on line 34 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L29-L34
|
||
} | ||
|
||
public static <T> SearchResponseEntity<T> okWithMessage(T body, Object message){ | ||
SearchResponseEntity<T> SearchResponseEntity = new SearchResponseEntity<>(); | ||
SearchResponseEntity.message = message; | ||
SearchResponseEntity.code = HttpStatus.OK.value(); | ||
SearchResponseEntity.body = body; | ||
SearchResponseEntity.hasMoreData = true; | ||
return SearchResponseEntity; | ||
Check warning on line 43 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L38-L43
|
||
} | ||
|
||
public static <T> SearchResponseEntity<T> error(HttpStatus httpCode, Object message){ | ||
SearchResponseEntity<T> SearchResponseEntity = new SearchResponseEntity<>(); | ||
SearchResponseEntity.message = message; | ||
SearchResponseEntity.code = httpCode.value(); | ||
return SearchResponseEntity; | ||
Check warning on line 50 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L47-L50
|
||
} | ||
|
||
public int getCode() { | ||
return code; | ||
Check warning on line 54 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L54
|
||
} | ||
|
||
public Object getMessage() { | ||
return message; | ||
Check warning on line 58 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L58
|
||
} | ||
|
||
public T getBody() { | ||
return body; | ||
Check warning on line 62 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L62
|
||
} | ||
|
||
public boolean isHasMoreData() {return hasMoreData;} | ||
Check warning on line 65 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java Codecov / codecov/patchapollo-common/src/main/java/com/ctrip/framework/apollo/common/http/SearchResponseEntity.java#L65
|
||
|
||
} |