Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #141

Merged
merged 4 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +114,7 @@ public ResponseCustom<StoreGetResponseDTO> getStoreInfo(Authentication authentic

@Operation(summary = "결제 κ·Έλ£Ή 쑰회", description = "μž₯λΆ€ 결제 그룹을 μ‘°νšŒν•©λ‹ˆλ‹€.")
@GetMapping("/payment_group")
public ResponseCustom<List<StoreTeamResponseDTO>> getPaymentGroup(Authentication authentication) {
public ResponseCustom<List<StoreTeamResponse>> getPaymentGroup(Authentication authentication) {
return ResponseCustom.OK(
storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jangburich.domain.store.domain;

import java.time.LocalDateTime;

import com.querydsl.core.annotations.QueryProjection;

import lombok.Builder;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -211,7 +212,7 @@ public StoreGetResponseDTO getStoreInfo(String authentication) {
return new StoreGetResponseDTO().of(store);
}

public List<StoreTeamResponseDTO> getPaymentGroup(String userId) {
public List<StoreTeamResponse> getPaymentGroup(String userId) {
User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));

Expand All @@ -221,7 +222,12 @@ public List<StoreTeamResponseDTO> getPaymentGroup(String userId) {
Store store = storeRepository.findByOwner(owner)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));

return storeTeamRepository.findAllByStore(store);
List<StoreTeamResponse> 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<SearchStoresResponse> searchByCategory(final String authentication, final Integer searchRadius,
Expand Down
Loading