Skip to content
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

[Feat/dashboard] 대시보드 학원 교습 타입 수정 대응 #98

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -57,15 +63,13 @@ public void validateLesson(final Long academyId, final Long lessonId) {
}
}

/**
* 응답으로 카테고리 종류 1개 이상으로 수정 List<String> categories
*/
@Override
public AcademyInfo findAcademyInfo(final Long academyId) {
final Academy academy = academyRepository.findAcademyById(academyId)
.orElseThrow(() -> new AcademyException("존재하지 않는 학원입니다."));
List<Long> categoryIds = academyCategoryRepository.findCategoryIdsByAcademyId(academyId);

return AcademyInfo.from(academy);
return AcademyInfo.from(academy, categoryIds);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -11,10 +13,14 @@ public record AcademyInfo(
String shuttleAvailability,
long expectedFee,
LocalDate updatedDate,
String areaOfExpertise
List<String> categories
) {

public static AcademyInfo from(final Academy entity) {
public static AcademyInfo from(final Academy entity, final List<Long> categoryIds) {
final List<String> categories = categoryIds.stream()
.map(CategoryInfo::getCategoryNameById)
.toList();

return new AcademyInfo(
entity.getId(),
entity.getAcademyName(),
Expand All @@ -23,7 +29,7 @@ public static AcademyInfo from(final Academy entity) {
entity.getShuttleAvailability(),
entity.getMaxEducationFee(),
entity.getUpdatedDate(),
entity.getAreaOfExpertise());
categories);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> childIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("수업 아이디"),
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,7 +119,7 @@ public AcademyInfo makeAcademyInfo() {
"AVAILABLE",
100_000,
LocalDate.now(),
"예능(대)"
List.of(SCIENCE.getCategoryName(), MATH.getCategoryName())
);
}

Expand Down