-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-94 feat: 학교 필드 추가 #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7fa95ed
4fe83bb
c5e37d4
1f9231f
6db4d09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,25 @@ | ||
| package life.mosu.mosuserver.domain.school; | ||
|
|
||
| import java.util.Arrays; | ||
| import life.mosu.mosuserver.global.exception.CustomRuntimeException; | ||
| import life.mosu.mosuserver.global.exception.ErrorCode; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum Area { | ||
| DAECHI("대치"), | ||
| MOKDONG("목동"), | ||
| NOWON("노원"); | ||
| private final String areaName; | ||
|
|
||
| Area(String areaName) { | ||
| private Area(String areaName) { | ||
| this.areaName = areaName; | ||
| } | ||
|
|
||
| public String getAreaName() { | ||
| return areaName; | ||
| 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)); | ||
| } | ||
|
Comment on lines
+19
to
24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a static 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;
} |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ | |
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import life.mosu.mosuserver.domain.application.Lunch; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
@@ -30,11 +32,20 @@ public class SchoolJpaEntity { | |
| @Column(name = "school_name") | ||
| private String schoolName; | ||
|
|
||
| @Embedded | ||
| private AddressJpaVO address; | ||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainAddress field not included in constructor. The 🏁 Script executed: #!/bin/bash
# Check if AddressJpaVO is used elsewhere in the codebase and how it's typically initialized
rg -A 5 "AddressJpaVO" --type javaLength 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.javaLength of output: 1865 Include The • File: Please update the constructor to include @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 |
||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private Area area; | ||
|
|
||
| @Embedded | ||
| private AddressJpaVO address; | ||
| @Enumerated(EnumType.STRING) | ||
| private Lunch lunch; | ||
|
|
||
| @Column(name = "lunch_price") | ||
| private Integer lunchPrice; | ||
|
|
||
| @Column(name = "deadline_time") | ||
| private LocalDateTime deadlineTime; | ||
|
|
||
| @Column(name = "exam_date") | ||
| private LocalDate examDate; | ||
|
|
@@ -43,12 +54,16 @@ public class SchoolJpaEntity { | |
| private Long capacity; | ||
|
|
||
| @Builder | ||
| public SchoolJpaEntity(String schoolName, Area area, AddressJpaVO address, LocalDate examDate, | ||
| Long capacity) { | ||
| 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.address = address; | ||
| this.lunch = lunch; | ||
| this.examDate = examDate; | ||
| this.capacity = capacity; | ||
| this.deadlineTime = deadlineTime; | ||
| this.lunchPrice = lunchPrice; | ||
| this.address = address; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,43 +5,59 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| import jakarta.validation.constraints.NotNull; | ||||||||||||||||||||||||||||||||||||||||||||||
| import jakarta.validation.constraints.Positive; | ||||||||||||||||||||||||||||||||||||||||||||||
| import java.time.LocalDate; | ||||||||||||||||||||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.school.AddressJpaVO; | ||||||||||||||||||||||||||||||||||||||||||||||
| import java.time.LocalDateTime; | ||||||||||||||||||||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.application.Lunch; | ||||||||||||||||||||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.school.Area; | ||||||||||||||||||||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.school.SchoolJpaEntity; | ||||||||||||||||||||||||||||||||||||||||||||||
| import life.mosu.mosuserver.presentation.application.dto.AddressRequest; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "학교 생성/등록 요청 DTO") | ||||||||||||||||||||||||||||||||||||||||||||||
| public record SchoolRegistrationRequest( | ||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "학교 이름", example = "모수고등학교") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotBlank(message = "학교 이름은 필수 입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| String schoolName, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "지역 (예: DAECHI, MOKDONG, NOWON)", example = "DAECHI") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull(message = "지역은 필수 입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| String area, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "학교 주소 정보") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull(message = "주소 정보는 필수 입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| AddressRequest address, | ||||||||||||||||||||||||||||||||||||||||||||||
| AddressRequest schoolAddress, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "시험/입학 시험 날짜 (YYYY-MM-DD)", example = "2025-11-20") | ||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "날짜 (YYYY-MM-DD)", example = "2025-11-20") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull(message = "시험 날짜는 필수입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| LocalDate examDate, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "학교명", example = "모수고등학교") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotBlank(message = "학교 이름은 필수 입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| String schoolName, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "도시락 메뉴") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull | ||||||||||||||||||||||||||||||||||||||||||||||
| String lunch, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "도시락 가격") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull | ||||||||||||||||||||||||||||||||||||||||||||||
| Integer lunchPrice, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull | ||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "신청 마감 일시", example = "2025-05-30T10:00:00") | ||||||||||||||||||||||||||||||||||||||||||||||
| LocalDateTime deadlineTime, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new fields Additionally,
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Schema(description = "수용 인원", example = "300") | ||||||||||||||||||||||||||||||||||||||||||||||
| @NotNull(message = "수용 인원은 필수입니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| @Positive(message = "수용 인원은 양수여야 합니다.") | ||||||||||||||||||||||||||||||||||||||||||||||
| Long capacity | ||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public SchoolJpaEntity toEntity() { | ||||||||||||||||||||||||||||||||||||||||||||||
| AddressJpaVO address = address().toValueObject(); | ||||||||||||||||||||||||||||||||||||||||||||||
| return SchoolJpaEntity.builder() | ||||||||||||||||||||||||||||||||||||||||||||||
| .schoolName(schoolName) | ||||||||||||||||||||||||||||||||||||||||||||||
| .area(Area.valueOf(area)) | ||||||||||||||||||||||||||||||||||||||||||||||
| .address(address) | ||||||||||||||||||||||||||||||||||||||||||||||
| .address(schoolAddress.toValueObject()) | ||||||||||||||||||||||||||||||||||||||||||||||
| .area(Area.from(area)) | ||||||||||||||||||||||||||||||||||||||||||||||
| .examDate(examDate) | ||||||||||||||||||||||||||||||||||||||||||||||
| .schoolName(schoolName) | ||||||||||||||||||||||||||||||||||||||||||||||
| .lunch(Lunch.from(lunch)) | ||||||||||||||||||||||||||||||||||||||||||||||
| .lunchPrice(lunchPrice) | ||||||||||||||||||||||||||||||||||||||||||||||
| .deadlineTime(deadlineTime) | ||||||||||||||||||||||||||||||||||||||||||||||
| .capacity(capacity) | ||||||||||||||||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved performance, use a static
Mapfor 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 staticMapprovides a constant time complexity O(1) lookup.