@@ -57,16 +57,12 @@ public ResponseEntity<Map<String, Object>> articlesPagination(HttpServletRequest
57
57
if (page != -1 ) { // with pagination
58
58
int pageSize = 10 ;
59
59
Principal principal = request .getUserPrincipal ();
60
- if (principal != null ) {
61
- User user = userService .findByNAME (principal .getName ()).get ();
62
60
try {
63
-
64
61
Map <String , Object > response = new HashMap <>();
65
62
List <String > articles_info = new LinkedList <String >();
66
63
Pageable paging = (Pageable ) PageRequest .of (0 , pageSize );
67
64
Page <Article > pageTuts ;
68
-
69
- pageTuts = articleService .findByUSERS (user , paging .withPage (page ));
65
+ pageTuts = articleService .findAllPageable (paging .withPage (page ));
70
66
if (pageTuts .getNumberOfElements () == 0 ) {
71
67
articles_info .add ("Empty" );
72
68
}else {
@@ -79,16 +75,10 @@ public ResponseEntity<Map<String, Object>> articlesPagination(HttpServletRequest
79
75
response .put ("totalItemsUser" , pageTuts .getTotalElements ());
80
76
response .put ("totalItemsThisPage" , pageTuts .getNumberOfElements ());
81
77
response .put ("articles" , articles_info );
82
-
83
-
84
-
85
78
return new ResponseEntity <>(response , HttpStatus .OK );
86
79
} catch (Exception e ) {
87
80
return new ResponseEntity <>(null , HttpStatus .INTERNAL_SERVER_ERROR );
88
81
}
89
- } else {
90
- return ResponseEntity .notFound ().build ();
91
- }
92
82
}else { // without pagination
93
83
Principal principal = request .getUserPrincipal ();
94
84
if (principal != null ) {
0 commit comments