Skip to content

Commit f3e8fa8

Browse files
committed
feat: release 1.2.4
- pagination support added in CommonResponse
1 parent d87e441 commit f3e8fa8

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ framework and objects.
4949
<dependency>
5050
<groupId>com.javaquery</groupId>
5151
<artifactId>util</artifactId>
52-
<version>1.2.3</version>
52+
<version>1.2.4</version>
5353
</dependency>
5454
```
5555

5656
# Gradle
5757

5858
```
59-
implementation 'com.javaquery:util:1.2.3'
59+
implementation 'com.javaquery:util:1.2.4'
6060
```

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66

77
sourceCompatibility = 1.8
88
group 'com.javaquery'
9-
version '1.2.3'
9+
version '1.2.4'
1010

1111
repositories {
1212
mavenCentral()

src/main/java/com/javaquery/util/http/CommonResponse.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public class CommonResponse<T> implements Serializable {
2525
@JsonProperty("error_messages")
2626
private final List<String> errorMessages;
2727

28+
private int page;
29+
private int limit;
30+
private int total;
31+
2832
private CommonResponse(int statusCode, String message, T payload, List<String> errorMessages) {
2933
this.statusCode = statusCode;
3034
this.message = message;
@@ -67,4 +71,31 @@ public T getPayload() {
6771
public List<String> getErrorMessages() {
6872
return errorMessages;
6973
}
74+
75+
public int getPage() {
76+
return page;
77+
}
78+
79+
public CommonResponse<T> setPage(int page) {
80+
this.page = page;
81+
return this;
82+
}
83+
84+
public int getLimit() {
85+
return limit;
86+
}
87+
88+
public CommonResponse<T> setLimit(int limit) {
89+
this.limit = limit;
90+
return this;
91+
}
92+
93+
public int getTotal() {
94+
return total;
95+
}
96+
97+
public CommonResponse<T> setTotal(int total) {
98+
this.total = total;
99+
return this;
100+
}
70101
}

src/test/java/com/javaquery/util/http/TestCommonResponse.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,15 @@ public void ofWithStatusCodeErrorMessages(){
4444
Assertions.assertEquals(HttpStatus.BAD_REQUEST.value(), commonResponse.getStatusCode());
4545
Assertions.assertEquals("errorMessage", commonResponse.getErrorMessages().get(0));
4646
}
47+
48+
@Test
49+
public void okWithPaging(){
50+
CommonResponse<Long> commonResponse = CommonResponse.of(HttpStatus.CREATED, 1L);
51+
commonResponse.setPage(1).setLimit(10).setTotal(100);
52+
Assertions.assertEquals(HttpStatus.CREATED.value(), commonResponse.getStatusCode());
53+
Assertions.assertEquals(1L, commonResponse.getPayload());
54+
Assertions.assertEquals(1, commonResponse.getPage());
55+
Assertions.assertEquals(10, commonResponse.getLimit());
56+
Assertions.assertEquals(100, commonResponse.getTotal());
57+
}
4758
}

0 commit comments

Comments
 (0)