55import static edu .tamu .framework .enums .BusinessValidationType .EXISTS ;
66
77import org .springframework .beans .factory .annotation .Autowired ;
8- import org .springframework .data .domain .Page ;
98import org .springframework .transaction .annotation .Transactional ;
109import org .springframework .web .bind .annotation .RestController ;
1110
12- import com .fasterxml .jackson .core .JsonProcessingException ;
13- import com .fasterxml .jackson .databind .ObjectMapper ;
14-
1511import edu .tamu .app .model .Note ;
16- import edu .tamu .app .model .Service ;
1712import edu .tamu .app .model .repo .NoteRepo ;
1813import edu .tamu .app .model .request .FilteredPageRequest ;
1914import edu .tamu .framework .aspect .annotation .ApiCredentials ;
2015import edu .tamu .framework .aspect .annotation .ApiData ;
2116import edu .tamu .framework .aspect .annotation .ApiMapping ;
22- import edu .tamu .framework .aspect .annotation .ApiModel ;
2317import edu .tamu .framework .aspect .annotation .ApiValidatedModel ;
2418import edu .tamu .framework .aspect .annotation .ApiValidation ;
2519import edu .tamu .framework .aspect .annotation .ApiVariable ;
@@ -34,19 +28,10 @@ public class NoteController {
3428 @ Autowired
3529 private NoteRepo noteRepo ;
3630
37- @ Autowired
38- private ObjectMapper objectMapper ;
39-
40- @ ApiMapping ("/all" )
41- @ Auth (role = "ROLE_ANONYMOUS" )
42- public ApiResponse getAllNotes () {
43- return new ApiResponse (SUCCESS , noteRepo .findAll ());
44- }
45-
46- @ ApiMapping ("/by-service" )
31+ @ ApiMapping ("/query" )
4732 @ Auth (role = "ROLE_ANONYMOUS" )
48- public ApiResponse getAllNotesByService (@ ApiModel Service service ) {
49- return new ApiResponse (SUCCESS , noteRepo .findAllByService ( service ));
33+ public ApiResponse getAllNotesByService (@ ApiData FilteredPageRequest filteredPageRequest ) {
34+ return new ApiResponse (SUCCESS , noteRepo .findAll ( filteredPageRequest . getSpecification (), filteredPageRequest . getPageRequest () ));
5035 }
5136
5237 @ ApiMapping ("/{id}" )
@@ -80,7 +65,7 @@ public ApiResponse remove(@ApiValidatedModel Note note) {
8065 @ ApiMapping ("/page" )
8166 @ Auth (role = "ROLE_ANONYMOUS" )
8267 public ApiResponse page (@ ApiData FilteredPageRequest filteredPageRequest ) {
83- return new ApiResponse (SUCCESS , noteRepo .findAll (filteredPageRequest .toPageRequest ()));
68+ return new ApiResponse (SUCCESS , noteRepo .findAll (filteredPageRequest .getPageRequest ()));
8469 }
8570
8671}
0 commit comments