Skip to content

Commit d8e92ba

Browse files
committed
fix #177
1 parent 30e205c commit d8e92ba

11 files changed

Lines changed: 62 additions & 10 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.10.29</version>
18+
<version>2.10.30</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.29</version>
9+
<version>2.10.30</version>
1010
</parent>
1111

1212
<name>springboot-starter-data-authorization</name>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>2.10.29</version>
8+
<version>2.10.30</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.29</version>
9+
<version>2.10.30</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.10.29</version>
9+
<version>2.10.30</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.10.29</version>
8+
<version>2.10.30</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.codingapi.springboot.framework.context;
2+
3+
import com.codingapi.springboot.framework.dto.ICurrentOffset;
4+
import com.codingapi.springboot.framework.dto.request.PageRequest;
5+
import lombok.Getter;
6+
import lombok.Setter;
7+
8+
public class CurrentPageOffsetContext implements ICurrentPageOffset{
9+
10+
@Getter
11+
private static final CurrentPageOffsetContext instance = new CurrentPageOffsetContext();
12+
13+
private CurrentPageOffsetContext(){}
14+
15+
@Setter
16+
private ICurrentPageOffset currentPageOffset = new ICurrentPageOffset(){
17+
@Override
18+
public int getCurrentPage(ICurrentOffset target, int current) {
19+
if(target instanceof PageRequest){
20+
return current;
21+
}
22+
return current - 1;
23+
}
24+
};
25+
26+
public int getCurrentPage(ICurrentOffset target,int current) {
27+
return currentPageOffset.getCurrentPage(target,current);
28+
}
29+
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codingapi.springboot.framework.context;
2+
3+
import com.codingapi.springboot.framework.dto.ICurrentOffset;
4+
5+
public interface ICurrentPageOffset {
6+
7+
int getCurrentPage(ICurrentOffset target, int current);
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codingapi.springboot.framework.dto;
2+
3+
public interface ICurrentOffset {
4+
5+
void setCurrent(int current);
6+
7+
}

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/PageRequest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.codingapi.springboot.framework.dto.request;
22

3+
import com.codingapi.springboot.framework.context.CurrentPageOffsetContext;
4+
import com.codingapi.springboot.framework.dto.ICurrentOffset;
35
import lombok.Getter;
46
import lombok.Setter;
57
import org.springframework.data.domain.Sort;
68

7-
public class PageRequest extends org.springframework.data.domain.PageRequest {
9+
public class PageRequest extends org.springframework.data.domain.PageRequest implements ICurrentOffset {
810

911
@Getter
10-
@Setter
1112
private int current;
1213

1314
@Setter
@@ -32,6 +33,10 @@ public PageRequest() {
3233
this(0, 20, Sort.unsorted());
3334
}
3435

36+
public void setCurrent(int current) {
37+
this.current = CurrentPageOffsetContext.getInstance().getCurrentPage(this,current);
38+
}
39+
3540
public String getStringFilter(String key) {
3641
return requestFilter.getStringFilter(key);
3742
}

0 commit comments

Comments
 (0)