-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: 주점 결제 정보 CRUD 및 예외처리 추가 #105
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
10973be
feat(StorePayment): StorePayment 엔티티 생성
Jjiggu e28ed57
feat(StorePayment): StorePayment 엔드포인트 작성
Jjiggu fef6cf0
feat(StorePayment): StorePayment 엔드포인트 작성
Jjiggu 50e460e
feat(StorePayment): StorePaymentService 생성 및 StorePaymentServiceImpl …
Jjiggu eece165
feat(StorePayment): StorePaymentRepository 생성
Jjiggu 1ad00bc
feat(StorePayment): StorePaymentCreate 관련 Dto 생성
Jjiggu e4f66b9
feat(StorePayment): StorePaymentRead 관련 Dto 생성
Jjiggu 1fded2f
feat(StorePayment): StorePaymentUpdate 관련 Dto 생성
Jjiggu e022714
feat(StorePayment): StorePayment 에러 메시지 추가
Jjiggu 716dade
feat(StorePayment): StorePayment 예외 처리 추가
Jjiggu f4ea011
chore: 중복 파일 삭제
Jjiggu 7b81e4a
feat(StorePayment): 이미 존재하는 주점 결제 정보 확인
Jjiggu 66b012b
feat(StorePayment): 패키지 이름 변경
Jjiggu 3f3265f
feat(StorePayment): 이미 존재하는 주점 결제 정보 확인을 위한 예외처리 추가
Jjiggu f576d68
feat(StorePayment): 이미 존재하는 주점 결제 정보 확인을 위한 예외처리 추가
Jjiggu 71455db
feat(StorePayment): 패키지 이름 변경
Jjiggu 41d3068
feat(StorePayment): 패키지 이름 변경
Jjiggu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...main/java/com/nowait/applicationadmin/storePayment/controller/StorePaymentController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package com.nowait.applicationadmin.storePayment.controller; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateRequest; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateResponse; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentUpdateRequest; | ||
| import com.nowait.applicationadmin.storePayment.service.StorePaymentService; | ||
| import com.nowait.common.api.ApiUtils; | ||
| import com.nowait.domaincorerdb.user.entity.MemberDetails; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Tag(name = "Store Payment API", description = "주점 결제 정보 API") | ||
| @RestController | ||
| @RequestMapping("admin/store-payments") | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class StorePaymentController { | ||
|
|
||
| private final StorePaymentService storePaymentService; | ||
|
|
||
| @PostMapping("/create") | ||
| @Operation(summary = "주점 결제 Url 등록 및 생성", description = "새로운 주점 결제 정보를 생성합니다.") | ||
| @ApiResponse(responseCode = "201", description = "주점 결제 정보 생성 성공") | ||
| public ResponseEntity<?> createStorePayment(@Valid @RequestBody StorePaymentCreateRequest request, @AuthenticationPrincipal MemberDetails memberDetails) { | ||
| StorePaymentCreateResponse response = storePaymentService.createStorePayment(request, memberDetails); | ||
|
|
||
| return ResponseEntity | ||
| .status(HttpStatus.CREATED) | ||
| .body( | ||
| ApiUtils.success( | ||
| response | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @GetMapping() | ||
| @Operation(summary = "주점 결제 정보 조회", description = "인증된 사용자의 주점 결제 정보를 조회합니다.") | ||
| @ApiResponse(responseCode = "200", description = "주점 결제 정보 조회 성공") | ||
| public ResponseEntity<?> getStorePaymentByStoreId(@AuthenticationPrincipal MemberDetails memberDetails) { | ||
| return ResponseEntity | ||
| .status(HttpStatus.OK) | ||
| .body( | ||
| ApiUtils.success( | ||
| storePaymentService.getStorePaymentByStoreId(memberDetails) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @PatchMapping("/update") | ||
| @Operation(summary = "주점 결제 정보 수정", description = "주점 결제 정보를 수정합니다.") | ||
| @ApiResponse(responseCode = "200", description = "주점 결제 정보 수정 성공") | ||
| public ResponseEntity<?> updateStorePayment(@RequestBody StorePaymentUpdateRequest request, @AuthenticationPrincipal MemberDetails memberDetails) { | ||
| return ResponseEntity | ||
| .status(HttpStatus.OK) | ||
| .body( | ||
| ApiUtils.success( | ||
| storePaymentService.updateStorePayment(request, memberDetails) | ||
| ) | ||
| ); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
...src/main/java/com/nowait/applicationadmin/storePayment/dto/StorePaymentCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.nowait.applicationadmin.storePayment.dto; | ||
|
|
||
| import com.nowait.domaincorerdb.storepayment.entity.StorePayment; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class StorePaymentCreateRequest { | ||
|
|
||
| private String tossUrl; | ||
| private String kakaoPayUrl; | ||
| private String naverPayUrl; | ||
|
|
||
| public StorePayment toEntity(Long storeId) { | ||
| return StorePayment.builder() | ||
| .storeId(storeId) | ||
| .tossUrl(tossUrl) | ||
| .kakaoPayUrl(kakaoPayUrl) | ||
| .naverPayUrl(naverPayUrl) | ||
| .build(); | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
...rc/main/java/com/nowait/applicationadmin/storePayment/dto/StorePaymentCreateResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.nowait.applicationadmin.storePayment.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.nowait.domaincorerdb.storepayment.entity.StorePayment; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class StorePaymentCreateResponse { | ||
|
|
||
| private Long paymentMethodId; | ||
| private Long storeId; | ||
| private String tossUrl; | ||
| private String kakaoPayUrl; | ||
| private String naverPayUrl; | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public static StorePaymentCreateResponse fromEntity(StorePayment storePayment) { | ||
| return StorePaymentCreateResponse.builder() | ||
| .paymentMethodId(storePayment.getPaymentMethodId()) | ||
| .storeId(storePayment.getStoreId()) | ||
| .tossUrl(storePayment.getTossUrl()) | ||
| .kakaoPayUrl(storePayment.getKakaoPayUrl()) | ||
| .naverPayUrl(storePayment.getNaverPayUrl()) | ||
| .createdAt(storePayment.getCreatedAt()) | ||
| .build(); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
...n-api/src/main/java/com/nowait/applicationadmin/storePayment/dto/StorePaymentReadDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.nowait.applicationadmin.storePayment.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.nowait.domaincorerdb.storepayment.entity.StorePayment; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class StorePaymentReadDto { | ||
| private Long paymentMethodId; | ||
| private Long storeId; | ||
| private String tossUrl; | ||
| private String kakaoPayUrl; | ||
| private String naverPayUrl; | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public static StorePaymentReadDto fromEntity(StorePayment storePayment) { | ||
| return StorePaymentReadDto.builder() | ||
| .paymentMethodId(storePayment.getPaymentMethodId()) | ||
| .storeId(storePayment.getStoreId()) | ||
| .tossUrl(storePayment.getTossUrl()) | ||
| .kakaoPayUrl(storePayment.getKakaoPayUrl()) | ||
| .naverPayUrl(storePayment.getNaverPayUrl()) | ||
| .createdAt(storePayment.getCreatedAt()) | ||
| .build(); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
...src/main/java/com/nowait/applicationadmin/storePayment/dto/StorePaymentUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.nowait.applicationadmin.storePayment.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| @Builder | ||
| public class StorePaymentUpdateRequest { | ||
| private String tossUrl; | ||
| private String kakaoPayUrl; | ||
| private String naverPayUrl; | ||
| } |
14 changes: 14 additions & 0 deletions
14
...i/src/main/java/com/nowait/applicationadmin/storePayment/service/StorePaymentService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.nowait.applicationadmin.storePayment.service; | ||
|
|
||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateRequest; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateResponse; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentReadDto; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentUpdateRequest; | ||
| import com.nowait.domaincorerdb.user.entity.MemberDetails; | ||
|
|
||
| public interface StorePaymentService { | ||
|
|
||
| StorePaymentCreateResponse createStorePayment(StorePaymentCreateRequest request, MemberDetails memberDetails); | ||
| StorePaymentReadDto getStorePaymentByStoreId(MemberDetails memberDetails); | ||
| StorePaymentReadDto updateStorePayment(StorePaymentUpdateRequest request, MemberDetails memberDetails); | ||
| } |
90 changes: 90 additions & 0 deletions
90
...c/main/java/com/nowait/applicationadmin/storePayment/service/StorePaymentServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package com.nowait.applicationadmin.storePayment.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateRequest; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentCreateResponse; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentReadDto; | ||
| import com.nowait.applicationadmin.storePayment.dto.StorePaymentUpdateRequest; | ||
| import com.nowait.common.enums.Role; | ||
| import com.nowait.domaincorerdb.storepayment.entity.StorePayment; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentAlreadyExistsException; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentCreationUnauthorizedException; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentNotFoundException; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentParamEmptyException; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentUpdateUnauthorizedException; | ||
| import com.nowait.domaincorerdb.storepayment.exception.StorePaymentViewUnauthorizedException; | ||
| import com.nowait.domaincorerdb.storepayment.repository.StorePaymentRepository; | ||
| import com.nowait.domaincorerdb.user.entity.MemberDetails; | ||
| import com.nowait.domaincorerdb.user.entity.User; | ||
| import com.nowait.domaincorerdb.user.exception.UserNotFoundException; | ||
| import com.nowait.domaincorerdb.user.repository.UserRepository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class StorePaymentServiceImpl implements StorePaymentService { | ||
|
|
||
| private final StorePaymentRepository storePaymentRepository; | ||
| private final UserRepository userRepository; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public StorePaymentCreateResponse createStorePayment(StorePaymentCreateRequest request, MemberDetails memberDetails) { | ||
| if (request == null) throw new StorePaymentParamEmptyException(); | ||
|
|
||
| User user = userRepository.findById(memberDetails.getId()).orElseThrow(UserNotFoundException::new); | ||
| Long storeId = user.getStoreId(); | ||
| if (storePaymentRepository.findByStoreId(storeId).isPresent()) { | ||
| throw new StorePaymentAlreadyExistsException(); | ||
| } | ||
| if (!Role.SUPER_ADMIN.equals(user.getRole()) && !user.getStoreId().equals(storeId)) { | ||
| throw new StorePaymentCreationUnauthorizedException(); | ||
| } | ||
| StorePayment toSave = request.toEntity(storeId); | ||
| StorePayment saved = storePaymentRepository.save(toSave); | ||
|
|
||
| return StorePaymentCreateResponse.fromEntity(saved); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public StorePaymentReadDto getStorePaymentByStoreId(MemberDetails memberDetails) { | ||
| if (memberDetails == null) throw new StorePaymentParamEmptyException(); | ||
|
|
||
| User user = userRepository.findById(memberDetails.getId()).orElseThrow(UserNotFoundException::new); | ||
| Long storeId = user.getStoreId(); | ||
| if (!Role.SUPER_ADMIN.equals(user.getRole()) && !user.getStoreId().equals(storeId)) { | ||
| throw new StorePaymentViewUnauthorizedException(); | ||
|
Jjiggu marked this conversation as resolved.
|
||
| } | ||
| StorePayment storePayment = storePaymentRepository.findByStoreId(storeId) | ||
| .orElseThrow(StorePaymentNotFoundException::new); | ||
|
|
||
| return StorePaymentReadDto.fromEntity(storePayment); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public StorePaymentReadDto updateStorePayment(StorePaymentUpdateRequest request, MemberDetails memberDetails) { | ||
| if (request == null) throw new StorePaymentParamEmptyException(); | ||
|
|
||
| User user = userRepository.findById(memberDetails.getId()).orElseThrow(UserNotFoundException::new); | ||
| Long storeId = user.getStoreId(); | ||
| if (!Role.SUPER_ADMIN.equals(user.getRole()) && !user.getStoreId().equals(storeId)) { | ||
| throw new StorePaymentUpdateUnauthorizedException(); | ||
|
Jjiggu marked this conversation as resolved.
|
||
| } | ||
| StorePayment storePayment = storePaymentRepository.findByStoreId(storeId) | ||
| .orElseThrow(StorePaymentNotFoundException::new); | ||
|
|
||
| storePayment.updatePaymentMethodUrl( | ||
| request.getTossUrl(), | ||
| request.getKakaoPayUrl(), | ||
| request.getNaverPayUrl() | ||
| ); | ||
| storePaymentRepository.save(storePayment); | ||
|
|
||
| return StorePaymentReadDto.fromEntity(storePayment); | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
.../main/java/com/nowait/applicationuser/storepayment/controller/StorePaymentController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.nowait.applicationuser.storepayment.controller; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| 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; | ||
|
|
||
| import com.nowait.applicationuser.storepayment.service.StorePaymentService; | ||
| import com.nowait.common.api.ApiUtils; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Tag(name = "Store Payment API", description = "주점 결제 정보 API") | ||
| @RestController | ||
| @RequestMapping("v1/store-payments") | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class StorePaymentController { | ||
|
|
||
| private final StorePaymentService storePaymentService; | ||
|
|
||
| @GetMapping(("/{storeId}")) | ||
| @Operation(summary = "주점 결제 정보 조회", description = "주점 ID로 주점 결제 정보를 조회합니다.") | ||
| @ApiResponse(responseCode = "200", description = "주점 결제 정보 조회 성공") | ||
| public ResponseEntity<?> getStorePaymentByStoreId(@PathVariable Long storeId) { | ||
| return ResponseEntity | ||
| .status(HttpStatus.OK) | ||
| .body( | ||
| ApiUtils.success( | ||
| storePaymentService.getStorePaymentByStoreId(storeId) | ||
| ) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
결제 URL 필드들에 대한 검증이 필요합니다.
결제 URL 필드들이 null 값을 허용하는지 명확하지 않으며, 비즈니스 로직에 따라 필수 값일 수 있습니다.
다음과 같이 검증 어노테이션을 추가하는 것을 권장합니다:
또는 선택적 필드라면 명시적으로 문서화하거나 null 체크를 추가해야 합니다.
📝 Committable suggestion
🤖 Prompt for AI Agents