Skip to content

Commit 92b86d5

Browse files
committed
修改数据接口实现
1 parent 9e97c96 commit 92b86d5

22 files changed

Lines changed: 40 additions & 58 deletions

File tree

admin/src/main/java/info/xiaomo/admin/controller/AdminUserController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import info.xiaomo.core.untils.MD5Util;
88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.data.domain.Page;
10-
import org.springframework.data.domain.PageRequest;
1110
import org.springframework.web.bind.annotation.RequestMapping;
1211
import org.springframework.web.bind.annotation.RequestMethod;
1312
import org.springframework.web.bind.annotation.RequestParam;
@@ -128,7 +127,7 @@ public HashMap<String, Object> findUserById(@RequestParam("id") Long id) {
128127

129128
@RequestMapping(value = "findAll", method = RequestMethod.GET)
130129
public HashMap<String, Object> getAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int page) {
131-
Page<AdminModel> pages = service.getAdminUsers(new PageRequest(start - 1, page));
130+
Page<AdminModel> pages = service.getAdminUsers(start, page);
132131
result.put(code, success);
133132
result.put(adminUsers, pages);
134133
return result;

admin/src/main/java/info/xiaomo/admin/controller/BlogController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import info.xiaomo.core.service.BlogService;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.data.domain.Page;
8-
import org.springframework.data.domain.PageRequest;
98
import org.springframework.web.bind.annotation.RequestMapping;
109
import org.springframework.web.bind.annotation.RequestMethod;
1110
import org.springframework.web.bind.annotation.RequestParam;
@@ -83,7 +82,7 @@ public HashMap<String, Object> findByTitle(@RequestParam String title) {
8382
*/
8483
@RequestMapping("findAll")
8584
public HashMap<String, Object> findAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
86-
Page<BlogModel> all = service.findAll(new PageRequest(start - 1, pageSize));
85+
Page<BlogModel> all = service.findAll(start, pageSize);
8786
result.put(code, success);
8887
result.put(blogs, all);
8988
return result;

admin/src/main/java/info/xiaomo/admin/controller/LinkController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import info.xiaomo.core.service.LinkService;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.data.domain.Page;
8-
import org.springframework.data.domain.PageRequest;
98
import org.springframework.web.bind.annotation.RequestMapping;
109
import org.springframework.web.bind.annotation.RequestParam;
1110
import org.springframework.web.bind.annotation.RestController;
@@ -59,8 +58,8 @@ public HashMap<String, Object> findByName(@RequestParam String name) {
5958

6059

6160
@RequestMapping("findAll")
62-
public HashMap<String, Object> findAll(@RequestParam(value = "start",defaultValue = "1") int start, @RequestParam(value = "pageSize",defaultValue = "10") int pageSize) {
63-
Page<LinkModel> models = service.findAll(new PageRequest(start - 1, pageSize));
61+
public HashMap<String, Object> findAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
62+
Page<LinkModel> models = service.findAll(start, pageSize);
6463
result.put(code, success);
6564
result.put(links, models);
6665
return result;

admin/src/main/java/info/xiaomo/admin/controller/TagController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import info.xiaomo.core.service.TagService;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.data.domain.Page;
8-
import org.springframework.data.domain.PageRequest;
98
import org.springframework.web.bind.annotation.RequestMapping;
109
import org.springframework.web.bind.annotation.RequestParam;
1110
import org.springframework.web.bind.annotation.RestController;
@@ -59,8 +58,8 @@ public HashMap<String, Object> findByName(@RequestParam String name) {
5958

6059

6160
@RequestMapping("findAll")
62-
public HashMap<String, Object> findAll(@RequestParam(value = "start",defaultValue = "1") int start, @RequestParam(value = "pageSize",defaultValue = "10") int pageSize) {
63-
Page<TagModel> models = service.findAll(new PageRequest(start - 1, pageSize));
61+
public HashMap<String, Object> findAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
62+
Page<TagModel> models = service.findAll(start, pageSize);
6463
result.put(code, success);
6564
result.put(tags, models);
6665
return result;

admin/src/main/java/info/xiaomo/admin/controller/UserController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import info.xiaomo.core.service.UserService;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.data.domain.Page;
9-
import org.springframework.data.domain.PageRequest;
109
import org.springframework.web.bind.annotation.RequestMapping;
1110
import org.springframework.web.bind.annotation.RequestMethod;
1211
import org.springframework.web.bind.annotation.RequestParam;
@@ -61,8 +60,8 @@ public HashMap<String, Object> findUserById(@RequestParam("id") Long id) {
6160
* @return result
6261
*/
6362
@RequestMapping(value = "findAll", method = RequestMethod.GET)
64-
public HashMap<String, Object> getAll(@RequestParam(value = "start",defaultValue = "1") int start, @RequestParam(value = "pageSize",defaultValue = "10") int page) {
65-
Page<UserModel> pages = service.findAll(new PageRequest(start - 1, page));
63+
public HashMap<String, Object> getAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
64+
Page<UserModel> pages = service.findAll(start, pageSize);
6665
result.put(code, success);
6766
result.put(users, pages);
6867
return result;

admin/src/test/java/info/xiaomo/admin/test/userTest/UserControllerTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.junit.Test;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.data.domain.Page;
9-
import org.springframework.data.domain.PageRequest;
109

1110
/**
1211
* │\__╭╭╭╭╭__/│
@@ -37,7 +36,7 @@ public class UserControllerTest extends BaseTest {
3736

3837
@Test
3938
public void testFindAll() {
40-
Page<UserModel> all = service.findAll(new PageRequest(0, 5));
39+
Page<UserModel> all = service.findAll(1, 5);
4140
for (UserModel userModel : all) {
4241
System.out.println(userModel.getNickName());
4342
}
@@ -48,6 +47,5 @@ public void testUpdate() {
4847
UserModel userModel = new UserModel();
4948

5049

51-
5250
}
5351
}

core/src/main/java/info/xiaomo/core/service/AdminUserService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import info.xiaomo.core.exception.UserNotFoundException;
44
import info.xiaomo.core.model.AdminModel;
55
import org.springframework.data.domain.Page;
6-
import org.springframework.data.domain.Pageable;
76

87
/**
98
* │\__╭╭╭╭╭__/│
@@ -37,7 +36,7 @@ public interface AdminUserService {
3736

3837
AdminModel updateAdminUser(AdminModel model) throws UserNotFoundException;
3938

40-
Page<AdminModel> getAdminUsers(Pageable pageable);
39+
Page<AdminModel> getAdminUsers(int start ,int pageSize);
4140

4241
AdminModel deleteAdminUserById(Long id) throws UserNotFoundException;
4342

core/src/main/java/info/xiaomo/core/service/BlogService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import info.xiaomo.core.model.BlogModel;
44
import org.springframework.data.domain.Page;
55

6-
import org.springframework.data.domain.Pageable;
7-
86
/**
97
* 把今天最好的表现当作明天最新的起点..~
108
* いま 最高の表現 として 明日最新の始発..~
@@ -25,7 +23,7 @@ public interface BlogService {
2523

2624
BlogModel findBlogByTitle(String title);
2725

28-
Page<BlogModel> findAll(Pageable pageable);
26+
Page<BlogModel> findAll(int start ,int pageSize);
2927

3028
BlogModel addBlog(BlogModel model);
3129

core/src/main/java/info/xiaomo/core/service/ChangeLogService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import info.xiaomo.core.model.ChangeLogModel;
44
import org.springframework.data.domain.Page;
5-
import org.springframework.data.domain.Pageable;
65

76
/**
87
* 把今天最好的表现当作明天最新的起点..~
@@ -24,7 +23,7 @@ public interface ChangeLogService {
2423

2524
ChangeLogModel findByName(String name);
2625

27-
Page<ChangeLogModel> findAll(Pageable pageable);
26+
Page<ChangeLogModel> findAll(int start ,int pageSize);
2827

2928
ChangeLogModel add(ChangeLogModel model);
3029

core/src/main/java/info/xiaomo/core/service/LinkService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import info.xiaomo.core.model.LinkModel;
44
import org.springframework.data.domain.Page;
5-
import org.springframework.data.domain.Pageable;
65

76
/**
87
* 把今天最好的表现当作明天最新的起点..~
@@ -24,7 +23,7 @@ public interface LinkService {
2423

2524
LinkModel findByName(String name);
2625

27-
Page<LinkModel> findAll(Pageable pageable);
26+
Page<LinkModel> findAll(int start ,int pageSize);
2827

2928
LinkModel add(LinkModel model);
3029

0 commit comments

Comments
 (0)