Repository navigation
Add meal plan CRUD routes - #49
Merged
Merged
Conversation
- Missing or other users' meal plans return 404 - Delete goes through User.removeMealPlan so entries are removed and recipes are kept - Added MealPlanServiceTest (Mockito) and MealPlanServiceJpaTest (cascade, ownership)
- GET list (paginated, size 1-100), POST, GET by id, PATCH, DELETE - Enabled RFC 9457 Problem Details for errors - Set hibernate default_batch_fetch_size to avoid N+1 on entries - Added MealPlanControllerTest for 200/201/204/400/404
- springdoc-openapi-starter-webmvc-ui 3.1.1 (Spring Boot 4) - Test that /v3/api-docs and /swagger-ui.html are served
Yooze0x4c8
requested review from
Solian21,
annabelleb20 and
leslyVillanueva1020
as code owners
October 15, 2026 03:51
Solian21
approved these changes
Oct 15, 2026
Solian21
left a comment
Owner
There was a problem hiding this comment.
I think it looks really good overall. The CRUD routes are pretty well organized and user ownership is enforced through the repository queries.
annabelleb20
approved these changes
Oct 15, 2026
annabelleb20
left a comment
Collaborator
There was a problem hiding this comment.
I really like how this is formatted, hopefully all the TODOs are able to be covered by my PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45
What changed
MealPlanControllerfor/api/v1/meal-plansGET /api/v1/meal-plans?page&size: paginated list of the signed-in user's plans (content+pagemetadata,size1–100,page≥ 0)POST /api/v1/meal-plans: 201 with aLocationheader, starts with emptyentriesGET /api/v1/meal-plans/{mealPlanId}: plan with its entriesPATCH /api/v1/meal-plans/{mealPlanId}: changesweekStartonly, entries are keptDELETE /api/v1/meal-plans/{mealPlanId}: 204, deletes the plan's entries but keeps the recipesMealPlanServiceandMealPlanRepository. Lookups are scoped to the owner, so a missing plan and another user's plan both return 404 (not 403)MealPlanCreate,MealPlanPatch,MealPlanResponse,MealPlanEntryResponse) so entities are never serialized directlyMealPlan.changeWeekStartspring.mvc.problemdetails.enabled) for 400/404 errorshibernate.default_batch_fetch_sizeto avoid N+1 queries when listing entries/swagger-ui.html, docs at/v3/api-docs)Depends on #48
This PR works on top of
mainwithout Spring Security, so some parts are temporary and marked withTODO(#48):displayNameis not unique). For now the user is looked up throughMealPlanRepository.findUserByEmail. After Implemented User GET, PATCH, DELETE API routes #48 merges, this moves toUserRepository.findByEmail/UserService.getUserByEmail, andloadUserByUsernameshould use email as the username. The steps are in the TODO onfindUserByEmail.SecurityConfig(see my comment on Implemented User GET, PATCH, DELETE API routes #48). A 401 test will be added toMealPlanControllerTestafter that./swagger-ui.html,/swagger-ui/**,/v3/api-docs/**) will needpermitAll()inSecurityConfig.How I tested it
./gradlew check, service package coverage above the 70% floor)MealPlanServiceTest: 404 for missing/other users' plans, empty list, new plan is owned and empty, update keeps entries, delete removes the plan from its ownerMealPlanServiceJpaTest: deleting a plan removes entries but keeps recipes; other users' plans are hidden from get and listMealPlanControllerTest: page shape, 400 for bad paging / missing or invalid date / empty PATCH body, 201 +Location, 204, 404 asapplication/problem+jsonApiApplicationTests:/v3/api-docsand/swagger-ui.htmlare serveddocs/openapi.yamlis updated and lints clean. Not applicable: the implementation follows the existing contract, anddocs/openapi.yamlwas not changed.Reviewers
2 approving teammates who are not the author (1 for a team of 3).