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 #198

Merged
merged 5 commits into from
Dec 6, 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 @@ -57,13 +57,12 @@ public class StoreController {
public ResponseCustom<Page<SearchStoresResponse>> searchByCategory(
Authentication authentication,
@RequestParam(required = false, defaultValue = "3") Integer searchRadius,
@RequestParam(required = false, defaultValue = "ALL") Category category,
Double lat,
Double lon, Pageable pageable) {
@RequestParam(required = false, defaultValue = "전체") String category,
Double lat, Double lon, Pageable pageable) {
Category categoryEnum = Category.fromDisplayName(category);
return ResponseCustom.OK(
storeService.searchByCategory(AuthenticationParser.parseUserId(authentication), searchRadius, category, lat,
lon,
pageable));
storeService.searchByCategory(AuthenticationParser.parseUserId(authentication), searchRadius, categoryEnum,
lat, lon, pageable));
}

@Operation(summary = "맀μž₯ μ°ΎκΈ°(검색)", description = "검색어와 맀μž₯ μœ ν˜•μ— λ§žλŠ” 맀μž₯을 κ²€μƒ‰ν•©λ‹ˆλ‹€.")
Expand Down Expand Up @@ -159,10 +158,10 @@ public ResponseCustom<OrdersDetailResponse> getOrders(Authentication authenticat
@Operation(summary = "κ°€κ²Œ μ—‘μ…€ λ‹€μš΄λ‘œλ“œ", description = "κ°€κ²Œ μž₯λΆ€ μ„ΈλΆ€ 내역을 μ—‘μ…€λ‘œ μ œκ³΅ν•©λ‹ˆλ‹€.")
@GetMapping("/excel")
public ResponseEntity<?> getExcel(
Authentication authentication,
// Authentication authentication,
@RequestParam(defaultValue = "1") Integer period
) {
byte[] excel = storeService.createExcel(AuthenticationParser.parseUserId(authentication), period);
byte[] excel = storeService.createExcel("test-owner", period);

String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String fileName = "μž₯λΆ€_μ„ΈλΆ€λ‚΄μ—­_" + period + "κ°œμ›”_" + today + ".xlsx";
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/jangburich/domain/store/domain/Category.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jangburich.domain.store.domain;

import java.util.Arrays;

public enum Category {
ALL("전체"),
KOREAN("ν•œμ‹"),
Expand All @@ -24,4 +26,19 @@ public enum Category {
public String getDisplayName() {
return displayName;
}

public static Category fromDisplayName(String displayName) {
return Arrays.stream(Category.values())
.filter(category -> category.getDisplayName().equals(displayName))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Invalid category: " + displayName + ". Please use one of: " + getValidCategories()));
}

private static String getValidCategories() {
return Arrays.stream(Category.values())
.map(Category::getDisplayName)
.reduce((a, b) -> a + ", " + b)
.orElse("");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.jangburich.domain.store.domain.Category;
import com.querydsl.core.annotations.QueryProjection;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

import lombok.Builder;

@Builder
Expand Down Expand Up @@ -33,9 +36,18 @@ public SearchStoresResponse(Long storeId, String name, Double latitude, Double l
category.getDisplayName(),
distance,
businessStatus,
closeTime,
formatCloseTime(closeTime),
phoneNumber,
imageUrl
);
}
}

private static String formatCloseTime(String closeTime) {
try {
LocalTime time = LocalTime.parse(closeTime.split("\\.")[0]);
return time.format(DateTimeFormatter.ofPattern("HH:mm"));
} catch (Exception e) {
return closeTime;
}
}
}
Loading