diff --git a/src/main/java/com/ggang/be/api/group/controller/GroupController.java b/src/main/java/com/ggang/be/api/group/controller/GroupController.java index 8e12c6b..1b699b0 100644 --- a/src/main/java/com/ggang/be/api/group/controller/GroupController.java +++ b/src/main/java/com/ggang/be/api/group/controller/GroupController.java @@ -98,7 +98,7 @@ public ResponseEntity>> getFillGroups( } @GetMapping("/group/latest") - public ResponseEntity>> getLatestGroups( + public ResponseEntity>> getLatestGroups( @RequestHeader("Authorization") final String accessToken, @RequestParam("groupType") final GroupType groupType ) { diff --git a/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java b/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java new file mode 100644 index 0000000..31906cd --- /dev/null +++ b/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java @@ -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() + ); + } +} diff --git a/src/main/java/com/ggang/be/api/group/facade/GroupFacade.java b/src/main/java/com/ggang/be/api/group/facade/GroupFacade.java index daab787..a030e29 100644 --- a/src/main/java/com/ggang/be/api/group/facade/GroupFacade.java +++ b/src/main/java/com/ggang/be/api/group/facade/GroupFacade.java @@ -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.*; @@ -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 @@ -134,7 +135,7 @@ public List getFillGroups(long userId, Category category) .collect(Collectors.toList()); } - public List getLatestGroups(long userId, GroupType groupType) { + public List getLatestGroups(long userId, GroupType groupType) { UserEntity currentUser = userService.getUserById(userId); LatestGroupStrategy latestGroupStrategy = latestGroupStrategyRegistry.getGroupStrategy( @@ -143,8 +144,7 @@ public List 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()); } diff --git a/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java b/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java index 595410d..5095e40 100644 --- a/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java +++ b/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java @@ -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) { @@ -20,6 +21,7 @@ public static GroupVo fromEveryGroup(EveryGroupVo everyGroupVo) { everyGroupVo.category(), everyGroupVo.coverImg(), everyGroupVo.profileImg(), + everyGroupVo.nickname(), GroupType.WEEKLY, everyGroupVo.groupTitle(), everyGroupVo.weekDate(), @@ -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()), diff --git a/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java b/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java index 0d0ff50..8efe105 100644 --- a/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java +++ b/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java @@ -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( @@ -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(), diff --git a/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupVo.java b/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupVo.java index bfa9e54..f6d7ea7 100644 --- a/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupVo.java +++ b/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupVo.java @@ -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) { @@ -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(),