From e7b1457b3f0ccb947ccb6ee1d7adef8334a6a0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 20 Nov 2024 18:57:51 +0900 Subject: [PATCH 01/20] =?UTF-8?q?chore:=20classPlace=20=ED=81=AC=EA=B8=B0?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/domain/timetableV2/model/TimetableLecture.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java b/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java index 0fc1571bd..f9d498e4d 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java @@ -42,8 +42,8 @@ public class TimetableLecture extends BaseEntity { @Column(name = "class_time", columnDefinition = "TEXT") private String classTime; - @Size(max = 30) - @Column(name = "class_place", length = 30) + @Size(max = 255) + @Column(name = "class_place", length = 255) private String classPlace; @Size(max = 30) From 2d16d9dba113586709ef05f32f2146475787ae87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Thu, 21 Nov 2024 12:57:11 +0900 Subject: [PATCH 02/20] =?UTF-8?q?chore:=20=EA=B0=95=EC=9D=98=20=EC=9E=A5?= =?UTF-8?q?=EC=86=8C=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/TimetableLectureCreateRequest.java | 14 ++++++++++---- .../dto/TimetableLectureUpdateRequest.java | 4 +--- .../timetableV2/service/TimetableServiceV2.java | 9 ++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureCreateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureCreateRequest.java index 644c4c97c..55c7a2e24 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureCreateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureCreateRequest.java @@ -36,8 +36,7 @@ public record InnerTimeTableLectureRequest( List classTime, @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) - @Size(max = 30, message = "강의 장소의 최대 글자는 30글자입니다.") - String classPlace, + List classPlace, @Schema(description = "교수명", example = "null", requiredMode = NOT_REQUIRED) @Size(max = 30, message = "교수 명의 최대 글자는 30글자입니다.") @@ -64,7 +63,7 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame) { return new TimetableLecture( classTitle, getClassTimeToString(), - classPlace, + getClassPlaceToString(classPlace.toString()), professor, grades, memo, @@ -78,7 +77,7 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame, Lectur return new TimetableLecture( classTitle, getClassTimeToString(), - classPlace, + getClassPlaceToString(classPlace.toString()), professor, grades, memo, @@ -94,5 +93,12 @@ private String getClassTimeToString() { } return null; } + + private String getClassPlaceToString(String classPlace) { + if (classPlace != null) { + return classPlace.substring(1, classPlace.length() - 1); + } + return null; + } } } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureUpdateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureUpdateRequest.java index 93ee27df5..37bbaa5d5 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureUpdateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/TimetableLectureUpdateRequest.java @@ -37,12 +37,10 @@ public record InnerTimetableLectureRequest( String classTitle, @Schema(description = "강의 시간", example = "[210, 211]", requiredMode = NOT_REQUIRED) - @Size(max = 100, message = "강의 시간의 최대 글자는 100글자입니다.") List classTime, @Schema(description = "강의 장소", example = "null", requiredMode = NOT_REQUIRED) - @Size(max = 30, message = "강의 장소의 최대 글자는 30글자입니다.") - String classPlace, + List classPlace, @Schema(description = "강의 교수", example = "이돈우", requiredMode = NOT_REQUIRED) @Size(max = 30, message = "교수 명의 최대 글자는 30글자입니다.") diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java index 04980e740..10381d344 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java @@ -128,7 +128,7 @@ public TimetableLectureResponse updateTimetablesLectures(Integer userId, Timetab timetableLecture.update( timetableRequest.classTitle(), timetableRequest.classTime().toString(), - timetableRequest.classPlace(), + getClassPlaceToString(timetableRequest.classPlace().toString()), timetableRequest.professor(), timetableRequest.grades(), timetableRequest.memo()); @@ -137,6 +137,13 @@ public TimetableLectureResponse updateTimetablesLectures(Integer userId, Timetab return getTimetableLectureResponse(userId, timetableFrame, timetableLectures); } + private String getClassPlaceToString(String classPlace) { + if (classPlace != null) { + return classPlace.substring(1, classPlace.length() - 1); + } + return null; + } + @Transactional public TimetableLectureResponse getTimetableLectures(Integer userId, Integer timetableFrameId) { TimetableFrame frame = timetableFrameRepositoryV2.getById(timetableFrameId); From 74669cca2e1a65231ce280d12251246f0d4fee3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Thu, 21 Nov 2024 12:59:25 +0900 Subject: [PATCH 03/20] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../in/koreatech/koin/acceptance/TimetableV2ApiTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/in/koreatech/koin/acceptance/TimetableV2ApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TimetableV2ApiTest.java index 2b041c2c7..cb2bf2490 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TimetableV2ApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TimetableV2ApiTest.java @@ -275,7 +275,7 @@ void setup() { { "class_title": "커스텀생성1", "class_time" : [200, 201], - "class_place" : "한기대", + "class_place" : ["한기대"], "professor" : "서정빈", "grades": "2", "memo" : "메모" @@ -283,7 +283,7 @@ void setup() { { "class_title": "커스텀생성2", "class_time" : [202, 203], - "class_place" : "참빛관 편의점", + "class_place" : ["참빛관 편의점"], "professor" : "감사 서정빈", "grades": "1", "memo" : "메모" @@ -356,7 +356,7 @@ void setup() { "id": 1, "class_title": "커스텀바꿔요1", "class_time" : [200, 201], - "class_place" : "한기대", + "class_place" : ["한기대"], "professor" : "서정빈", "grades" : "0", "memo" : "메모한당 히히" @@ -365,7 +365,7 @@ void setup() { "id": 2, "class_title": "커스텀바꿔요2", "class_time" : [202, 203], - "class_place" : "참빛관 편의점", + "class_place" : ["참빛관 편의점"], "professor" : "알바 서정빈", "grades" : "0", "memo" : "메모한당 히히" From 4c2fd66313c70038ce295f33092a33a11599868e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 00:37:03 +0900 Subject: [PATCH 04/20] =?UTF-8?q?chore:=20=EC=B6=A9=EB=8F=8C=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/domain/timetableV2/service/TimetableServiceV2.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java index 10381d344..a6ef8d2dc 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java @@ -224,6 +224,7 @@ public void deleteTimetableLectureByFrameId(Integer frameId, Integer lectureId, if (!Objects.equals(timetableFrame.getUser().getId(), userId)) { throw AuthorizationException.withDetail("userId: " + userId); } + timetableLectureRepositoryV2.deleteByFrameIdAndLectureId(frameId, lectureId); } } From 7929480f82c153abead326512546e21fe8f35263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 00:54:30 +0900 Subject: [PATCH 05/20] =?UTF-8?q?fix:=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetableV2/factory/TimetableLectureUpdater.java | 9 ++++++++- .../domain/timetableV2/service/TimetableServiceV2.java | 0 2 files changed, 8 insertions(+), 1 deletion(-) delete mode 100644 src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java index 2f5aabb3d..6918821b4 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java @@ -21,11 +21,18 @@ public void updateTimetablesLectures(TimetableLectureUpdateRequest request) { timetableLecture.update( timetableRequest.classTitle(), timetableRequest.classTime().toString(), - timetableRequest.classPlace(), + getClassPlaceToString(timetableRequest.classPlace().toString()), timetableRequest.professor(), timetableRequest.grades(), timetableRequest.memo() ); } } + + private String getClassPlaceToString(String classPlace) { + if (classPlace != null) { + return classPlace.substring(1, classPlace.length() - 1); + } + return null; + } } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableServiceV2.java deleted file mode 100644 index e69de29bb..000000000 From ee079da807322853feb9148e85e51939fc08f0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 11:39:27 +0900 Subject: [PATCH 06/20] =?UTF-8?q?fix:=20timetableLecture=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EC=88=98=EC=A0=95=20dto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimetableLectureCreateRequest.java | 42 +++++++++++++------ .../TimetableLectureUpdateRequest.java | 18 +++++--- .../factory/TimetableLectureUpdater.java | 28 ++++++++++--- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java index 92a6f09f6..eee653129 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java @@ -2,8 +2,11 @@ import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; +import static java.util.stream.Stream.concat; +import static java.util.stream.Stream.of; import java.util.List; +import java.util.stream.Collectors; import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -32,11 +35,9 @@ public record InnerTimeTableLectureRequest( @Size(max = 100, message = "강의 이름의 최대 글자는 100글자입니다.") String classTitle, - @Schema(description = "강의 시간", example = "null", requiredMode = NOT_REQUIRED) - List classTime, - - @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) - List classPlace, + @Valid + @Schema(description = "강의 정보", requiredMode = NOT_REQUIRED) + List classInfos, @Schema(description = "교수명", example = "null", requiredMode = NOT_REQUIRED) @Size(max = 30, message = "교수 명의 최대 글자는 30글자입니다.") @@ -53,6 +54,18 @@ public record InnerTimeTableLectureRequest( @Schema(description = "강의 고유 번호", example = "14", requiredMode = NOT_REQUIRED) Integer lectureId ) { + @JsonNaming(value = SnakeCaseStrategy.class) + public record ClassInfo( + @Schema(description = "강의 시간", example = "null", requiredMode = NOT_REQUIRED) + List classTime, + + @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) + @Size(max = 255, message = "강의 장소의 최대 글자는 255글자입니다.") + String classPlace + ) { + + } + public InnerTimeTableLectureRequest { if (grades == null) { grades = "0"; @@ -63,7 +76,7 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame) { return new TimetableLecture( classTitle, getClassTimeToString(), - getClassPlaceToString(classPlace.toString()), + getClassPlaceToString(), professor, grades, memo, @@ -77,7 +90,7 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame, Lectur return new TimetableLecture( classTitle, getClassTimeToString(), - getClassPlaceToString(classPlace.toString()), + getClassPlaceToString(), professor, grades, memo, @@ -88,15 +101,20 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame, Lectur } private String getClassTimeToString() { - if (classTime != null) { - return classTime.toString(); + if (classInfos != null) { + List classTimes = classInfos.stream() + .flatMap(c -> concat(c.classTime().stream(), of(-1))) + .toList(); + return classTimes.toString(); } return null; } - private String getClassPlaceToString(String classPlace) { - if (classPlace != null) { - return classPlace.substring(1, classPlace.length() - 1); + private String getClassPlaceToString() { + if (classInfos != null) { + return classInfos.stream() + .map(c -> c.classPlace) + .collect(Collectors.joining(", ")); } return null; } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java index c3b1d824b..80defbd59 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java @@ -36,11 +36,9 @@ public record InnerTimetableLectureRequest( @Size(max = 100, message = "강의 이름의 최대 글자는 100글자입니다.") String classTitle, - @Schema(description = "강의 시간", example = "[210, 211]", requiredMode = NOT_REQUIRED) - List classTime, - - @Schema(description = "강의 장소", example = "null", requiredMode = NOT_REQUIRED) - List classPlace, + @Valid + @Schema(description = "강의 정보", requiredMode = NOT_REQUIRED) + List classInfos, @Schema(description = "강의 교수", example = "이돈우", requiredMode = NOT_REQUIRED) @Size(max = 30, message = "교수 명의 최대 글자는 30글자입니다.") @@ -54,6 +52,16 @@ public record InnerTimetableLectureRequest( @Size(max = 200, message = "메모는 200자 이하로 입력해주세요.") String memo ) { + @JsonNaming(value = SnakeCaseStrategy.class) + public record ClassInfo( + @Schema(description = "강의 시간", example = "null", requiredMode = NOT_REQUIRED) + List classTime, + + @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) + @Size(max = 255, message = "강의 장소의 최대 글자는 255글자입니다.") + String classPlace + ) { + } } } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java index 6918821b4..8cc71bdd3 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java @@ -1,6 +1,12 @@ package in.koreatech.koin.domain.timetableV2.factory; import static in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureUpdateRequest.InnerTimetableLectureRequest; +import static in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureUpdateRequest.InnerTimetableLectureRequest.ClassInfo; +import static java.util.stream.Stream.concat; +import static java.util.stream.Stream.of; + +import java.util.List; +import java.util.stream.Collectors; import org.springframework.stereotype.Component; @@ -20,8 +26,8 @@ public void updateTimetablesLectures(TimetableLectureUpdateRequest request) { TimetableLecture timetableLecture = timetableLectureRepositoryV2.getById(timetableRequest.id()); timetableLecture.update( timetableRequest.classTitle(), - timetableRequest.classTime().toString(), - getClassPlaceToString(timetableRequest.classPlace().toString()), + getClassTimeToString(timetableRequest.classInfos()), + getClassPlaceToString(timetableRequest.classInfos()), timetableRequest.professor(), timetableRequest.grades(), timetableRequest.memo() @@ -29,9 +35,21 @@ public void updateTimetablesLectures(TimetableLectureUpdateRequest request) { } } - private String getClassPlaceToString(String classPlace) { - if (classPlace != null) { - return classPlace.substring(1, classPlace.length() - 1); + private String getClassTimeToString(List classInfos) { + if (classInfos != null) { + List classTimes = classInfos.stream() + .flatMap(c -> concat(c.classTime().stream(), of(-1))) + .toList(); + return classTimes.toString(); + } + return null; + } + + private String getClassPlaceToString(List classInfos) { + if (classInfos != null) { + return classInfos.stream() + .map(ClassInfo::classPlace) + .collect(Collectors.joining(", ")); } return null; } From a3913254635be5473fb40cf500e12c17c5ca9ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 11:48:24 +0900 Subject: [PATCH 07/20] =?UTF-8?q?fix:=20class=5Fplace=20=EC=9E=90=EB=A3=8C?= =?UTF-8?q?=ED=98=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/domain/timetableV2/model/TimetableLecture.java | 4 ++-- .../V103__alter_timetable_lecture_class_place_column.sql | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/db/migration/V103__alter_timetable_lecture_class_place_column.sql diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java b/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java index 332ee2f6f..69ecc8a83 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/model/TimetableLecture.java @@ -42,8 +42,8 @@ public class TimetableLecture extends BaseEntity { @Column(name = "class_time", columnDefinition = "TEXT") private String classTime; - @Size(max = 255) - @Column(name = "class_place", length = 255) + @Lob + @Column(name = "class_place", columnDefinition = "TEXT") private String classPlace; @Size(max = 30) diff --git a/src/main/resources/db/migration/V103__alter_timetable_lecture_class_place_column.sql b/src/main/resources/db/migration/V103__alter_timetable_lecture_class_place_column.sql new file mode 100644 index 000000000..176ae8a36 --- /dev/null +++ b/src/main/resources/db/migration/V103__alter_timetable_lecture_class_place_column.sql @@ -0,0 +1,2 @@ +ALTER TABLE timetable_lecture + MODIFY COLUMN class_place TEXT; From 9c4b6694ac9337a41282c5a621215788b42f6f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 11:53:26 +0900 Subject: [PATCH 08/20] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acceptance/TimetableLectureApiTest.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java index f6e078961..4ba477e8a 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java @@ -67,16 +67,24 @@ void setup() { "timetable_lecture": [ { "class_title": "커스텀생성1", - "class_time" : [200, 201], - "class_place" : ["한기대"], + "class_infos": [ + { + "class_time" : [200, 201], + "class_place" : "한기대" + } + ] "professor" : "서정빈", "grades": "2", "memo" : "메모" }, { "class_title": "커스텀생성2", - "class_time" : [202, 203], - "class_place" : ["참빛관 편의점"], + "class_infos": [ + { + "class_time" : [202, 203], + "class_place" : "참빛관 편의점" + } + ], "professor" : "감사 서정빈", "grades": "1", "memo" : "메모" @@ -144,8 +152,12 @@ void setup() { { "id": 1, "class_title": "커스텀바꿔요1", - "class_time" : [200, 201], - "class_place" : ["한기대"], + "class_infos": [ + { + "class_time" : [200, 201], + "class_place" : "한기대" + } + ], "professor" : "서정빈", "grades" : "0", "memo" : "메모한당 히히" @@ -153,8 +165,12 @@ void setup() { { "id": 2, "class_title": "커스텀바꿔요2", - "class_time" : [202, 203], - "class_place" : ["참빛관 편의점"], + "class_infos": [ + { + "class_time" : [202, 203], + "class_place" : "참빛관 편의점" + } + ], "professor" : "알바 서정빈", "grades" : "0", "memo" : "메모한당 히히" From b1dacf94ddda9c13794ab86a7f44c99fe8747f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 12:21:28 +0900 Subject: [PATCH 09/20] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/acceptance/TimetableLectureApiTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java index 4ba477e8a..3feb9578c 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java @@ -72,7 +72,7 @@ void setup() { "class_time" : [200, 201], "class_place" : "한기대" } - ] + ], "professor" : "서정빈", "grades": "2", "memo" : "메모" @@ -105,7 +105,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201], + "class_time": [200, 201, -1], "class_place": "한기대", "memo": "메모", "grades": "2", @@ -121,7 +121,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203], + "class_time": [202, 203, -1], "class_place": "참빛관 편의점", "memo": "메모", "grades": "1", @@ -191,7 +191,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201], + "class_time": [200, 201, -1], "class_place": "한기대", "memo": "메모한당 히히", "grades": "0", @@ -207,7 +207,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203], + "class_time": [202, 203, -1], "class_place": "참빛관 편의점", "memo": "메모한당 히히", "grades": "0", From 8023610048b58bc50f17a4fa7f546f6199280e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 12:32:12 +0900 Subject: [PATCH 10/20] =?UTF-8?q?chore:=20classPlace=20=ED=81=AC=EA=B8=B0?= =?UTF-8?q?=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetableV2/dto/request/TimetableLectureCreateRequest.java | 2 +- .../timetableV2/dto/request/TimetableLectureUpdateRequest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java index eee653129..e30a0a499 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java @@ -60,7 +60,7 @@ public record ClassInfo( List classTime, @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) - @Size(max = 255, message = "강의 장소의 최대 글자는 255글자입니다.") + @Size(max = 30, message = "강의 장소의 최대 글자는 30글자입니다.") String classPlace ) { diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java index 80defbd59..01f2deec0 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureUpdateRequest.java @@ -58,7 +58,7 @@ public record ClassInfo( List classTime, @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) - @Size(max = 255, message = "강의 장소의 최대 글자는 255글자입니다.") + @Size(max = 30, message = "강의 장소의 최대 글자는 30글자입니다.") String classPlace ) { From 9997f7586425b67a37ddbd74ef777bbb8bcd0b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 12:41:35 +0900 Subject: [PATCH 11/20] =?UTF-8?q?chore:=20class=5Ftime=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/TimetableLectureCreateRequest.java | 9 ++++++--- .../timetableV2/factory/TimetableLectureUpdater.java | 9 ++++++--- .../koin/acceptance/TimetableLectureApiTest.java | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java index e30a0a499..f3ffb86df 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java @@ -5,6 +5,7 @@ import static java.util.stream.Stream.concat; import static java.util.stream.Stream.of; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -102,9 +103,11 @@ public TimetableLecture toTimetableLecture(TimetableFrame timetableFrame, Lectur private String getClassTimeToString() { if (classInfos != null) { - List classTimes = classInfos.stream() - .flatMap(c -> concat(c.classTime().stream(), of(-1))) - .toList(); + List classTimes = new ArrayList<>(); + for (int i = 0; i < classInfos.size(); i++) { + if (i > 0) classTimes.add(-1); + classTimes.addAll(classInfos.get(i).classTime); + } return classTimes.toString(); } return null; diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java index 8cc71bdd3..acfc985fc 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/factory/TimetableLectureUpdater.java @@ -5,6 +5,7 @@ import static java.util.stream.Stream.concat; import static java.util.stream.Stream.of; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -37,9 +38,11 @@ public void updateTimetablesLectures(TimetableLectureUpdateRequest request) { private String getClassTimeToString(List classInfos) { if (classInfos != null) { - List classTimes = classInfos.stream() - .flatMap(c -> concat(c.classTime().stream(), of(-1))) - .toList(); + List classTimes = new ArrayList<>(); + for (int i = 0; i < classInfos.size(); i++) { + if (i > 0) classTimes.add(-1); + classTimes.addAll(classInfos.get(i).classTime()); + } return classTimes.toString(); } return null; diff --git a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java index 3feb9578c..dc4dfc2e9 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java @@ -105,7 +105,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201, -1], + "class_time": [200, 201], "class_place": "한기대", "memo": "메모", "grades": "2", @@ -121,7 +121,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203, -1], + "class_time": [202, 203], "class_place": "참빛관 편의점", "memo": "메모", "grades": "1", @@ -191,7 +191,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201, -1], + "class_time": [200, 201], "class_place": "한기대", "memo": "메모한당 히히", "grades": "0", @@ -207,7 +207,7 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203, -1], + "class_time": [202, 203], "class_place": "참빛관 편의점", "memo": "메모한당 히히", "grades": "0", From fa73f50613abc491bd6aa3ba8a34a8e13993ace5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 13:31:01 +0900 Subject: [PATCH 12/20] =?UTF-8?q?chore:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20im?= =?UTF-8?q?port=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetableV2/dto/request/TimetableLectureCreateRequest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java index f3ffb86df..194d29379 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/request/TimetableLectureCreateRequest.java @@ -2,8 +2,6 @@ import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static java.util.stream.Stream.concat; -import static java.util.stream.Stream.of; import java.util.ArrayList; import java.util.List; From c3caa7951329f1c3da03b83fc634c063c2dca169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 14:10:16 +0900 Subject: [PATCH 13/20] =?UTF-8?q?fix:=20NPE=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetableV2/dto/response/TimetableLectureResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index 8621f4ce4..54262fc99 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -165,8 +165,9 @@ public static TimetableLectureResponse of(TimetableFrame timetableFrame, Integer } private static List parseClassTimes(String classTime) { - String classTimeWithoutBrackets = classTime.substring(INITIAL_BRACE_INDEX, classTime.length() - 1); + if (classTime == null) return null; + String classTimeWithoutBrackets = classTime.substring(INITIAL_BRACE_INDEX, classTime.length() - 1); return Arrays.stream(classTimeWithoutBrackets.split(SEPARATOR)) .map(String::strip) .map(Integer::parseInt) From bb0bc4aa252e5c9fc4277f45e204c699cced55cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 15:35:04 +0900 Subject: [PATCH 14/20] =?UTF-8?q?chore:=20=EC=99=9C=20=EC=9D=B4=EA=B1=B0?= =?UTF-8?q?=20=EB=B9=A0=EC=A0=B8=EC=9E=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/domain/timetableV2/controller/TimetableApiV2.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/controller/TimetableApiV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/controller/TimetableApiV2.java index 6ee1063c9..99e63a9af 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/controller/TimetableApiV2.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/controller/TimetableApiV2.java @@ -121,7 +121,11 @@ ResponseEntity deleteAllTimetablesFrame( @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(hidden = true))) } ) - @Operation(summary = "시간표에 강의 정보 추가") + @Operation(summary = "시간표에 강의 정보 추가", + description = """ + lecture_id가 있는 경우 class_title, class_time, professor은 null, grades는 '0'으로 입력해야합니다.\n + lecture_id가 없는 경우 class_title, class_time, professor, grades을 선택적으로 입력합니다. + """) @SecurityRequirement(name = "Jwt Authentication") @PostMapping("/v2/timetables/lecture") ResponseEntity createTimetableLecture( From 2afb11ab7c6c4038f9ceaa90b370bd31bf32a756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Tue, 26 Nov 2024 18:53:11 +0900 Subject: [PATCH 15/20] =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EC=BB=A4=EB=B0=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/TimetableLectureResponse.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index 54262fc99..b4f5e714b 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -15,6 +15,7 @@ import in.koreatech.koin.domain.timetableV2.model.TimetableFrame; import in.koreatech.koin.domain.timetableV2.model.TimetableLecture; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Size; @JsonNaming(value = SnakeCaseStrategy.class) public record TimetableLectureResponse( @@ -47,11 +48,8 @@ public record InnerTimetableLectureResponse( @Schema(description = "설계 학점", example = "0", requiredMode = NOT_REQUIRED) String designScore, - @Schema(description = "강의(커스텀) 시간", example = "[204, 205, 206, 207, 302, 303]", requiredMode = REQUIRED) - List classTime, - - @Schema(description = "강의 장소", example = "2공학관", requiredMode = NOT_REQUIRED) - String classPlace, + @Schema(description = "강의 정보", requiredMode = NOT_REQUIRED) + List classInfos, @Schema(description = "메모", example = "null", requiredMode = NOT_REQUIRED) String memo, @@ -74,6 +72,18 @@ public record InnerTimetableLectureResponse( @Schema(description = "학부", example = "디자인ㆍ건축공학부", requiredMode = NOT_REQUIRED) String department ) { + @JsonNaming(value = SnakeCaseStrategy.class) + public record ClassInfo( + @Schema(description = "강의 시간", example = "null", requiredMode = NOT_REQUIRED) + List classTime, + + @Schema(description = "강의 장소", example = "도서관", requiredMode = NOT_REQUIRED) + String classPlace + ) { + public static List of(String classTime, String classPlace) { + String[] classPlaceSegment = classPlace.split(","); + } + } public static List from(List timetableLectures) { List timetableLectureList = new ArrayList<>(); @@ -89,8 +99,7 @@ public static List from(List ti null, null, null, - parseClassTimes(timetableLecture.getClassTime()), - timetableLecture.getClassPlace(), + /**/, timetableLecture.getMemo(), timetableLecture.getGrades(), timetableLecture.getClassTitle(), From 3ae4c509c905d5c501caf0bffbb72c5ede9a8e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 Nov 2024 11:46:14 +0900 Subject: [PATCH 16/20] =?UTF-8?q?fix:=20=EC=9D=91=EB=8B=B5=20dto=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/TimetableLectureResponse.java | 59 ++++++++++++++----- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index b4f5e714b..f5c68e6da 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -81,7 +81,45 @@ public record ClassInfo( String classPlace ) { public static List of(String classTime, String classPlace) { + if (classPlace == null) { + return List.of(new ClassInfo(parseClassTimes(classTime), null)); + } + String[] classPlaceSegment = classPlace.split(","); + String[] classTimeSegment = classTime.substring(1, classTime.length() - 1).trim().split(","); + + List result = new ArrayList<>(); + List currentList = new ArrayList<>(); + int index = 0; + + for (String numStr : classTimeSegment) { + int num = Integer.parseInt(numStr); + if (num == -1) { + if (!currentList.isEmpty()) { + result.add(new ClassInfo(new ArrayList<>(currentList), classPlaceSegment[index++])); + currentList.clear(); + } + } + else { + currentList.add(num); + } + } + + if (!currentList.isEmpty()) { + result.add(new ClassInfo(new ArrayList<>(currentList), classPlaceSegment[index])); + } + + return result; + } + + private static List parseClassTimes(String classTime) { + if (classTime == null) return null; + + String classTimeWithoutBrackets = classTime.substring(INITIAL_BRACE_INDEX, classTime.length() - 1); + return Arrays.stream(classTimeWithoutBrackets.split(SEPARATOR)) + .map(String::strip) + .map(Integer::parseInt) + .toList(); } } @@ -99,7 +137,7 @@ public static List from(List ti null, null, null, - /**/, + ClassInfo.of(timetableLecture.getClassTime(), timetableLecture.getClassPlace()), timetableLecture.getMemo(), timetableLecture.getGrades(), timetableLecture.getClassTitle(), @@ -115,8 +153,7 @@ public static List from(List ti lecture.getRegularNumber(), lecture.getCode(), lecture.getDesignScore(), - getClassTime(timetableLecture, lecture), - timetableLecture.getClassPlace(), + ClassInfo.of(getClassTime(timetableLecture, lecture), timetableLecture.getClassPlace()), timetableLecture.getMemo(), getGrades(timetableLecture, lecture), getClassTitle(timetableLecture, lecture), @@ -152,11 +189,11 @@ private static String getGrades(TimetableLecture timetableLecture, Lecture lectu return timetableLecture.getGrades(); } - private static List getClassTime(TimetableLecture timetableLecture, Lecture lecture) { + private static String getClassTime(TimetableLecture timetableLecture, Lecture lecture) { if (timetableLecture.getClassTime() == null) { - return parseClassTimes(lecture.getClassTime()); + return lecture.getClassTime(); } - return parseClassTimes(timetableLecture.getClassTime()); + return timetableLecture.getClassTime(); } } @@ -172,14 +209,4 @@ public static TimetableLectureResponse of(TimetableFrame timetableFrame, Integer totalGrades ); } - - private static List parseClassTimes(String classTime) { - if (classTime == null) return null; - - String classTimeWithoutBrackets = classTime.substring(INITIAL_BRACE_INDEX, classTime.length() - 1); - return Arrays.stream(classTimeWithoutBrackets.split(SEPARATOR)) - .map(String::strip) - .map(Integer::parseInt) - .toList(); - } } From c16bc29a4758c57749d3d9608a113264a826da0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 Nov 2024 11:59:09 +0900 Subject: [PATCH 17/20] =?UTF-8?q?fix:=20=EA=B0=95=EC=9D=98=20=EC=9E=A5?= =?UTF-8?q?=EC=86=8C=20=EA=B3=B5=EB=B0=B1=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetableV2/dto/response/TimetableLectureResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index f5c68e6da..9eb35e741 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -85,8 +85,8 @@ public static List of(String classTime, String classPlace) { return List.of(new ClassInfo(parseClassTimes(classTime), null)); } - String[] classPlaceSegment = classPlace.split(","); - String[] classTimeSegment = classTime.substring(1, classTime.length() - 1).trim().split(","); + String[] classPlaceSegment = classPlace.split(",\\s*"); + String[] classTimeSegment = classTime.substring(1, classTime.length() - 1).trim().split(",\\s*"); List result = new ArrayList<>(); List currentList = new ArrayList<>(); From 8ba6728b5761024510ee49b5bbc1c5bd8f63459b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 Nov 2024 13:09:35 +0900 Subject: [PATCH 18/20] =?UTF-8?q?test:=20=EC=9D=91=EB=8B=B5=20dto=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acceptance/TimetableLectureApiTest.java | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java index dc4dfc2e9..d2a7e90a0 100644 --- a/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java +++ b/src/test/java/in/koreatech/koin/acceptance/TimetableLectureApiTest.java @@ -105,8 +105,12 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201], - "class_place": "한기대", + "class_infos": [ + { + "class_time": [200, 201], + "class_place": "한기대" + } + ], "memo": "메모", "grades": "2", "class_title": "커스텀생성1", @@ -121,8 +125,12 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203], - "class_place": "참빛관 편의점", + "class_infos": [ + { + "class_time": [202, 203], + "class_place": "참빛관 편의점" + } + ], "memo": "메모", "grades": "1", "class_title": "커스텀생성2", @@ -191,8 +199,12 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [200, 201], - "class_place": "한기대", + "class_infos": [ + { + "class_time": [200, 201], + "class_place": "한기대" + } + ], "memo": "메모한당 히히", "grades": "0", "class_title": "커스텀바꿔요1", @@ -207,8 +219,12 @@ void setup() { "regular_number": null, "code": null, "design_score": null, - "class_time": [202, 203], - "class_place": "참빛관 편의점", + "class_infos": [ + { + "class_time": [202, 203], + "class_place": "참빛관 편의점" + } + ], "memo": "메모한당 히히", "grades": "0", "class_title": "커스텀바꿔요2", @@ -248,8 +264,12 @@ void setup() { "regular_number": "25", "code": "ARB244", "design_score": "0", - "class_time": [200, 201, 202, 203, 204, 205, 206, 207], - "class_place": null, + "class_infos": [ + { + "class_time": [200, 201, 202, 203, 204, 205, 206, 207], + "class_place": null + } + ], "memo": null, "grades": "3", "class_title": "건축구조의 이해 및 실습", @@ -264,8 +284,12 @@ void setup() { "regular_number": "22", "code": "BSM590", "design_score": "0", - "class_time": [12, 13, 14, 15, 210, 211, 212, 213], - "class_place": null, + "class_infos": [ + { + "class_time": [12, 13, 14, 15, 210, 211, 212, 213], + "class_place": null + } + ], "memo": null, "grades": "3", "class_title": "컴퓨팅사고", From 4e15f2bbba206ec7d2ae7656f264f735151a1e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 Nov 2024 13:36:13 +0900 Subject: [PATCH 19/20] =?UTF-8?q?chore:=20=EC=A3=BC=EC=84=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/TimetableLectureResponse.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index 9eb35e741..55ff30a42 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -81,35 +81,37 @@ public record ClassInfo( String classPlace ) { public static List of(String classTime, String classPlace) { + // 정규 강의인 경우 강의 장소가 없기 때문에 바로 반환 if (classPlace == null) { return List.of(new ClassInfo(parseClassTimes(classTime), null)); } + // 구분자를 바탕으로 강의 시간과 강의 장소 분리 String[] classPlaceSegment = classPlace.split(",\\s*"); String[] classTimeSegment = classTime.substring(1, classTime.length() - 1).trim().split(",\\s*"); - List result = new ArrayList<>(); - List currentList = new ArrayList<>(); + List classInfos = new ArrayList<>(); + List tempClassTimes = new ArrayList<>(); int index = 0; - for (String numStr : classTimeSegment) { - int num = Integer.parseInt(numStr); - if (num == -1) { - if (!currentList.isEmpty()) { - result.add(new ClassInfo(new ArrayList<>(currentList), classPlaceSegment[index++])); - currentList.clear(); + for (String segment : classTimeSegment) { + int parseInt = Integer.parseInt(segment); + if (parseInt == -1) { + if (!tempClassTimes.isEmpty()) { + classInfos.add(new ClassInfo(new ArrayList<>(tempClassTimes), classPlaceSegment[index++])); + tempClassTimes.clear(); } } else { - currentList.add(num); + tempClassTimes.add(parseInt); } } - if (!currentList.isEmpty()) { - result.add(new ClassInfo(new ArrayList<>(currentList), classPlaceSegment[index])); + if (!tempClassTimes.isEmpty()) { + classInfos.add(new ClassInfo(new ArrayList<>(tempClassTimes), classPlaceSegment[index])); } - return result; + return classInfos; } private static List parseClassTimes(String classTime) { From 8630d8221a8147d0688a32acccd84c3611c0e206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 27 Nov 2024 14:08:18 +0900 Subject: [PATCH 20/20] =?UTF-8?q?chore:=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/TimetableLectureResponse.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java index 55ff30a42..bfc9c46a4 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/dto/response/TimetableLectureResponse.java @@ -91,24 +91,24 @@ public static List of(String classTime, String classPlace) { String[] classTimeSegment = classTime.substring(1, classTime.length() - 1).trim().split(",\\s*"); List classInfos = new ArrayList<>(); - List tempClassTimes = new ArrayList<>(); + List currentTimes = new ArrayList<>(); int index = 0; for (String segment : classTimeSegment) { int parseInt = Integer.parseInt(segment); if (parseInt == -1) { - if (!tempClassTimes.isEmpty()) { - classInfos.add(new ClassInfo(new ArrayList<>(tempClassTimes), classPlaceSegment[index++])); - tempClassTimes.clear(); + if (!currentTimes.isEmpty()) { + classInfos.add(new ClassInfo(new ArrayList<>(currentTimes), classPlaceSegment[index++])); + currentTimes.clear(); } } else { - tempClassTimes.add(parseInt); + currentTimes.add(parseInt); } } - if (!tempClassTimes.isEmpty()) { - classInfos.add(new ClassInfo(new ArrayList<>(tempClassTimes), classPlaceSegment[index])); + if (!currentTimes.isEmpty()) { + classInfos.add(new ClassInfo(new ArrayList<>(currentTimes), classPlaceSegment[index])); } return classInfos;