Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public enum SwaggerResponseDescription {
ROOM_PASSWORD_NOT_REQUIRED
))),
ROOM_RECRUITING_DETAIL_VIEW(new LinkedHashSet<>(Set.of(
ROOM_NOT_FOUND
ROOM_NOT_FOUND,
BOOK_NOT_FOUND,
ROOM_RECRUITMENT_PERIOD_EXPIRED
))),
ROOM_GET_HOME_JOINED_LIST(new LinkedHashSet<>(Set.of(
USER_NOT_FOUND
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/konkuk/thip/common/util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ public static String formatAfterTime(LocalDate date) {
return minutes + "분 뒤";
}

public static String RecruitingRoomFormatAfterTime(LocalDate date) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime dateTime = date.atStartOfDay();
Duration d = Duration.between(now, dateTime);

if (d.isNegative() || d.isZero()) {
return "??";
}

long days = d.toDays();
if (days > 0) {
return days + "일 남음";
}

long hours = d.toHours();
if (hours >= 1) {
return hours + "시간 남음";
}

return "마감 임박";
}


public static String formatDate(LocalDate date) {
return date.format(DATE_FORMATTER);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package konkuk.thip.recentSearch.adapter.in.web;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import konkuk.thip.common.dto.BaseResponse;
import konkuk.thip.common.security.annotation.UserId;
Expand All @@ -25,7 +26,7 @@ public class RecentSearchCommandController {
@DeleteMapping("/recent-searches/{recentSearchId}")
public BaseResponse<Void> deleteRecentSearch(
@PathVariable(value = "recentSearchId") final Long recentSearchId,
@UserId final Long userId
@Parameter(hidden = true) @UserId final Long userId
) {
return BaseResponse.ok(recentSearchDeleteUseCase.deleteRecentSearch(recentSearchId, userId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public record RoomRecruitingDetailViewResponse(
@Builder
public record RecommendRoom(
Long roomId,
String roomImageUrl,
String bookImageUrl,
String roomName,
int memberCount,
int recruitCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ public List<RoomQueryDto> findRecruitingRoomsWithCategoryOrderByMemberCountDesc(
public List<RoomRecruitingDetailViewResponse.RecommendRoom> findOtherRecruitingRoomsByCategoryOrderByStartDateAsc(Long roomId, String category, int count) {
NumberExpression<Long> memberCountExpr = participant.roomParticipantId.count();
List<Tuple> tuples = queryFactory
.select(room.roomId, room.title, memberCountExpr, room.recruitCount, room.startDate)
.select(room.roomId, room.title, memberCountExpr, room.recruitCount, room.startDate, book.imageUrl)
.from(room)
.join(room.bookJpaEntity, book)
.leftJoin(participant).on(participant.roomJpaEntity.eq(room))
Comment thread
hd0rable marked this conversation as resolved.
.where(
room.categoryJpaEntity.value.eq(category)
Expand All @@ -195,7 +196,7 @@ public List<RoomRecruitingDetailViewResponse.RecommendRoom> findOtherRecruitingR
return tuples.stream()
.map(t -> RoomRecruitingDetailViewResponse.RecommendRoom.builder()
.roomId(t.get(room.roomId))
.roomImageUrl(null) // roomImageUrl은 추후 구현
.bookImageUrl(t.get(book.imageUrl))
.roomName(t.get(room.title))
.memberCount(t.get(memberCountExpr).intValue())
.recruitCount(t.get(room.recruitCount))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class RoomShowRecruitingDetailViewService implements RoomShowRecruitingDe
public RoomRecruitingDetailViewResponse getRecruitingRoomDetailView(Long userId, Long roomId) {
// 1. Room 조회, Book 조회
Room room = roomCommandPort.getByIdOrThrow(roomId);
room.validateRoomRecruitExpired(); // 모집기간 지난 방 예외처리

Book book = bookCommandPort.findById(room.getBookId());

// 2. Room과 연관된 UserRoom 조회, RoomParticipants 일급 컬렉션 생성
Expand Down Expand Up @@ -62,7 +64,7 @@ private RoomRecruitingDetailViewResponse buildResponse(
.isPublic(room.isPublic())
.progressStartDate(DateUtil.formatDate(room.getStartDate()))
.progressEndDate(DateUtil.formatDate(room.getEndDate()))
.recruitEndDate(DateUtil.formatAfterTime(room.getStartDate()))
.recruitEndDate(DateUtil.RecruitingRoomFormatAfterTime(room.getStartDate()))
.category(room.getCategory().getValue())
.categoryColor(roomQueryPort.findAliasColorOfCategory(room.getCategory())) // TODO : 리펙토링 대상
.roomDescription(room.getDescription())
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/konkuk/thip/room/domain/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void validateRoomRecruitExpired() {
if (isRecruitmentPeriodExpired()) {
String message = String.format("모집기간(%s까지)이 만료된 방에는 참여할 수 없습니다.", deadline);
throw new InvalidStateException(
ErrorCode.ROOM_RECRUITMENT_PERIOD_EXPIRED, new IllegalArgumentException(message)
ROOM_RECRUITMENT_PERIOD_EXPIRED, new IllegalArgumentException(message)
);
}
}
Expand Down