Skip to content

Commit

Permalink
[fix] 참여 가능한 모임 조회 response body 에 닉네임 추가 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
khyojun authored Jan 21, 2025
2 parents 40b0aac + cad98f7 commit 6fd82c9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ResponseEntity<ApiResponse<List<ActiveGroupsResponse>>> getFillGroups(
}

@GetMapping("/group/latest")
public ResponseEntity<ApiResponse<List<ActiveGroupsResponse>>> getLatestGroups(
public ResponseEntity<ApiResponse<List<LatestResponse>>> getLatestGroups(
@RequestHeader("Authorization") final String accessToken,
@RequestParam("groupType") final GroupType groupType
) {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/ggang/be/api/group/dto/LatestResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.ggang.be.api.group.dto;

import com.ggang.be.domain.constant.Category;
import com.ggang.be.domain.constant.GroupType;
import com.ggang.be.domain.constant.WeekDate;
import com.ggang.be.domain.group.dto.GroupVo;

import java.time.LocalDate;

public record LatestResponse(
long groupId,
Category category,
int coverImg,
int profileImg,
String nickname,
GroupType groupType,
String groupTitle,
WeekDate weekDate,
LocalDate groupDate,
double startTime,
double endTime,
String location
) {
public static LatestResponse fromGroupVo(GroupVo groupVo) {
return new LatestResponse(
groupVo.groupId(),
groupVo.category(),
groupVo.coverImg(),
groupVo.profileImg(),
groupVo.nickname(),
groupVo.groupType(),
groupVo.groupTitle(),
groupVo.weekDate(),
groupVo.groupDate(),
groupVo.startTime(),
groupVo.endTime(),
groupVo.location()
);
}
}
12 changes: 6 additions & 6 deletions src/main/java/com/ggang/be/api/group/facade/GroupFacade.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ggang.be.api.group.facade;

import com.ggang.be.api.group.ActiveCombinedGroupVoPreparer;
import com.ggang.be.api.group.CombinedNearestGroupVo;
import com.ggang.be.api.group.CombinedNearestGroupVoPreparer;
import com.ggang.be.api.group.ActiveCombinedGroupVoPreparer;
import com.ggang.be.api.group.GroupVoAggregator;
import com.ggang.be.api.group.dto.*;
import com.ggang.be.api.group.registry.*;
Expand All @@ -15,12 +15,13 @@
import com.ggang.be.domain.user.UserEntity;
import com.ggang.be.domain.user.dto.UserInfo;
import com.ggang.be.global.annotation.Facade;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;


@Facade
@RequiredArgsConstructor
Expand Down Expand Up @@ -134,7 +135,7 @@ public List<ActiveGroupsResponse> getFillGroups(long userId, Category category)
.collect(Collectors.toList());
}

public List<ActiveGroupsResponse> getLatestGroups(long userId, GroupType groupType) {
public List<LatestResponse> getLatestGroups(long userId, GroupType groupType) {
UserEntity currentUser = userService.getUserById(userId);

LatestGroupStrategy latestGroupStrategy = latestGroupStrategyRegistry.getGroupStrategy(
Expand All @@ -143,8 +144,7 @@ public List<ActiveGroupsResponse> getLatestGroups(long userId, GroupType groupTy
return latestGroupStrategy.getLatestGroups(currentUser).stream()
.filter(groupVo -> lectureTimeSlotService.isActiveGroupsInLectureTimeSlot(currentUser, groupVo))
.sorted((group1, group2) -> group2.createdAt().compareTo(group1.createdAt()))
.limit(5)
.map(ActiveGroupsResponse::fromGroupVo)
.limit(5).map(LatestResponse::fromGroupVo)
.collect(Collectors.toList());
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/ggang/be/domain/group/dto/GroupVo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.time.LocalDate;
import java.time.LocalDateTime;

public record GroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, GroupType groupType,
public record GroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, String nickname,
GroupType groupType,
String groupTitle, WeekDate weekDate, LocalDate groupDate, double startTime, double endTime, String location, LocalDateTime createdAt) {

public static GroupVo fromEveryGroup(EveryGroupVo everyGroupVo) {
Expand All @@ -20,6 +21,7 @@ public static GroupVo fromEveryGroup(EveryGroupVo everyGroupVo) {
everyGroupVo.category(),
everyGroupVo.coverImg(),
everyGroupVo.profileImg(),
everyGroupVo.nickname(),
GroupType.WEEKLY,
everyGroupVo.groupTitle(),
everyGroupVo.weekDate(),
Expand All @@ -38,6 +40,7 @@ public static GroupVo fromOnceGroup(OnceGroupVo onceGroupVo) {
onceGroupVo.category(),
onceGroupVo.coverImg(),
onceGroupVo.profileImg(),
onceGroupVo.nickname(),
GroupType.ONCE,
onceGroupVo.groupTitle(),
WeekDate.fromDayOfWeek(onceGroupVo.dateTime().getDayOfWeek()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import java.time.LocalDateTime;

public record EveryGroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, GroupType groupType,
public record EveryGroupVo(long groupId, Status status, Category category, int coverImg, int profileImg,
String nickname, GroupType groupType,
String groupTitle, WeekDate weekDate, double startTime, double endTime, String location, LocalDateTime createdAt) {
public static EveryGroupVo of(EveryGroupEntity everyGroupEntity) {
return new EveryGroupVo(
Expand All @@ -17,6 +18,7 @@ public static EveryGroupVo of(EveryGroupEntity everyGroupEntity) {
everyGroupEntity.getCategory(),
everyGroupEntity.getCoverImg(),
everyGroupEntity.getUserEntity().getProfileImg(),
everyGroupEntity.getUserEntity().getNickname(),
GroupType.WEEKLY,
everyGroupEntity.getTitle(),
everyGroupEntity.getGongbaekTimeSlotEntity().getWeekDate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import java.time.LocalDate;
import java.time.LocalDateTime;

public record OnceGroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, GroupType groupType,
public record OnceGroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, String nickname,
GroupType groupType,
String groupTitle, LocalDate dateTime, double startTime, double endTime, String location,
LocalDateTime createdAt, GongbaekTimeSlotEntity gongbaekTimeSlotEntity) {
public static OnceGroupVo of(OnceGroupEntity onceGroupEntity) {
Expand All @@ -19,6 +20,7 @@ public static OnceGroupVo of(OnceGroupEntity onceGroupEntity) {
onceGroupEntity.getCategory(),
onceGroupEntity.getCoverImg(),
onceGroupEntity.getUserEntity().getProfileImg(),
onceGroupEntity.getUserEntity().getNickname(),
GroupType.ONCE,
onceGroupEntity.getTitle(),
onceGroupEntity.getGroupDate(),
Expand Down

0 comments on commit 6fd82c9

Please sign in to comment.