Skip to content

Commit

Permalink
fix : 내 그룹 참여자 조회시 NPE 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
1000kkannoo committed Aug 28, 2023
1 parent 398fdf6 commit 77a4075
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public CustomResponseEntity<GroupResponse.Create> createGroup(

// 모임 참여자 정보 리스트 조회 API
@GetMapping("")
public CustomResponseEntity<GroupResponse.Detail> readParticipateGroupByRegion(@RequestParam Long groupId) {
public CustomResponseEntity<GroupResponse.Detail> readParticipateGroupByRegion(
@RequestParam Long groupId
) {
return CustomResponseEntity.success(groupService.readParticipateGroupByRegion(groupId));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.moim.backend.domain.space.response;

import com.moim.backend.domain.space.entity.BestPlace;
import com.moim.backend.domain.space.entity.Groups;
import com.moim.backend.domain.space.entity.Participation;
import lombok.*;

import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class GroupResponse {
Expand Down Expand Up @@ -55,11 +56,15 @@ public static class Detail {
private List<Region> participantsByRegion;

public static Detail response(Groups group, List<Region> participantsByRegion) {
String date = Optional.ofNullable(group.getDate())
.map(d -> d.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.orElse(null);

return Detail.builder()
.groupId(group.getGroupId())
.name(group.getName())
.adminId(group.getAdminId())
.date(group.getDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.date(date)
.participantsByRegion(participantsByRegion)
.build();
}
Expand Down

0 comments on commit 77a4075

Please sign in to comment.