diff --git a/src/main/java/com/jangburich/domain/store/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/controller/StoreController.java index 571a311..0349eee 100644 --- a/src/main/java/com/jangburich/domain/store/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/controller/StoreController.java @@ -23,6 +23,12 @@ import com.jangburich.domain.store.domain.StoreGetResponseDTO; import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; +<<<<<<< Updated upstream +======= +import com.jangburich.domain.store.dto.StoreTeamResponse; +import com.jangburich.domain.store.dto.condition.StoreSearchCondition; +import com.jangburich.domain.store.dto.condition.StoreSearchConditionWithType; +>>>>>>> Stashed changes import com.jangburich.domain.store.dto.response.OrdersDetailResponse; import com.jangburich.domain.store.dto.response.OrdersGetResponse; import com.jangburich.domain.store.dto.response.OrdersTodayResponse; @@ -108,7 +114,7 @@ public ResponseCustom getStoreInfo(Authentication authentic @Operation(summary = "결제 그룹 조회", description = "장부 결제 그룹을 조회합니다.") @GetMapping("/payment_group") - public ResponseCustom> getPaymentGroup(Authentication authentication) { + public ResponseCustom> getPaymentGroup(Authentication authentication) { return ResponseCustom.OK( storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication))); } diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java index 34ecc75..6318300 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java @@ -1,5 +1,7 @@ package com.jangburich.domain.store.domain; +import java.time.LocalDateTime; + import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; @@ -11,17 +13,19 @@ public record StoreTeamResponseDTO( Long teamId, String teamName, String teamDescription, - Long storeId + Long storeId, + LocalDateTime updatedAt ) { @QueryProjection public StoreTeamResponseDTO(Long id, Integer remainPoint, Long teamId, String teamName, String teamDescription, - Long storeId) { + Long storeId, LocalDateTime updatedAt) { this.id = id; this.remainPoint = remainPoint; this.teamId = teamId; this.teamName = teamName; this.teamDescription = teamDescription; this.storeId = storeId; + this.updatedAt = updatedAt; } } diff --git a/src/main/java/com/jangburich/domain/store/dto/StoreTeamResponse.java b/src/main/java/com/jangburich/domain/store/dto/StoreTeamResponse.java new file mode 100644 index 0000000..0e553de --- /dev/null +++ b/src/main/java/com/jangburich/domain/store/dto/StoreTeamResponse.java @@ -0,0 +1,39 @@ +package com.jangburich.domain.store.dto; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class StoreTeamResponse { + Long id; + Integer remainPoint; + Long teamId; + String teamName; + String teamDescription; + Long storeId; + String period; + + public StoreTeamResponse(Long id, Integer remainPoint, Long teamId, String teamName, String teamDescription, + Long storeId, LocalDateTime period, long maxReservation) { + this.id = id; + this.remainPoint = remainPoint; + this.teamId = teamId; + this.teamName = teamName; + this.teamDescription = teamDescription; + this.storeId = storeId; + this.period = calculateDateRange(period, maxReservation); + } + + private String calculateDateRange(LocalDateTime updatedAt, long maxReservation) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); + + // 시작 날짜 + String startDate = updatedAt.format(formatter); + + // 종료 날짜 + LocalDateTime endDateTime = updatedAt.plusDays(maxReservation); + String endDate = endDateTime.format(formatter); + + // 범위 문자열 생성 + return startDate + " ~ " + endDate; + } +} diff --git a/src/main/java/com/jangburich/domain/store/service/StoreService.java b/src/main/java/com/jangburich/domain/store/service/StoreService.java index 29a4681..086a053 100644 --- a/src/main/java/com/jangburich/domain/store/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/service/StoreService.java @@ -34,6 +34,7 @@ import com.jangburich.domain.store.domain.StoreTeam; import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; +import com.jangburich.domain.store.dto.StoreTeamResponse; import com.jangburich.domain.store.dto.condition.StoreSearchCondition; import com.jangburich.domain.store.dto.condition.StoreSearchConditionWithType; import com.jangburich.domain.store.dto.response.OrdersDetailResponse; @@ -211,7 +212,7 @@ public StoreGetResponseDTO getStoreInfo(String authentication) { return new StoreGetResponseDTO().of(store); } - public List getPaymentGroup(String userId) { + public List getPaymentGroup(String userId) { User user = userRepository.findByProviderId(userId) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); @@ -221,7 +222,12 @@ public List getPaymentGroup(String userId) { Store store = storeRepository.findByOwner(owner) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); - return storeTeamRepository.findAllByStore(store); + List list = storeTeamRepository.findAllByStore(store).stream().map(storeTeamResponseDTO -> { + return new StoreTeamResponse(storeTeamResponseDTO.id(), storeTeamResponseDTO.remainPoint(), + storeTeamResponseDTO.teamId(), storeTeamResponseDTO.teamName(), storeTeamResponseDTO.teamDescription(), + storeTeamResponseDTO.storeId(), storeTeamResponseDTO.updatedAt(), store.getMaxReservation()); + }).toList(); + return list; } public Page searchByCategory(final String authentication, final Integer searchRadius,