MOSU-105 refactor: SchoolJpa 도시락 여러 개 추가하도록 변경#106
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis change refactors lunch menu handling throughout the school domain and DTOs. It replaces single lunch and price fields with a list of lunch menu objects in entities and request/response DTOs, introduces new classes for lunch menu representation, and updates the database schema generation strategy. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant DTO
participant DomainEntity
participant DB
Client->>Controller: Submit SchoolRegistrationRequest (with lunchMenus)
Controller->>DTO: Map request to DTOs (LunchMenuRequest)
DTO->>DomainEntity: Convert LunchMenuRequest list to LunchMenu list
DomainEntity->>DB: Persist SchoolJpaEntity with List<LunchMenu>
DB-->>DomainEntity: Confirmation
DomainEntity-->>Controller: Persisted entity
Controller-->>Client: Response with lunchMenus
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @jbh010204, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refactors the SchoolJpaEntity and its associated data transfer objects (DTOs) to enable the storage and management of multiple lunch menus per school, moving away from a single lunch option. This change enhances the flexibility of school data by allowing a more comprehensive representation of available lunch offerings, impacting both the persistence layer and the API's input/output structures.
Highlights
- Data Model Refactoring: The
SchoolJpaEntityhas been updated to store a collection ofLunchMenuobjects, replacing the previous singlelunchandlunchPricefields. This allows a school to offer multiple lunch options. - New Embeddable
LunchMenu: A new JPA embeddable classLunchMenuwas introduced to encapsulate the lunch type and its price, facilitating the storage of multiple lunch options. - API DTO Updates: All relevant DTOs (
SchoolRegistrationRequest,SchoolEditRequest,SchoolResponse,AreaDetail) have been modified to reflect the new multiple lunch menu structure, including the introduction ofLunchMenuRequest(for requests) andLunchInfo(for responses) DTOs. - Database Schema Management: The
ddl-autosetting inapplication.ymlwas changed fromupdatetocreate-drop, which will recreate the database schema on each application startup. This is typically used for development and testing of schema changes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request refactors the application to support multiple lunch options for a school. The review focuses on improving the code's robustness and maintainability by addressing a potential NullPointerException, cleaning up the entity constructor, and decoupling the API DTOs from the domain model.
| @Schema(description = "도시락 가격") | ||
| @NotNull | ||
| Integer lunchPrice, | ||
| List<LunchMenuRequest> lunchMenus, |
There was a problem hiding this comment.
The lunchMenus field can be null if it's omitted from the request payload, causing a NullPointerException in the toEntity() method. Add a @NotNull annotation to enforce that the field is always present in the request.
| List<LunchMenuRequest> lunchMenus, | |
| @NotNull | |
| List<LunchMenuRequest> lunchMenus, |
| public SchoolJpaEntity(String schoolName, Area area, Lunch lunch, LocalDate examDate, | ||
| Long capacity, | ||
| LocalDateTime deadlineTime, Integer lunchPrice, AddressJpaVO address) { | ||
| LocalDateTime deadlineTime, Integer lunchPrice, AddressJpaVO address, | ||
| List<LunchMenu> lunchMenu | ||
| ) { |
There was a problem hiding this comment.
The constructor includes an unused parameter lunch. It should be removed to clean up the method signature.
| public SchoolJpaEntity(String schoolName, Area area, Lunch lunch, LocalDate examDate, | |
| Long capacity, | |
| LocalDateTime deadlineTime, Integer lunchPrice, AddressJpaVO address) { | |
| LocalDateTime deadlineTime, Integer lunchPrice, AddressJpaVO address, | |
| List<LunchMenu> lunchMenu | |
| ) { | |
| public SchoolJpaEntity(String schoolName, Area area, LocalDate examDate, | |
| Long capacity, | |
| LocalDateTime deadlineTime, AddressJpaVO address, | |
| List<LunchMenu> lunchMenu | |
| ) { |
| @NotNull | ||
| Integer lunchPrice, | ||
| @Schema(description = "점심 메뉴 목록") | ||
| List<LunchMenu> lunchMenus, |
There was a problem hiding this comment.
| String area, | ||
| String lunch, | ||
| Integer lunchPrice, | ||
| List<LunchMenu> lunchMenus, |
| school.getArea().getAreaName(), | ||
| school.getLunch().getLunchName(), | ||
| school.getLunchPrice(), | ||
| school.getLunchMenus(), |
✨ 구현한 기능
📢 논의하고 싶은 내용
🎸 기타
Summary by CodeRabbit
New Features
Improvements
Other Changes