diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/SalesController.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/SalesController.java index d19031b..eab1e76 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/SalesController.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/SalesController.java @@ -4,10 +4,12 @@ import com.won.smarketing.common.dto.ApiResponse; import com.won.smarketing.store.dto.SalesResponse; import com.won.smarketing.store.service.SalesService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,12 +28,16 @@ public class SalesController { /** * 매출 정보 조회 * + * @param storeId 가게 ID * @return 매출 정보 (오늘, 월간, 전일 대비) */ @Operation(summary = "매출 조회", description = "오늘 매출, 월간 매출, 전일 대비 매출 정보를 조회합니다.") - @GetMapping - public ResponseEntity> getSales() { - SalesResponse response = salesService.getSales(); + @GetMapping("/{storeId}") + public ResponseEntity> getSales( + @Parameter(description = "가게 ID", required = true) + @PathVariable Long storeId + ) { + SalesResponse response = salesService.getSales(storeId); return ResponseEntity.ok(ApiResponse.success(response)); } } diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/StoreController.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/StoreController.java index 348aa57..86191c5 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/StoreController.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/controller/StoreController.java @@ -58,17 +58,17 @@ public class StoreController { /** * 매장 정보 수정 * - * @param storeId 수정할 매장 ID + * //@param storeId 수정할 매장 ID * @param request 매장 수정 요청 정보 * @return 수정된 매장 정보 */ @Operation(summary = "매장 수정", description = "매장 정보를 수정합니다.") - @PutMapping("/{storeId}") + @PutMapping() public ResponseEntity> updateStore( @Parameter(description = "매장 ID", required = true) - @PathVariable Long storeId, + // @PathVariable Long storeId, @Valid @RequestBody StoreUpdateRequest request) { - StoreResponse response = storeService.updateStore(storeId, request); + StoreResponse response = storeService.updateStore(request); return ResponseEntity.ok(ApiResponse.success(response, "매장 정보가 성공적으로 수정되었습니다.")); } } diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/entity/Menu.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/entity/Menu.java index 83bb830..62627e1 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/entity/Menu.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/entity/Menu.java @@ -27,7 +27,7 @@ public class Menu { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "menu_id") - private Long id; + private Long menuId; @Column(name = "store_id", nullable = false) private Long storeId; diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/repository/MenuRepository.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/repository/MenuRepository.java index 67471dd..8a69e21 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/repository/MenuRepository.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/repository/MenuRepository.java @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Objects; +import java.util.Optional; /** * 메뉴 정보 데이터 접근을 위한 Repository diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/MenuServiceImpl.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/MenuServiceImpl.java index 7c31341..946e4ee 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/MenuServiceImpl.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/MenuServiceImpl.java @@ -79,6 +79,7 @@ public class MenuServiceImpl implements MenuService { @Override @Transactional public MenuResponse updateMenu(Long menuId, MenuUpdateRequest request) { + Menu menu = menuRepository.findById(menuId) .orElseThrow(() -> new BusinessException(ErrorCode.MENU_NOT_FOUND)); @@ -117,7 +118,7 @@ public class MenuServiceImpl implements MenuService { */ private MenuResponse toMenuResponse(Menu menu) { return MenuResponse.builder() - .menuId(menu.getId()) + .menuId(menu.getMenuId()) .menuName(menu.getMenuName()) .category(menu.getCategory()) .price(menu.getPrice()) diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesService.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesService.java index c077a9d..5221f56 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesService.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesService.java @@ -13,5 +13,5 @@ public interface SalesService { * * @return 매출 정보 */ - SalesResponse getSales(); + SalesResponse getSales(Long storeId); } diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesServiceImpl.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesServiceImpl.java index ded5564..5da7ddf 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesServiceImpl.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/SalesServiceImpl.java @@ -3,6 +3,7 @@ package com.won.smarketing.store.service; import com.won.smarketing.store.dto.SalesResponse; import com.won.smarketing.store.entity.Sales; import com.won.smarketing.store.repository.SalesRepository; +import com.won.smarketing.store.repository.StoreRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,6 +22,7 @@ import java.util.List; public class SalesServiceImpl implements SalesService { private final SalesRepository salesRepository; + private final StoreRepository storeRepository; /** * 매출 정보 조회 @@ -28,10 +30,7 @@ public class SalesServiceImpl implements SalesService { * @return 매출 정보 (오늘, 월간, 전일 대비) */ @Override - public SalesResponse getSales() { - // TODO: 현재는 더미 데이터 반환, 실제로는 현재 로그인한 사용자의 매장 ID를 사용해야 함 - Long storeId = 1L; // 임시로 설정 - + public SalesResponse getSales(Long storeId) { // 오늘 매출 계산 BigDecimal todaySales = calculateSalesByDate(storeId, LocalDate.now()); diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreService.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreService.java index ffd4a5f..aa2664b 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreService.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreService.java @@ -36,9 +36,9 @@ public interface StoreService { /** * 매장 정보 수정 * - * @param storeId 매장 ID + * //@param storeId 매장 ID * @param request 매장 수정 요청 정보 * @return 수정된 매장 정보 */ - StoreResponse updateStore(Long storeId, StoreUpdateRequest request); + StoreResponse updateStore(StoreUpdateRequest request); } diff --git a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreServiceImpl.java b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreServiceImpl.java index 4ddd56a..ea23dfe 100644 --- a/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreServiceImpl.java +++ b/smarketing-java/store/src/main/java/com/won/smarketing/store/service/StoreServiceImpl.java @@ -104,14 +104,16 @@ public class StoreServiceImpl implements StoreService { /** * 매장 정보 수정 * - * @param storeId 매장 ID + * //@param storeId 매장 ID * @param request 매장 수정 요청 정보 * @return 수정된 매장 정보 */ @Override @Transactional - public StoreResponse updateStore(Long storeId, StoreUpdateRequest request) { - Store store = storeRepository.findById(storeId) + public StoreResponse updateStore(StoreUpdateRequest request) { + String userId = getCurrentUserId(); + + Store store = storeRepository.findByUserId(userId) .orElseThrow(() -> new BusinessException(ErrorCode.STORE_NOT_FOUND)); // 매장 정보 업데이트