Skip to content

MOSU-94 feat: 학교 필드 추가#95

Merged
wlgns12370 merged 5 commits intodevelopfrom
feature/mosu-94
Jul 15, 2025
Merged

MOSU-94 feat: 학교 필드 추가#95
wlgns12370 merged 5 commits intodevelopfrom
feature/mosu-94

Conversation

@wlgns12370
Copy link
Contributor

@wlgns12370 wlgns12370 commented Jul 15, 2025

✨ 구현한 기능

  • 피그마와 다른 학교 등록에 도시락, 마감 기한 필드 추가

📢 논의하고 싶은 내용

  • x

🎸 기타

  • 학교 주소에 대한 필드를 받을지 말지에 대한 비즈니스적 결정이 나지 않아서 pr을 열어 두기만 하겠습니다.

Summary by CodeRabbit

  • New Features

    • Added support for specifying lunch options, lunch price, and deadline time during school registration.
    • Enhanced error handling with new messages for missing area or lunchbox information.
  • Improvements

    • Streamlined the school registration process by updating field names and order for clarity.
    • Improved conversion and validation of area and lunch information during registration.

@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

Walkthrough

This update introduces new static factory methods for enum lookup in Lunch and Area, adds lunch and deadline fields to the SchoolJpaEntity, and expands the SchoolRegistrationRequest to include lunch-related data. Error codes for missing enums are added, and field ordering and naming are adjusted for consistency.

Changes

File(s) Change Summary
.../domain/application/Lunch.java Added static method from(String lunchName) to map a string to a Lunch enum or throw a custom exception if not found.
.../domain/school/Area.java Added static method from(String areaName) for enum lookup; replaced explicit getter with Lombok @Getter.
.../domain/school/SchoolJpaEntity.java Added fields: Lunch lunch, Integer lunchPrice, LocalDateTime deadlineTime. Updated constructor accordingly.
.../global/exception/ErrorCode.java Added error codes: NOT_FOUND_AREA, NOT_FOUND_LUNCH for enum lookup failures.
.../presentation/school/dto/SchoolRegistrationRequest.java Added fields: lunch, lunchPrice, deadlineTime; renamed address to schoolAddress; updated entity conversion.

Sequence Diagram(s)

sequenceDiagram
    participant Controller
    participant SchoolRegistrationRequest
    participant Area
    participant Lunch
    participant SchoolJpaEntity

    Controller->>SchoolRegistrationRequest: Receive registration data
    SchoolRegistrationRequest->>Area: Area.from(area)
    SchoolRegistrationRequest->>Lunch: Lunch.from(lunch)
    SchoolRegistrationRequest->>SchoolJpaEntity: Build entity with lunch, lunchPrice, deadlineTime, etc.
Loading

Suggested labels

우선순위 중

Suggested reviewers

  • polyglot-k

Poem

In the fields where enums grow,
Lunch and Area now both know,
How to find themselves by name,
Or raise an error, just the same.
Schools get lunch and deadlines too,
Hopping forward, code anew! 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f9231f and 6db4d09.

📒 Files selected for processing (1)
  • src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @wlgns12370, 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 introduces new data fields for school registration, specifically for lunch details and application deadlines, and updates the corresponding API request DTO. It also enhances the robustness of enum conversions by adding utility methods and dedicated error handling. A notable aspect is the temporary omission of address field mapping, pending a business decision.

Highlights

  • New School Fields: I've added new fields to the SchoolJpaEntity to support lunch options, lunch price, and a deadline for school registration. This aligns with the requirement to capture more detailed information for school entries.
  • API Request Updates: The SchoolRegistrationRequest DTO has been updated to include the new lunch, lunchPrice, and deadlineTime fields. The toEntity() method now correctly maps these new fields to the SchoolJpaEntity.
  • Enum Utility Methods & Error Handling: I've introduced from() static methods to both Lunch and Area enums. These methods provide a safer way to convert string values to their corresponding enum types, throwing specific CustomRuntimeException errors (NOT_FOUND_LUNCH, NOT_FOUND_AREA) if an invalid string is provided. Corresponding error codes have been added to ErrorCode.java.
  • Address Field Handling: The SchoolRegistrationRequest no longer directly maps the schoolAddress field to the SchoolJpaEntity builder. This change reflects the ongoing business decision regarding the handling of school address information, as noted in the PR description.
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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds new fields for lunch options and deadlines to the school registration process. I've identified a few critical issues where the school's address, though provided in the request, is not being saved. I've also suggested some improvements for validation messages and code efficiency in enum lookups. Addressing these points will significantly improve the robustness and quality of the code.

Comment on lines 57 to 67
public SchoolJpaEntity(String schoolName, Area area, Lunch lunch, LocalDate examDate,
Long capacity,
LocalDateTime deadlineTime, Integer lunchPrice) {
this.schoolName = schoolName;
this.area = area;
this.address = address;
this.lunch = lunch;
this.examDate = examDate;
this.capacity = capacity;
this.deadlineTime = deadlineTime;
this.lunchPrice = lunchPrice;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The address field is declared in the entity but it's no longer being initialized in the constructor. This will result in the address information being lost when a new SchoolJpaEntity is created, even if it's provided in the request.

public SchoolJpaEntity(String schoolName, Area area, Lunch lunch, LocalDate examDate,
    Long capacity,
    LocalDateTime deadlineTime, Integer lunchPrice, AddressJpaVO address) {
    this.schoolName = schoolName;
    this.area = area;
    this.lunch = lunch;
    this.examDate = examDate;
    this.capacity = capacity;
    this.deadlineTime = deadlineTime;
    this.lunchPrice = lunchPrice;
    this.address = address;
}

Comment on lines 53 to 61
return SchoolJpaEntity.builder()
.schoolName(schoolName)
.area(Area.valueOf(area))
.address(address)
.area(Area.from(area))
.examDate(examDate)
.schoolName(schoolName)
.lunch(Lunch.from(lunch))
.lunchPrice(lunchPrice)
.deadlineTime(deadlineTime)
.capacity(capacity)
.build();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The schoolAddress field is a required part of the request DTO, but it is not being used within the toEntity() method. This means the address information will be discarded and not persisted to the database.

You need to convert schoolAddress to AddressJpaVO and set it on the SchoolJpaEntity using the builder.

return SchoolJpaEntity.builder()
    .area(Area.from(area))
    .address(schoolAddress.toValueObject())
    .examDate(examDate)
    .schoolName(schoolName)
    .lunch(Lunch.from(lunch))
    .lunchPrice(lunchPrice)
    .deadlineTime(deadlineTime)
    .capacity(capacity)
    .build()

Comment on lines +22 to +29
public static Lunch from(String lunchName) {
return Arrays.stream(values())
.filter(e -> e.getLunchName().equals(lunchName))
.findFirst()
.orElseThrow(
() -> new CustomRuntimeException(ErrorCode.NOT_FOUND_LUNCH)
);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved performance, use a static Map for looking up enum values from a string. The current implementation iterates through all enum values for every call, which has a time complexity of O(n). Using a pre-populated static Map provides a constant time complexity O(1) lookup.

private static final java.util.Map<String, Lunch> LUNCH_BY_NAME =
    java.util.Arrays.stream(values()).collect(
        java.util.stream.Collectors.toUnmodifiableMap(Lunch::getLunchName, e -> e));

public static Lunch from(String lunchName) {
    Lunch lunch = LUNCH_BY_NAME.get(lunchName);
    if (lunch == null) {
        throw new CustomRuntimeException(ErrorCode.NOT_FOUND_LUNCH);
    }
    return lunch;
}

Comment on lines +19 to 24
public static Area from(String areaName) {
return Arrays.stream(Area.values())
.filter(area -> area.getAreaName().equals(areaName))
.findFirst()
.orElseThrow(() -> new CustomRuntimeException(ErrorCode.NOT_FOUND_AREA));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a static Map for lookups in the from method would be more efficient. While the performance impact is negligible with only three enum constants, it's a good practice for consistency and scalability.

private static final java.util.Map<String, Area> AREA_BY_NAME =
    java.util.Arrays.stream(values()).collect(
        java.util.stream.Collectors.toUnmodifiableMap(Area::getAreaName, e -> e));

public static Area from(String areaName) {
    Area area = AREA_BY_NAME.get(areaName);
    if (area == null) {
        throw new CustomRuntimeException(ErrorCode.NOT_FOUND_AREA);
    }
    return area;
}

Comment on lines +34 to +44
@Schema(description = "도시락 메뉴")
@NotNull
String lunch,

@Schema(description = "도시락 가격")
@NotNull
Integer lunchPrice,

@NotNull
@Schema(description = "신청 마감 일시", example = "2025-05-30T10:00:00")
LocalDateTime deadlineTime,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new fields lunch, lunchPrice, and deadlineTime are annotated with @NotNull, but they are missing the message attribute. Providing a descriptive error message is important for client-side error handling and provides a better user experience.

Additionally, lunchPrice should probably be a positive number. Consider adding a @Positive annotation.

Suggested change
@Schema(description = "도시락 메뉴")
@NotNull
String lunch,
@Schema(description = "도시락 가격")
@NotNull
Integer lunchPrice,
@NotNull
@Schema(description = "신청 마감 일시", example = "2025-05-30T10:00:00")
LocalDateTime deadlineTime,
@NotNull(message = "도시락 메뉴는 필수입니다.")
String lunch,
@Schema(description = "도시락 가격")
@NotNull(message = "도시락 가격은 필수입니다.")
@Positive(message = "도시락 가격은 양수여야 합니다.")
Integer lunchPrice,
@NotNull(message = "신청 마감 일시는 필수입니다.")
@Schema(description = "신청 마감 일시", example = "2025-05-30T10:00:00")
LocalDateTime deadlineTime,

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/life/mosu/mosuserver/domain/school/Area.java (1)

15-17: Redundant explicit private constructor.

Enum constructors are implicitly private, making the explicit private modifier redundant. Consider removing it for cleaner code.

-    private Area(String areaName) {
+    Area(String areaName) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bbd947 and c5e37d4.

📒 Files selected for processing (5)
  • src/main/java/life/mosu/mosuserver/domain/application/Lunch.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/school/Area.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/global/exception/ErrorCode.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java (1 hunks)
🔇 Additional comments (9)
src/main/java/life/mosu/mosuserver/domain/application/Lunch.java (1)

22-29: Well-implemented enum factory method.

The static factory method follows good practices with proper error handling and clear exception messaging. The implementation is consistent with the Area enum's similar method.

src/main/java/life/mosu/mosuserver/global/exception/ErrorCode.java (1)

66-68: Appropriate error codes added.

The new enum-related error codes are well-categorized and use appropriate HTTP status codes. The Korean error messages are consistent with the existing codebase style.

src/main/java/life/mosu/mosuserver/domain/school/Area.java (1)

19-24: Consistent enum factory method implementation.

The static factory method implementation is consistent with the Lunch enum and follows good practices with proper error handling.

src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java (2)

41-48: New lunch and deadline fields properly implemented.

The new fields are correctly annotated with appropriate JPA annotations (@Enumerated for the enum, @column for the others). The field types and naming are consistent with the domain model.


57-67: Constructor updated with new fields.

The constructor correctly includes the new lunch, lunchPrice, and deadlineTime fields. The field assignments are properly implemented.

src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java (4)

34-44: New lunch and deadline fields properly validated.

The new fields have appropriate validation annotations (@NotNull, @notblank) and clear schema descriptions. The field types are consistent with the entity model.


54-60: Proper use of enum factory methods.

The toEntity() method correctly uses the new Area.from() and Lunch.from() methods, which provide better error handling than the previous valueOf() approach.


16-49: Ignore field reordering – no explicit serialization order detected

I couldn’t find any @JsonPropertyOrder annotations or Jackson configuration that enforces declaration-order serialization for SchoolRegistrationRequest. Jackson falls back to alphabetical ordering by default, so moving schoolName after examDate will not affect JSON output.

Likely an incorrect or invalid review comment.


52-62: Confirm Address Mapping Intent

The SchoolJpaEntity still declares a private AddressJpaVO address (line 36) but its constructor and Lombok-generated builder no longer accept or set this field—so toEntity() can’t map the address and it’ll remain null. Please verify whether this omission is intentional or if address assignment needs to be reintroduced (e.g., add a builder setter or handle it separately in the service layer).

• Domain entity:
– File: src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java
– Line 36: private AddressJpaVO address;
– Constructor signature at lines 57–63 has no address parameter and no address(...) builder method.
• DTO mapping:
– File: src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java
– Lines 52–62: toEntity() omits any address conversion.

Please confirm and, if needed, restore address mapping or adjust the design accordingly.

Comment on lines +35 to +36
@Embedded
private AddressJpaVO address;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Address field not included in constructor.

The address field is still present in the entity but removed from the constructor parameters. This could lead to entities being created with null addresses. Verify if this is intentional or if the address should be included in the constructor.


🏁 Script executed:

#!/bin/bash
# Check if AddressJpaVO is used elsewhere in the codebase and how it's typically initialized
rg -A 5 "AddressJpaVO" --type java

Length of output: 10540


🏁 Script executed:

#!/bin/bash
# Display class declaration, annotations, constructor, and builder for SchoolJpaEntity
sed -n '1,200p' src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java

Length of output: 1865


Include address in the SchoolJpaEntity @builder constructor

The address field is declared but omitted from the builder constructor, which prevents calls like SchoolJpaEntity.builder().address(...) (used in DatabaseInitializer) and leaves address uninitialized.

• File: src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java
– The @Builder constructor (around line Thirty-nine) only takes (String schoolName, Area area, Lunch lunch, LocalDate examDate, Long capacity, LocalDateTime deadlineTime, Integer lunchPrice).

Please update the constructor to include AddressJpaVO address and assign it:

 @Builder
-public SchoolJpaEntity(String schoolName,
-        Area area,
-        Lunch lunch,
-        LocalDate examDate,
-        Long capacity,
-        LocalDateTime deadlineTime,
-        Integer lunchPrice) {
-    this.schoolName = schoolName;
-    this.area = area;
-    this.lunch = lunch;
-    this.examDate = examDate;
-    this.capacity = capacity;
-    this.deadlineTime = deadlineTime;
-    this.lunchPrice = lunchPrice;
-}
+public SchoolJpaEntity(String schoolName,
+        AddressJpaVO address,
+        Area area,
+        Lunch lunch,
+        LocalDate examDate,
+        Long capacity,
+        LocalDateTime deadlineTime,
+        Integer lunchPrice) {
+    this.schoolName = schoolName;
+    this.address = address;
+    this.area = area;
+    this.lunch = lunch;
+    this.examDate = examDate;
+    this.capacity = capacity;
+    this.deadlineTime = deadlineTime;
+    this.lunchPrice = lunchPrice;
+}
🤖 Prompt for AI Agents
In src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java around
lines 35 to 39, the address field is declared but missing from the @Builder
constructor parameters and assignment. Update the @Builder constructor to
include AddressJpaVO address as a parameter and assign it to this.address to
enable builder calls like SchoolJpaEntity.builder().address(...).

coderabbitai bot added a commit that referenced this pull request Jul 15, 2025
Docstrings generation was requested by @toothlessdev.

* #95 (comment)

The following files were modified:

* `src/main/java/life/mosu/mosuserver/domain/application/Lunch.java`
* `src/main/java/life/mosu/mosuserver/domain/school/Area.java`
* `src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaEntity.java`
* `src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolRegistrationRequest.java`
@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

Note

Generated docstrings for this pull request at #100

@wlgns12370 wlgns12370 changed the title MOSU-94 feat: 학교 필드 추가 (pr 닫지마세요) MOSU-94 feat: 학교 필드 추가 Jul 15, 2025
@wlgns12370 wlgns12370 merged commit 12871d5 into develop Jul 15, 2025
2 checks passed
@wlgns12370 wlgns12370 deleted the feature/mosu-94 branch July 15, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant