diff --git a/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java b/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java index e2caec3..8250686 100644 --- a/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java +++ b/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java @@ -2,7 +2,6 @@ import java.util.List; -import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -18,6 +17,7 @@ import com.jangburich.domain.menu.domain.MenuUpdateRequestDTO; import com.jangburich.domain.menu.domain.service.MenuService; import com.jangburich.domain.oauth.domain.CustomOAuthUser; +import com.jangburich.global.payload.Message; import com.jangburich.global.payload.ResponseCustom; import io.swagger.v3.oas.annotations.tags.Tag; @@ -32,31 +32,31 @@ public class MenuController { private final MenuService menuService; @PostMapping("/register") - public ResponseCustom registerMenu(Authentication authentication, + public ResponseCustom registerMenu(Authentication authentication, @RequestBody MenuCreateRequestDTO menuCreateRequestDTO) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.registerMenu(customOAuthUser, menuCreateRequestDTO); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @PatchMapping("/update/{id}") - public ResponseCustom updateMenu(Authentication authentication, @PathVariable Long id, + public ResponseCustom updateMenu(Authentication authentication, @PathVariable Long id, @RequestBody MenuUpdateRequestDTO menuUpdateRequestDTO) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.updateMenu(customOAuthUser, id, menuUpdateRequestDTO); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @DeleteMapping("/{id}") - public ResponseCustom deleteMenu(Authentication authentication, @PathVariable Long id) { + public ResponseCustom deleteMenu(Authentication authentication, @PathVariable Long id) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.deleteMenu(customOAuthUser, id); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @GetMapping("") public ResponseCustom> getMenu(Authentication authentication) { - CustomOAuthUser customOAuthUser = (CustomOAuthUser) authentication.getPrincipal(); + CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); List menu = menuService.getMenu(customOAuthUser); return ResponseCustom.OK(menu); } 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 b2be3af..34ecc75 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java @@ -1,6 +1,5 @@ package com.jangburich.domain.store.domain; -import com.jangburich.domain.team.domain.Team; import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; @@ -8,18 +7,21 @@ @Builder public record StoreTeamResponseDTO( Long id, - Integer point, + Integer remainPoint, Long teamId, String teamName, + String teamDescription, Long storeId ) { @QueryProjection - public StoreTeamResponseDTO(Long id, Integer point, Long teamId, String teamName, Long storeId) { + public StoreTeamResponseDTO(Long id, Integer remainPoint, Long teamId, String teamName, String teamDescription, + Long storeId) { this.id = id; - this.point = point; + this.remainPoint = remainPoint; this.teamId = teamId; this.teamName = teamName; + this.teamDescription = teamDescription; this.storeId = storeId; } } diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index f55caf1..67c21d3 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -85,11 +85,10 @@ public ResponseCustom createAdditionalInfo(Authentication authenticatio } @Operation(summary = "가게 정보 수정", description = "가게 정보를 수정합니다.") - @PatchMapping("/{storeId}/update") - public ResponseCustom updateStore(Authentication authentication, @PathVariable Long storeId, + @PatchMapping("/update") + public ResponseCustom updateStore(Authentication authentication, @RequestBody StoreUpdateRequestDTO storeUpdateRequestDTO) { - CustomOAuthUser principal = (CustomOAuthUser)authentication.getPrincipal(); - storeService.updateStore(principal, storeId, storeUpdateRequestDTO); + storeService.updateStore(AuthenticationParser.parseUserId(authentication), storeUpdateRequestDTO); return ResponseCustom.OK(Message.builder().message("success").build()); } @@ -120,6 +119,7 @@ public ResponseCustom getPaymentGroupDetail(Authenti @Operation(summary = "결제 내역 조회", description = "가게에서 일어난 결제 내역을 조회합니다.") @GetMapping("/payment_history") public ResponseCustom getPaymentHistory(Authentication authentication, Pageable pageable) { - return ResponseCustom.OK(storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable)); + return ResponseCustom.OK( + storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable)); } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java index 4b3e0e2..20bdd5d 100644 --- a/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java +++ b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java @@ -18,6 +18,7 @@ public class PaymentGroupDetailResponse { private Integer remainPoint; private String teamLeaderName; private String teamLeaderPhoneNum; + // TODO 이거 아니고, order 결제 내역으로 변경해야함. private Page historyResponses; public static PaymentGroupDetailResponse create(String teamName, Integer point, Integer remainPoint, diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index 961eaa0..58b9b41 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -79,11 +79,17 @@ public void createAdditionalInfo(CustomOAuthUser customOAuthUser, } @Transactional - public void updateStore(CustomOAuthUser customOAuth2User, Long storeId, - StoreUpdateRequestDTO storeUpdateRequestDTO) { - Store store = storeRepository.findById(storeId) - .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_STORE_ID)); - if (!store.getOwner().getUser().getProviderId().equals(customOAuth2User.getUserId())) { + public void updateStore(String userId, StoreUpdateRequestDTO storeUpdateRequestDTO) { + User user = userRepository.findByProviderId(userId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + if (!store.getOwner().getUser().getProviderId().equals(userId)) { throw new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION); } @@ -167,11 +173,8 @@ public Page getPaymentGroup(String userId, Pageable pageab return storeTeamRepository.findAllByStore(store, pageable); } - public Page searchByCategory(final Authentication authentication, - final Integer searchRadius, - final Category category, - final StoreSearchCondition storeSearchCondition, - final Pageable pageable) { + public Page searchByCategory(final Authentication authentication, final Integer searchRadius, + final Category category, final StoreSearchCondition storeSearchCondition, final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); @@ -180,8 +183,7 @@ public Page searchByCategory(final Authentication authenti } public Page searchStores(final Authentication authentication, final String keyword, - final StoreSearchConditionWithType storeSearchConditionWithType, - final Pageable pageable) { + final StoreSearchConditionWithType storeSearchConditionWithType, final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));