Skip to content

Commit

Permalink
Merge pull request #24 from kurtyoon/fix
Browse files Browse the repository at this point in the history
[Feat] WAS에 현재 디자인을 반영한다.
  • Loading branch information
kurtyoon authored Dec 20, 2023
2 parents 9c8440c + 8253a1d commit 8bb71e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/me")
@RequiredArgsConstructor
Expand All @@ -32,7 +34,7 @@ public ResponseDto<?> updateUserLocation(@SocialId String socialId,

@Operation(summary = "유저 팀 리스트 조회", description = "유저 팀 리스트를 조회합니다.")
@GetMapping("/team")
public ResponseDto<UserTeamListDto> getUserTeamList(@SocialId String socialId) {
public ResponseDto<List<UserTeamListDto>> getUserTeamList(@SocialId String socialId) {
return ResponseDto.ok(myPageService.getUserTeamList(socialId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ public record UserTeamDto(
@JsonProperty("team_id")
Long teamId,

@JsonProperty("title")
String title,

@JsonProperty("writer")
String writer,

@JsonProperty("content")
String content
) implements Serializable {
public static UserTeamDto of(
Long teamId, String title, String writer, String content
Long teamId, String writer, String content
) {
return UserTeamDto.builder()
.teamId(teamId)
.title(title)
.writer(writer)
.content(content)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

@Builder
public record UserTeamListDto (
@JsonProperty("title")
String title,
@JsonProperty("res")
List<UserTeamDto> res
) implements Serializable {
public static UserTeamListDto of(List<UserTeamDto> res) {
public static UserTeamListDto of(String title, List<UserTeamDto> res) {
return UserTeamListDto.builder()
.title(title)
.res(res)
.build();
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/donggukthon/volunmate/service/MyPageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ public boolean updateUserLocation(String socialId, UserLocationDto userLocationD
userLocationDto.myLatitude(), userLocationDto.myLongitude());
}

public UserTeamListDto getUserTeamList(String socialId) {
public List<UserTeamListDto> getUserTeamList(String socialId) {
User user = userRepository.findBySocialIdAndIsLogin(socialId, true)
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ERROR));
List<Volunteer> volunteers = volunteerRepository.findByUser(user);
List<UserTeamDto> userTeamDto = volunmateRepository.findByVolunteersIn(volunteers).stream()
.filter(volunmate -> volunmate.getStatus() == EStatusType.READY)
.map(volunmate -> UserTeamDto.of(
volunmate.getId(), volunmate.getVolunteer().getTitle(), volunmate.getUser().getUserName(), volunmate.getContent()
)).toList();
return UserTeamListDto.of(userTeamDto);
return volunteers.stream()
.map(volunteer -> {
String title = volunteer.getTitle();
List<UserTeamDto> userTeamDto = volunteer.getVolunmates().stream()
.map(volunmate -> UserTeamDto.of(
volunmate.getId(), volunmate.getUser().getUserName(), volunmate.getContent()
)).toList();
return UserTeamListDto.of(title, userTeamDto);
}).toList();
}

@Transactional
Expand Down

0 comments on commit 8bb71e5

Please sign in to comment.