Skip to content

Commit

Permalink
Merge pull request #140 from 9oormthon-univ/fix/store
Browse files Browse the repository at this point in the history
Fix/store
  • Loading branch information
HyunWoo9930 authored Nov 23, 2024
2 parents 2e9dffc + c96e2df commit adf3064
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
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

0 comments on commit adf3064

Please sign in to comment.