Nantes Université

Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider ba3950a1 rédigé par Féry Mathieu (Mathius)'s avatar Féry Mathieu (Mathius)
Parcourir les fichiers

feat(controllers): Add max limit (Actually 30)

parent 0e0b881f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,4 +8,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -8,4 +8,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(path = "/api/v1", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/api/v1", produces = MediaType.APPLICATION_JSON_VALUE)
public class BaseController { public class BaseController {
protected Integer adaptLimit(Integer limitSupplied) {
return (limitSupplied == null || limitSupplied > 30) ? 30 : limitSupplied;
}
} }
...@@ -55,7 +55,7 @@ public class Posts extends BaseController { ...@@ -55,7 +55,7 @@ public class Posts extends BaseController {
public WithCursor<List<ShortPost>> posts( public WithCursor<List<ShortPost>> posts(
@Parameter(description = "Limit for request", example = "2") @RequestParam @Nullable Integer limit, @Parameter(description = "Limit for request", example = "2") @RequestParam @Nullable Integer limit,
@Parameter(description = "Cursor for next entity", example = "CgA=") @RequestParam @Nullable String cursor) { @Parameter(description = "Cursor for next entity", example = "CgA=") @RequestParam @Nullable String cursor) {
return shortPostDB.getAllCreatedDesc(limit, cursor != null ? Cursor.fromUrlSafe(cursor) : null); return shortPostDB.getAllCreatedDesc(adaptLimit(limit), cursor != null ? Cursor.fromUrlSafe(cursor) : null);
} }
@CrossOrigin @CrossOrigin
......
...@@ -60,8 +60,8 @@ public class Users extends BaseController { ...@@ -60,8 +60,8 @@ public class Users extends BaseController {
@Parameter(description = "userName research", example = "momo54") @RequestParam @Nullable String userName) { @Parameter(description = "userName research", example = "momo54") @RequestParam @Nullable String userName) {
Cursor cursorObject = cursor != null ? Cursor.fromUrlSafe(cursor) : null; Cursor cursorObject = cursor != null ? Cursor.fromUrlSafe(cursor) : null;
if (userName != null) if (userName != null)
return shortUserDB.searchWithUserNameStartsWith(limit, cursorObject, userName); return shortUserDB.searchWithUserNameStartsWith(adaptLimit(limit), cursorObject, userName);
return shortUserDB.getAllWithoutLinks(limit, cursorObject); return shortUserDB.getAllWithoutLinks(adaptLimit(limit), cursorObject);
} }
@CrossOrigin @CrossOrigin
...@@ -86,7 +86,7 @@ public class Users extends BaseController { ...@@ -86,7 +86,7 @@ public class Users extends BaseController {
@Parameter(description = "Cursor for next entity", example = "CgA=") @RequestParam @Nullable String cursor) @Parameter(description = "Cursor for next entity", example = "CgA=") @RequestParam @Nullable String cursor)
throws ResponseError { throws ResponseError {
Cursor cursorObject = cursor != null ? Cursor.fromUrlSafe(cursor) : null; Cursor cursorObject = cursor != null ? Cursor.fromUrlSafe(cursor) : null;
return shortPostDB.getParentRelatedCreatedDesc(shortUserDB.get(id), limit, cursorObject); return shortPostDB.getParentRelatedCreatedDesc(shortUserDB.get(id), adaptLimit(limit), cursorObject);
} }
@CrossOrigin @CrossOrigin
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter