From f5e3d39a49e6b65dbb1ee7e29dcd9e5699200571 Mon Sep 17 00:00:00 2001 From: SeYoE Date: Fri, 1 Dec 2023 15:39:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Refactor:=20=ED=95=99=EC=9B=90=20=EA=B5=90?= =?UTF-8?q?=EC=8A=B5=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95=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 --- .../academy/service/AcademyAccessServiceImpl.java | 14 +++++++++----- .../domain/dashboard/facade/vo/AcademyInfo.java | 12 +++++++++--- .../controller/DashboardRestControllerTest.java | 4 ++-- .../domain/dashboard/fixture/DashboardFixture.java | 5 ++++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/guzzing/studayserver/domain/academy/service/AcademyAccessServiceImpl.java b/src/main/java/org/guzzing/studayserver/domain/academy/service/AcademyAccessServiceImpl.java index b570b1fe..231f23f1 100644 --- a/src/main/java/org/guzzing/studayserver/domain/academy/service/AcademyAccessServiceImpl.java +++ b/src/main/java/org/guzzing/studayserver/domain/academy/service/AcademyAccessServiceImpl.java @@ -1,8 +1,10 @@ package org.guzzing.studayserver.domain.academy.service; +import java.util.List; import org.guzzing.studayserver.domain.academy.model.Academy; import org.guzzing.studayserver.domain.academy.model.Lesson; import org.guzzing.studayserver.domain.academy.repository.academy.AcademyRepository; +import org.guzzing.studayserver.domain.academy.repository.academycategory.AcademyCategoryRepository; import org.guzzing.studayserver.domain.academy.repository.lesson.LessonRepository; import org.guzzing.studayserver.domain.academy.service.dto.result.AcademyAndLessonDetailResult; import org.guzzing.studayserver.domain.academy.service.dto.result.AcademyFeeInfo; @@ -20,14 +22,18 @@ public class AcademyAccessServiceImpl implements private final AcademyRepository academyRepository; private final LessonRepository lessonRepository; + private final AcademyCategoryRepository academyCategoryRepository; private final AcademyService academyService; public AcademyAccessServiceImpl( final AcademyRepository academyRepository, final LessonRepository lessonRepository, - AcademyService academyService) { + final AcademyCategoryRepository academyCategoryRepository, + final AcademyService academyService + ) { this.academyRepository = academyRepository; this.lessonRepository = lessonRepository; + this.academyCategoryRepository = academyCategoryRepository; this.academyService = academyService; } @@ -57,15 +63,13 @@ public void validateLesson(final Long academyId, final Long lessonId) { } } - /** - * 응답으로 카테고리 종류 1개 이상으로 수정 List categories - */ @Override public AcademyInfo findAcademyInfo(final Long academyId) { final Academy academy = academyRepository.findAcademyById(academyId) .orElseThrow(() -> new AcademyException("존재하지 않는 학원입니다.")); + List categoryIds = academyCategoryRepository.findCategoryIdsByAcademyId(academyId); - return AcademyInfo.from(academy); + return AcademyInfo.from(academy, categoryIds); } @Override diff --git a/src/main/java/org/guzzing/studayserver/domain/dashboard/facade/vo/AcademyInfo.java b/src/main/java/org/guzzing/studayserver/domain/dashboard/facade/vo/AcademyInfo.java index 66c6f690..ef00babb 100644 --- a/src/main/java/org/guzzing/studayserver/domain/dashboard/facade/vo/AcademyInfo.java +++ b/src/main/java/org/guzzing/studayserver/domain/dashboard/facade/vo/AcademyInfo.java @@ -1,7 +1,9 @@ package org.guzzing.studayserver.domain.dashboard.facade.vo; import java.time.LocalDate; +import java.util.List; import org.guzzing.studayserver.domain.academy.model.Academy; +import org.guzzing.studayserver.domain.academy.util.CategoryInfo; public record AcademyInfo( long academyId, @@ -11,10 +13,14 @@ public record AcademyInfo( String shuttleAvailability, long expectedFee, LocalDate updatedDate, - String areaOfExpertise + List categories ) { - public static AcademyInfo from(final Academy entity) { + public static AcademyInfo from(final Academy entity, final List categoryIds) { + final List categories = categoryIds.stream() + .map(CategoryInfo::getCategoryNameById) + .toList(); + return new AcademyInfo( entity.getId(), entity.getAcademyName(), @@ -23,7 +29,7 @@ public static AcademyInfo from(final Academy entity) { entity.getShuttleAvailability(), entity.getMaxEducationFee(), entity.getUpdatedDate(), - entity.getAreaOfExpertise()); + categories); } } diff --git a/src/test/java/org/guzzing/studayserver/domain/dashboard/controller/DashboardRestControllerTest.java b/src/test/java/org/guzzing/studayserver/domain/dashboard/controller/DashboardRestControllerTest.java index 6b838da5..607327b2 100644 --- a/src/test/java/org/guzzing/studayserver/domain/dashboard/controller/DashboardRestControllerTest.java +++ b/src/test/java/org/guzzing/studayserver/domain/dashboard/controller/DashboardRestControllerTest.java @@ -282,7 +282,7 @@ void getDashboard() throws Exception { .description("셔틀 운행 여부"), fieldWithPath("academyInfo.expectedFee").type(NUMBER).description("예상 교육비"), fieldWithPath("academyInfo.updatedDate").type(STRING).description("업데이트 날짜"), - fieldWithPath("academyInfo.areaOfExpertise").type(STRING) + fieldWithPath("academyInfo.categories").type(ARRAY) .description("강의 분야 구분"), fieldWithPath("lessonInfo").type(OBJECT).description("수업 정보"), fieldWithPath("lessonInfo.lessonId").type(NUMBER).description("수업 아이디"), @@ -397,7 +397,7 @@ void getDashboards_ByActiveOnlyBoolean_AllDashboardOfChild() throws Exception { .description("예상 교육비"), fieldWithPath("responses[].academyInfo.updatedDate").type(STRING) .description("업데이트 날짜"), - fieldWithPath("responses[].academyInfo.areaOfExpertise").type(STRING) + fieldWithPath("responses[].academyInfo.categories").type(ARRAY) .description("강의 분야 구분"), fieldWithPath("responses[].lessonInfo").type(OBJECT).description("수업 정보"), fieldWithPath("responses[].lessonInfo.lessonId").type(NUMBER) diff --git a/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java b/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java index 598c3f3d..97123e42 100644 --- a/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java +++ b/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java @@ -3,6 +3,8 @@ import static java.time.DayOfWeek.FRIDAY; import static java.time.DayOfWeek.MONDAY; import static java.time.DayOfWeek.SUNDAY; +import static org.guzzing.studayserver.domain.academy.util.CategoryInfo.MATH; +import static org.guzzing.studayserver.domain.academy.util.CategoryInfo.SCIENCE; import static org.guzzing.studayserver.domain.dashboard.model.vo.Repeatance.WEEKLY; import static org.guzzing.studayserver.domain.dashboard.model.vo.SimpleMemoType.CHEAP_FEE; import static org.guzzing.studayserver.domain.dashboard.model.vo.SimpleMemoType.GOOD_FACILITY; @@ -14,6 +16,7 @@ import java.time.LocalDate; import java.util.List; import java.util.Map; +import org.guzzing.studayserver.domain.academy.util.CategoryInfo; import org.guzzing.studayserver.domain.dashboard.controller.dto.request.DashboardPostRequest; import org.guzzing.studayserver.domain.dashboard.controller.dto.request.DashboardPutRequest; import org.guzzing.studayserver.domain.dashboard.controller.vo.Schedule; @@ -117,7 +120,7 @@ public AcademyInfo makeAcademyInfo() { "AVAILABLE", 100_000, LocalDate.now(), - "예능(대)" + List.of(SCIENCE.getCategoryName(), MATH.getCategoryName()) ); } From 952e53fc6471b1759e5da3fd2e3d07d73443cb43 Mon Sep 17 00:00:00 2001 From: SeYoE Date: Fri, 1 Dec 2023 15:40:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Style:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=EB=A7=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/AcademyCalendarLoadToUpdateResponse.java | 6 +++--- .../domain/dashboard/repository/DashboardJpaRepository.java | 6 +++--- .../studayserver/domain/region/service/RegionService.java | 1 - .../studayserver/domain/review/service/ReviewService.java | 2 +- .../domain/dashboard/fixture/DashboardFixture.java | 1 - 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/guzzing/studayserver/domain/calendar/controller/dto/response/AcademyCalendarLoadToUpdateResponse.java b/src/main/java/org/guzzing/studayserver/domain/calendar/controller/dto/response/AcademyCalendarLoadToUpdateResponse.java index 045f1225..19a06d89 100644 --- a/src/main/java/org/guzzing/studayserver/domain/calendar/controller/dto/response/AcademyCalendarLoadToUpdateResponse.java +++ b/src/main/java/org/guzzing/studayserver/domain/calendar/controller/dto/response/AcademyCalendarLoadToUpdateResponse.java @@ -44,12 +44,12 @@ public static LessonScheduleLoadToUpdateResponse from( return new LessonScheduleLoadToUpdateResponse( result.dayOfWeek(), new LessonTime( - result.lessonStartTime(), - result.lessonEndTime()) + result.lessonStartTime(), + result.lessonEndTime()) ); } - public record LessonTime ( + public record LessonTime( String lessonStartTime, String lessonEndTime ) { diff --git a/src/main/java/org/guzzing/studayserver/domain/dashboard/repository/DashboardJpaRepository.java b/src/main/java/org/guzzing/studayserver/domain/dashboard/repository/DashboardJpaRepository.java index 3be306e8..7bb2faa5 100644 --- a/src/main/java/org/guzzing/studayserver/domain/dashboard/repository/DashboardJpaRepository.java +++ b/src/main/java/org/guzzing/studayserver/domain/dashboard/repository/DashboardJpaRepository.java @@ -16,8 +16,8 @@ public interface DashboardJpaRepository extends @Modifying(clearAutomatically = true) @Query(""" - delete from Dashboard d - where d.childId in :childIds - """) + delete from Dashboard d + where d.childId in :childIds + """) void deleteByChildIds(List childIds); } diff --git a/src/main/java/org/guzzing/studayserver/domain/region/service/RegionService.java b/src/main/java/org/guzzing/studayserver/domain/region/service/RegionService.java index e322d814..ac5180e0 100644 --- a/src/main/java/org/guzzing/studayserver/domain/region/service/RegionService.java +++ b/src/main/java/org/guzzing/studayserver/domain/region/service/RegionService.java @@ -3,7 +3,6 @@ import static org.guzzing.studayserver.domain.region.model.Region.BASE_REGION_SIDO; import java.util.List; -import java.util.Optional; import org.guzzing.studayserver.domain.region.model.Region; import org.guzzing.studayserver.domain.region.repository.RegionRepository; import org.guzzing.studayserver.domain.region.service.dto.beopjungdong.SidoResult; diff --git a/src/main/java/org/guzzing/studayserver/domain/review/service/ReviewService.java b/src/main/java/org/guzzing/studayserver/domain/review/service/ReviewService.java index b4302a95..391bdcbf 100644 --- a/src/main/java/org/guzzing/studayserver/domain/review/service/ReviewService.java +++ b/src/main/java/org/guzzing/studayserver/domain/review/service/ReviewService.java @@ -61,7 +61,7 @@ public ReviewPostResult createReviewOfAcademy(final ReviewPostParam param) { } @Transactional - public void removeReview(final long memberId){ + public void removeReview(final long memberId) { reviewRepository.deleteByMemberId(memberId); } diff --git a/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java b/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java index 97123e42..0216362a 100644 --- a/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java +++ b/src/test/java/org/guzzing/studayserver/domain/dashboard/fixture/DashboardFixture.java @@ -16,7 +16,6 @@ import java.time.LocalDate; import java.util.List; import java.util.Map; -import org.guzzing.studayserver.domain.academy.util.CategoryInfo; import org.guzzing.studayserver.domain.dashboard.controller.dto.request.DashboardPostRequest; import org.guzzing.studayserver.domain.dashboard.controller.dto.request.DashboardPutRequest; import org.guzzing.studayserver.domain.dashboard.controller.vo.Schedule;