Skip to content

Commit

Permalink
[FEAT] mapper 변환과정 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Dec 13, 2023
1 parent 2e36b8c commit 8bcacb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ PlanInfoResponse toPlanInfoResponse(
GroupInfoResponse groupInfoResponse,
List<MemberResponse> memberResponses);

@IterableMapping(elementTargetType = PlanInfoResponse.class)
List<PlanInfoResponse> toPlanInfoResponses(List<Plan> plans);

@IterableMapping(qualifiedByName = "toPlaceDetails")
@IterableMapping(qualifiedByName = "toPlaceDetail")
List<PlaceDetails> toPlaceDetails(List<PlaceClientDetails> placeClientDetails);

@Named("toPlaceDetails")
@Named("toPlaceDetail")
@Mapping(target = "longitude", source = "x")
@Mapping(target = "latitude", source = "y")
PlaceDetails toPlaceDetails(PlaceClientDetails placeClientDetails);
PlaceDetails toPlaceDetail(PlaceClientDetails placeClientDetails);
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public void outPlan(PlanMemberRequest request) {
public PlanInfoResponse getPlanById(UUID id) {
Plan plan = getPlanEntity(id);

return getPlanInfoResponse(plan);
}

private PlanInfoResponse getPlanInfoResponse(final Plan plan) {
GroupInfoResponse groupInfo = groupService.getGroupInfoResponse(plan.getGroup());
PlaceClientDetails placeDetails = placeService.getPlaceDetails(plan.getPlace());

Expand All @@ -122,7 +126,7 @@ public Plan getPlanEntity(UUID id) {
public List<PlanInfoResponse> getPlans() {
final Member member = authService.getMemberByJwt();
final List<Plan> plans = planRepository.findAllByMember(member);
return planMapper.toPlanInfoResponses(plans);
return plans.stream().map(this::getPlanInfoResponse).toList();
}

public void updatePlan(final UpdatePlanRequest updatePlanRequest) {
Expand Down

0 comments on commit 8bcacb3

Please sign in to comment.