From 959dc3bfb42562b9ed27d8d7d5d1f448625d2bb1 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:33:10 +0900 Subject: [PATCH 01/21] =?UTF-8?q?[#207]feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=99=98=EA=B8=89=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20request=20/=20response=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/dto/request/UserPointRefundRequestDto.java | 9 +++++++++ .../user/dto/response/UserPointRefundResponseDto.java | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java create mode 100644 src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java diff --git a/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java b/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java new file mode 100644 index 00000000..579da54d --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java @@ -0,0 +1,9 @@ +package bc1.gream.domain.user.dto.request; + +public record UserPointRefundRequestDto( + Long point, + String bank, + String accountNumber +) { + +} diff --git a/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java new file mode 100644 index 00000000..884ea883 --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java @@ -0,0 +1,7 @@ +package bc1.gream.domain.user.dto.response; + +public record UserPointRefundResponseDto( + Long point +) { + +} From 103864834403620fa365e37ec29aa42d32c5bfde Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:33:36 +0900 Subject: [PATCH 02/21] =?UTF-8?q?[#207]feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=99=98=EA=B8=89=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gream/domain/user/controller/UserController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/bc1/gream/domain/user/controller/UserController.java b/src/main/java/bc1/gream/domain/user/controller/UserController.java index 6a91eb7f..d61526c3 100644 --- a/src/main/java/bc1/gream/domain/user/controller/UserController.java +++ b/src/main/java/bc1/gream/domain/user/controller/UserController.java @@ -1,6 +1,8 @@ package bc1.gream.domain.user.controller; +import bc1.gream.domain.user.dto.request.UserPointRefundRequestDto; import bc1.gream.domain.user.dto.request.UserSignupRequestDto; +import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; import bc1.gream.domain.user.dto.response.UserPointResponseDto; import bc1.gream.domain.user.dto.response.UserSignupResponseDto; import bc1.gream.domain.user.service.UserService; @@ -38,4 +40,13 @@ public RestResponse pointsCheck(@AuthenticationPrincipal U UserPointResponseDto response = userService.pointsCheck(userDetails); return RestResponse.success(response); } + + @PostMapping("/points/refunds") + public RestResponse refundsPoint( + @AuthenticationPrincipal UserDetailsImpl userDetails, + @RequestBody UserPointRefundRequestDto requestDto + ) { + UserPointRefundResponseDto responseDto = userService.refundsPoint(userDetails.getUser(), requestDto); + return RestResponse.success(responseDto); + } } From bdb7b13c1de941287c1188cc3391b207fc0b135e Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:34:04 +0900 Subject: [PATCH 03/21] =?UTF-8?q?[#207]feat:=20=ED=99=98=EA=B8=89=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20repository=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gream/domain/user/repository/RefundRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/user/repository/RefundRepository.java diff --git a/src/main/java/bc1/gream/domain/user/repository/RefundRepository.java b/src/main/java/bc1/gream/domain/user/repository/RefundRepository.java new file mode 100644 index 00000000..3888b688 --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/repository/RefundRepository.java @@ -0,0 +1,8 @@ +package bc1.gream.domain.user.repository; + +import bc1.gream.domain.user.entity.Refund; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RefundRepository extends JpaRepository { + +} From e8b4dd46535f7b0a558656e2d6ca43ffcc7177e9 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:34:25 +0900 Subject: [PATCH 04/21] =?UTF-8?q?[#207]feat:=20=ED=99=98=EA=B8=89=20respon?= =?UTF-8?q?seDto=20Mapper=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gream/domain/user/mapper/RefundMapper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java diff --git a/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java b/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java new file mode 100644 index 00000000..ab34b275 --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java @@ -0,0 +1,15 @@ +package bc1.gream.domain.user.mapper; + +import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; +import bc1.gream.domain.user.entity.Refund; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface RefundMapper { + + RefundMapper INSTANCE = Mappers.getMapper(RefundMapper.class); + + UserPointRefundResponseDto toUserPointRefundResponseDto(Refund refund); + +} From 741a0bb283fda0147fdcfc07c7348926c5d317e9 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:35:00 +0900 Subject: [PATCH 05/21] =?UTF-8?q?[#207]refactor:=20=EA=B8=B0=ED=94=84?= =?UTF-8?q?=ED=8B=B0=EC=BD=98=20=EA=B5=AC=EB=A7=A4=20=ED=8C=90=EB=A7=A4=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=EC=A0=95=EB=A0=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gifticon/repository/GifticonRepositoryCustomImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/bc1/gream/domain/gifticon/repository/GifticonRepositoryCustomImpl.java b/src/main/java/bc1/gream/domain/gifticon/repository/GifticonRepositoryCustomImpl.java index 7e040619..210ac9da 100644 --- a/src/main/java/bc1/gream/domain/gifticon/repository/GifticonRepositoryCustomImpl.java +++ b/src/main/java/bc1/gream/domain/gifticon/repository/GifticonRepositoryCustomImpl.java @@ -19,6 +19,7 @@ public List findAllSoldBySeller(User user) { .selectFrom(QGifticon.gifticon) .leftJoin(QGifticon.gifticon.order, QOrder.order) .where(QGifticon.gifticon.order.seller.eq(user)) + .orderBy(QGifticon.gifticon.modifiedAt.desc()) .fetch(); } @@ -28,6 +29,7 @@ public List findAllBoughtByBuyer(User user) { .selectFrom(QGifticon.gifticon) .leftJoin(QGifticon.gifticon.order, QOrder.order) .where(QGifticon.gifticon.order.buyer.eq(user)) + .orderBy(QGifticon.gifticon.modifiedAt.desc()) .fetch(); } } From dd5e1dd14a2a07f1b0ef34a05118f0c6436aa3db Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:35:34 +0900 Subject: [PATCH 06/21] =?UTF-8?q?[#207]feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=99=98=EA=B8=89=20=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=20=EC=84=9C=EB=B9=84=EC=8A=A4=20api=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/service/UserService.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/bc1/gream/domain/user/service/UserService.java b/src/main/java/bc1/gream/domain/user/service/UserService.java index d193f6dd..804a1447 100644 --- a/src/main/java/bc1/gream/domain/user/service/UserService.java +++ b/src/main/java/bc1/gream/domain/user/service/UserService.java @@ -1,12 +1,17 @@ package bc1.gream.domain.user.service; +import bc1.gream.domain.user.dto.request.UserPointRefundRequestDto; import bc1.gream.domain.user.dto.request.UserSignupRequestDto; +import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; import bc1.gream.domain.user.dto.response.UserPointResponseDto; import bc1.gream.domain.user.dto.response.UserSignupResponseDto; import bc1.gream.domain.user.entity.Provider; +import bc1.gream.domain.user.entity.Refund; import bc1.gream.domain.user.entity.User; import bc1.gream.domain.user.entity.UserRole; +import bc1.gream.domain.user.mapper.RefundMapper; import bc1.gream.domain.user.mapper.UserMapper; +import bc1.gream.domain.user.repository.RefundRepository; import bc1.gream.domain.user.repository.UserRepository; import bc1.gream.global.common.ResultCase; import bc1.gream.global.exception.GlobalException; @@ -21,6 +26,7 @@ public class UserService { private final UserRepository userRepository; + private final RefundRepository refundRepository; private final PasswordEncoder passwordEncoder; @@ -56,4 +62,33 @@ private void validateExistingUser(UserSignupRequestDto request) { throw new GlobalException(ResultCase.DUPLICATED_NICKNAME); } } + + public User findUser(String loginId) { + User user = userRepository.findByLoginId(loginId).orElseThrow( + () -> new GlobalException(ResultCase.USER_NOT_FOUND) + ); + + return user; + } + + public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequestDto requestDto) { + User findUser = findUser(user.getLoginId()); + + Refund refund = Refund.builder() + .point(requestDto.point()) + .bank(requestDto.bank()) + .accountNumber(requestDto.accountNumber()) + .user(findUser) + .build(); + + Refund savedRefund = refundRepository.save(refund); + + return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund); + } + + public Refund findRefund(Long refundId) { + return refundRepository.findById(refundId).orElseThrow( + () -> new GlobalException(ResultCase.REFUND_NOT_FOUND) + ); + } } From ebb742068a397c7f640670161e015bc82d8c58b6 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:51:03 +0900 Subject: [PATCH 07/21] =?UTF-8?q?[#207]fix:=20=EC=9C=A0=EC=A0=80=EA=B0=80?= =?UTF-8?q?=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=99=98=EA=B8=89=20=EC=8B=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EA=B0=90?= =?UTF-8?q?=EC=86=8C=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bc1/gream/domain/user/service/UserService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/bc1/gream/domain/user/service/UserService.java b/src/main/java/bc1/gream/domain/user/service/UserService.java index 804a1447..42594cac 100644 --- a/src/main/java/bc1/gream/domain/user/service/UserService.java +++ b/src/main/java/bc1/gream/domain/user/service/UserService.java @@ -71,6 +71,7 @@ public User findUser(String loginId) { return user; } + @Transactional public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequestDto requestDto) { User findUser = findUser(user.getLoginId()); @@ -81,9 +82,11 @@ public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequest .user(findUser) .build(); + findUser.decreasePoint(requestDto.point()); + Refund savedRefund = refundRepository.save(refund); - return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund); + return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund, findUser); } public Refund findRefund(Long refundId) { From 65570c70a947dc32a8fdcd965291fb6e75e45f88 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:51:28 +0900 Subject: [PATCH 08/21] =?UTF-8?q?[#207]fix:=20=EC=9C=A0=EC=A0=80=EA=B0=80?= =?UTF-8?q?=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=99=98=EA=B8=89=20=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C=20=ED=99=98=EA=B8=89=20=EC=8B=A0=EC=B2=AD?= =?UTF-8?q?=ED=95=9C=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=EC=99=80=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=9E=94=EC=97=AC=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=ED=95=A0=20=EC=88=98=20=EC=9E=88=EA=B2=8C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/dto/response/UserPointRefundResponseDto.java | 3 ++- .../java/bc1/gream/domain/user/mapper/RefundMapper.java | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java index 884ea883..062c9e6a 100644 --- a/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java +++ b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java @@ -1,7 +1,8 @@ package bc1.gream.domain.user.dto.response; public record UserPointRefundResponseDto( - Long point + Long refundPoint, + Long userPoint ) { } diff --git a/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java b/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java index ab34b275..bdaeb2df 100644 --- a/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java +++ b/src/main/java/bc1/gream/domain/user/mapper/RefundMapper.java @@ -2,7 +2,9 @@ import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; import bc1.gream.domain.user.entity.Refund; +import bc1.gream.domain.user.entity.User; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @Mapper @@ -10,6 +12,8 @@ public interface RefundMapper { RefundMapper INSTANCE = Mappers.getMapper(RefundMapper.class); - UserPointRefundResponseDto toUserPointRefundResponseDto(Refund refund); + @Mapping(expression = "java(refund.getPoint())", target = "refundPoint") + @Mapping(expression = "java(user.getPoint())", target = "userPoint") + UserPointRefundResponseDto toUserPointRefundResponseDto(Refund refund, User user); } From 4419d7e9a9c7e019d18c8ae012d25a133f625977 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:57:15 +0900 Subject: [PATCH 09/21] =?UTF-8?q?[#207]feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=99=98=EA=B8=89=20=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?ResultCase=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bc1/gream/global/common/ResultCase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/bc1/gream/global/common/ResultCase.java b/src/main/java/bc1/gream/global/common/ResultCase.java index b3faabfb..fcf2152a 100644 --- a/src/main/java/bc1/gream/global/common/ResultCase.java +++ b/src/main/java/bc1/gream/global/common/ResultCase.java @@ -27,6 +27,7 @@ public enum ResultCase { // 만료된 리프레쉬 토큰 401 EXPIRED_REFRESH_TOKEN(HttpStatus.UNAUTHORIZED, 1006, "만료된 Refresh Token"), NOT_ENOUGH_POINT(HttpStatus.FORBIDDEN, 1007, "유저의 포인트가 부족합니다"), + REFUND_NOT_FOUND(HttpStatus.NOT_FOUND, 1008, "환급 정보가 없습니다."), // 상품 2000번대 // 검색 결과 없음 404 From 0b6a08bdbfa6ba51883d012f25cd7a41bb6d9fc7 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:02:54 +0900 Subject: [PATCH 10/21] =?UTF-8?q?[#208]feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EC=9C=A0=EC=A0=80=20=ED=99=98=EA=B8=89=20=ED=86=B5?= =?UTF-8?q?=EA=B3=BC=EC=8B=9C=ED=82=A4=EB=8A=94=20response=20/=20request?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/dto/request/AdminRefundPassResponseDto.java | 8 ++++++++ .../admin/dto/response/AdminRefundPassRequestDto.java | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/admin/dto/request/AdminRefundPassResponseDto.java create mode 100644 src/main/java/bc1/gream/domain/admin/dto/response/AdminRefundPassRequestDto.java diff --git a/src/main/java/bc1/gream/domain/admin/dto/request/AdminRefundPassResponseDto.java b/src/main/java/bc1/gream/domain/admin/dto/request/AdminRefundPassResponseDto.java new file mode 100644 index 00000000..7645c85c --- /dev/null +++ b/src/main/java/bc1/gream/domain/admin/dto/request/AdminRefundPassResponseDto.java @@ -0,0 +1,8 @@ +package bc1.gream.domain.admin.dto.request; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties +public record AdminRefundPassResponseDto() { + +} diff --git a/src/main/java/bc1/gream/domain/admin/dto/response/AdminRefundPassRequestDto.java b/src/main/java/bc1/gream/domain/admin/dto/response/AdminRefundPassRequestDto.java new file mode 100644 index 00000000..0098fbbe --- /dev/null +++ b/src/main/java/bc1/gream/domain/admin/dto/response/AdminRefundPassRequestDto.java @@ -0,0 +1,8 @@ +package bc1.gream.domain.admin.dto.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties +public record AdminRefundPassRequestDto() { + +} From f381e098d0e9b79f5743462d8ac0487697380b70 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:03:08 +0900 Subject: [PATCH 11/21] =?UTF-8?q?[#208]feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EC=9C=A0=EC=A0=80=20=ED=99=98=EA=B8=89=20=ED=86=B5?= =?UTF-8?q?=EA=B3=BC=EC=8B=9C=ED=82=A4=EB=8A=94=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/AdminController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/admin/controller/AdminController.java diff --git a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java new file mode 100644 index 00000000..42d59d1a --- /dev/null +++ b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java @@ -0,0 +1,30 @@ +package bc1.gream.domain.admin.controller; + +import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; +import bc1.gream.domain.admin.service.AdminService; +import bc1.gream.global.common.RestResponse; +import bc1.gream.global.security.UserDetailsImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/admin") +public class AdminController { + + private final AdminService adminService; + + @DeleteMapping("/refund/{id}") + public RestResponse refundPass( + @AuthenticationPrincipal UserDetailsImpl userDetails, + @PathVariable Long id + ) { + AdminRefundPassResponseDto responseDto = adminService.refundPass(userDetails.getUser(), id); + + return RestResponse.success(responseDto); + } +} From 90d663ee82fccbc1585ae36fa358f0eeed0ad529 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:03:17 +0900 Subject: [PATCH 12/21] =?UTF-8?q?[#208]feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EC=9C=A0=EC=A0=80=20=ED=99=98=EA=B8=89=20=ED=86=B5?= =?UTF-8?q?=EA=B3=BC=EC=8B=9C=ED=82=A4=EB=8A=94=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/service/AdminService.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/admin/service/AdminService.java diff --git a/src/main/java/bc1/gream/domain/admin/service/AdminService.java b/src/main/java/bc1/gream/domain/admin/service/AdminService.java new file mode 100644 index 00000000..b60c1b89 --- /dev/null +++ b/src/main/java/bc1/gream/domain/admin/service/AdminService.java @@ -0,0 +1,45 @@ +package bc1.gream.domain.admin.service; + +import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; +import bc1.gream.domain.user.entity.Refund; +import bc1.gream.domain.user.entity.User; +import bc1.gream.domain.user.entity.UserRole; +import bc1.gream.domain.user.repository.RefundRepository; +import bc1.gream.domain.user.service.UserService; +import bc1.gream.global.common.ResultCase; +import bc1.gream.global.exception.GlobalException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class AdminService { + + private final UserService userService; + private final RefundRepository refundRepository; + + public AdminRefundPassResponseDto refundPass(User user, Long refundId) { + + User AdminUser = checkUser(user.getLoginId()); + + Refund refund = userService.findRefund(refundId); + + refundRepository.delete(refund); + + return new AdminRefundPassResponseDto(); + } + + private User checkUser(String loginId) { + User user = userService.findUser(loginId); + + if (isAdmin(user)) { + return user; + } + + throw new GlobalException(ResultCase.NOT_AUTHORIZED); + } + + private boolean isAdmin(User user) { + return user.getRole().equals(UserRole.ADMIN); + } +} From aa862c1426b8485c3b93e5e872906a577423e284 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:58:39 +0900 Subject: [PATCH 13/21] =?UTF-8?q?[#208]refactor:=20Swagger=20Doc=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bc1/gream/domain/admin/controller/AdminController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java index 42d59d1a..6a2bc893 100644 --- a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java +++ b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java @@ -3,9 +3,8 @@ import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; import bc1.gream.domain.admin.service.AdminService; import bc1.gream.global.common.RestResponse; -import bc1.gream.global.security.UserDetailsImpl; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; -import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,11 +18,11 @@ public class AdminController { private final AdminService adminService; @DeleteMapping("/refund/{id}") + @Operation(summary = "유저 환급 승인", description = "유저가 신청한 환급 요청을 승인해주는 기능입니다.") public RestResponse refundPass( - @AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable Long id ) { - AdminRefundPassResponseDto responseDto = adminService.refundPass(userDetails.getUser(), id); + AdminRefundPassResponseDto responseDto = adminService.refundPass(id); return RestResponse.success(responseDto); } From f93d6f6a3ce0668c7259da8f2b00342dfda80b05 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:59:16 +0900 Subject: [PATCH 14/21] =?UTF-8?q?[#208]refactor:=20security=20filter=20?= =?UTF-8?q?=EB=8B=A8=EC=97=90=EC=84=9C=20admin=20=EA=B6=8C=ED=95=9C?= =?UTF-8?q?=EC=9D=84=20=ED=99=95=EC=9D=B8=ED=95=98=EA=B8=B0=20=EB=95=8C?= =?UTF-8?q?=EB=AC=B8=EC=97=90=20=EC=9C=A0=EC=A0=80=20=EC=96=B4=EB=93=9C?= =?UTF-8?q?=EB=AF=BC=20=EC=9C=A0=EC=A0=80=20=EC=B2=B4=ED=81=AC=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/service/AdminService.java | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/main/java/bc1/gream/domain/admin/service/AdminService.java b/src/main/java/bc1/gream/domain/admin/service/AdminService.java index b60c1b89..c95847c1 100644 --- a/src/main/java/bc1/gream/domain/admin/service/AdminService.java +++ b/src/main/java/bc1/gream/domain/admin/service/AdminService.java @@ -2,12 +2,8 @@ import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; import bc1.gream.domain.user.entity.Refund; -import bc1.gream.domain.user.entity.User; -import bc1.gream.domain.user.entity.UserRole; import bc1.gream.domain.user.repository.RefundRepository; import bc1.gream.domain.user.service.UserService; -import bc1.gream.global.common.ResultCase; -import bc1.gream.global.exception.GlobalException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -18,9 +14,7 @@ public class AdminService { private final UserService userService; private final RefundRepository refundRepository; - public AdminRefundPassResponseDto refundPass(User user, Long refundId) { - - User AdminUser = checkUser(user.getLoginId()); + public AdminRefundPassResponseDto refundPass(Long refundId) { Refund refund = userService.findRefund(refundId); @@ -28,18 +22,4 @@ public AdminRefundPassResponseDto refundPass(User user, Long refundId) { return new AdminRefundPassResponseDto(); } - - private User checkUser(String loginId) { - User user = userService.findUser(loginId); - - if (isAdmin(user)) { - return user; - } - - throw new GlobalException(ResultCase.NOT_AUTHORIZED); - } - - private boolean isAdmin(User user) { - return user.getRole().equals(UserRole.ADMIN); - } } From fb8390091e71737f74e35b1bb50b1e5389505a94 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:03:47 +0900 Subject: [PATCH 15/21] =?UTF-8?q?[#208]refactor:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bc1/gream/domain/admin/controller/AdminController.java | 4 ++-- .../java/bc1/gream/domain/admin/service/AdminService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java index 6a2bc893..942f18c8 100644 --- a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java +++ b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java @@ -19,10 +19,10 @@ public class AdminController { @DeleteMapping("/refund/{id}") @Operation(summary = "유저 환급 승인", description = "유저가 신청한 환급 요청을 승인해주는 기능입니다.") - public RestResponse refundPass( + public RestResponse approveRefund( @PathVariable Long id ) { - AdminRefundPassResponseDto responseDto = adminService.refundPass(id); + AdminRefundPassResponseDto responseDto = adminService.approveRefund(id); return RestResponse.success(responseDto); } diff --git a/src/main/java/bc1/gream/domain/admin/service/AdminService.java b/src/main/java/bc1/gream/domain/admin/service/AdminService.java index c95847c1..2a02b57e 100644 --- a/src/main/java/bc1/gream/domain/admin/service/AdminService.java +++ b/src/main/java/bc1/gream/domain/admin/service/AdminService.java @@ -14,7 +14,7 @@ public class AdminService { private final UserService userService; private final RefundRepository refundRepository; - public AdminRefundPassResponseDto refundPass(Long refundId) { + public AdminRefundPassResponseDto approveRefund(Long refundId) { Refund refund = userService.findRefund(refundId); From 481409bcffea1d23a40669baa1772c79abc67954 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:01:42 +0900 Subject: [PATCH 16/21] =?UTF-8?q?[#207]refactor:=20@Builder=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/dto/request/UserPointRefundRequestDto.java | 3 +++ .../domain/user/dto/response/UserPointRefundResponseDto.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java b/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java index 579da54d..03f4805d 100644 --- a/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java +++ b/src/main/java/bc1/gream/domain/user/dto/request/UserPointRefundRequestDto.java @@ -1,5 +1,8 @@ package bc1.gream.domain.user.dto.request; +import lombok.Builder; + +@Builder // 테스트용 public record UserPointRefundRequestDto( Long point, String bank, diff --git a/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java index 062c9e6a..858132cc 100644 --- a/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java +++ b/src/main/java/bc1/gream/domain/user/dto/response/UserPointRefundResponseDto.java @@ -1,5 +1,8 @@ package bc1.gream.domain.user.dto.response; +import lombok.Builder; + +@Builder public record UserPointRefundResponseDto( Long refundPoint, Long userPoint From 964094e43a909909f2ea3dc9eb8bade68a13a220 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:11:44 +0900 Subject: [PATCH 17/21] =?UTF-8?q?[#207]refactor:=20RefundService=EB=A1=9C?= =?UTF-8?q?=20=ED=99=98=EA=B8=89=20=EA=B4=80=EB=A0=A8=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 5 +++- .../domain/user/service/UserService.java | 27 ------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/main/java/bc1/gream/domain/user/controller/UserController.java b/src/main/java/bc1/gream/domain/user/controller/UserController.java index d61526c3..09400547 100644 --- a/src/main/java/bc1/gream/domain/user/controller/UserController.java +++ b/src/main/java/bc1/gream/domain/user/controller/UserController.java @@ -6,6 +6,7 @@ import bc1.gream.domain.user.dto.response.UserPointResponseDto; import bc1.gream.domain.user.dto.response.UserSignupResponseDto; import bc1.gream.domain.user.service.UserService; +import bc1.gream.domain.user.service.command.RefundCommandService; import bc1.gream.global.common.RestResponse; import bc1.gream.global.security.UserDetailsImpl; import io.swagger.v3.oas.annotations.Operation; @@ -25,6 +26,7 @@ public class UserController { private final UserService userService; + private final RefundCommandService refundCommandService; @PostMapping("/signup") @SecurityRequirements() // Swagger Security 적용 X @@ -42,11 +44,12 @@ public RestResponse pointsCheck(@AuthenticationPrincipal U } @PostMapping("/points/refunds") + @Operation(summary = "사용자 포인트 환급 요청", description = "사용자의 포인트에 대한 환급요청을 처리합니다.") public RestResponse refundsPoint( @AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody UserPointRefundRequestDto requestDto ) { - UserPointRefundResponseDto responseDto = userService.refundsPoint(userDetails.getUser(), requestDto); + UserPointRefundResponseDto responseDto = refundCommandService.refundsPoint(userDetails.getUser(), requestDto); return RestResponse.success(responseDto); } } diff --git a/src/main/java/bc1/gream/domain/user/service/UserService.java b/src/main/java/bc1/gream/domain/user/service/UserService.java index 42594cac..74db58f8 100644 --- a/src/main/java/bc1/gream/domain/user/service/UserService.java +++ b/src/main/java/bc1/gream/domain/user/service/UserService.java @@ -1,15 +1,11 @@ package bc1.gream.domain.user.service; -import bc1.gream.domain.user.dto.request.UserPointRefundRequestDto; import bc1.gream.domain.user.dto.request.UserSignupRequestDto; -import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; import bc1.gream.domain.user.dto.response.UserPointResponseDto; import bc1.gream.domain.user.dto.response.UserSignupResponseDto; import bc1.gream.domain.user.entity.Provider; -import bc1.gream.domain.user.entity.Refund; import bc1.gream.domain.user.entity.User; import bc1.gream.domain.user.entity.UserRole; -import bc1.gream.domain.user.mapper.RefundMapper; import bc1.gream.domain.user.mapper.UserMapper; import bc1.gream.domain.user.repository.RefundRepository; import bc1.gream.domain.user.repository.UserRepository; @@ -71,27 +67,4 @@ public User findUser(String loginId) { return user; } - @Transactional - public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequestDto requestDto) { - User findUser = findUser(user.getLoginId()); - - Refund refund = Refund.builder() - .point(requestDto.point()) - .bank(requestDto.bank()) - .accountNumber(requestDto.accountNumber()) - .user(findUser) - .build(); - - findUser.decreasePoint(requestDto.point()); - - Refund savedRefund = refundRepository.save(refund); - - return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund, findUser); - } - - public Refund findRefund(Long refundId) { - return refundRepository.findById(refundId).orElseThrow( - () -> new GlobalException(ResultCase.REFUND_NOT_FOUND) - ); - } } From 7b7f38f53f91ba8dd4fae0265bf271041784ea0b Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:12:09 +0900 Subject: [PATCH 18/21] =?UTF-8?q?[#207]refactor:=20RefundService=EB=A5=BC?= =?UTF-8?q?=20query=EC=99=80=20command=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/command/RefundCommandService.java | 39 +++++++++++++++++++ .../service/query/RefundQueryService.java | 24 ++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java create mode 100644 src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java diff --git a/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java b/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java new file mode 100644 index 00000000..15dd5a61 --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java @@ -0,0 +1,39 @@ +package bc1.gream.domain.user.service.command; + +import bc1.gream.domain.user.dto.request.UserPointRefundRequestDto; +import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; +import bc1.gream.domain.user.entity.Refund; +import bc1.gream.domain.user.entity.User; +import bc1.gream.domain.user.mapper.RefundMapper; +import bc1.gream.domain.user.repository.RefundRepository; +import bc1.gream.domain.user.service.UserService; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class RefundCommandService { + + private final RefundRepository refundRepository; + private final UserService userService; + + @Transactional + public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequestDto requestDto) { + User findUser = userService.findUser(user.getLoginId()); + + Refund refund = Refund.builder() + .point(requestDto.point()) + .bank(requestDto.bank()) + .accountNumber(requestDto.accountNumber()) + .user(findUser) + .build(); + + findUser.decreasePoint(requestDto.point()); + + Refund savedRefund = refundRepository.save(refund); + + return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund, findUser); + } + +} diff --git a/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java b/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java new file mode 100644 index 00000000..b682f464 --- /dev/null +++ b/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java @@ -0,0 +1,24 @@ +package bc1.gream.domain.user.service.query; + +import bc1.gream.domain.user.entity.Refund; +import bc1.gream.domain.user.repository.RefundRepository; +import bc1.gream.global.common.ResultCase; +import bc1.gream.global.exception.GlobalException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class RefundQueryService { + + private final RefundRepository refundRepository; + + public Refund findRefund(Long refundId) { + return refundRepository.findById(refundId).orElseThrow( + () -> new GlobalException(ResultCase.REFUND_NOT_FOUND) + ); + } + +} From 868f62da338eab58f67d1caf2756234bc63a98e7 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:25:23 +0900 Subject: [PATCH 19/21] =?UTF-8?q?[#208]remove:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/service/AdminService.java | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 src/main/java/bc1/gream/domain/admin/service/AdminService.java diff --git a/src/main/java/bc1/gream/domain/admin/service/AdminService.java b/src/main/java/bc1/gream/domain/admin/service/AdminService.java deleted file mode 100644 index 2a02b57e..00000000 --- a/src/main/java/bc1/gream/domain/admin/service/AdminService.java +++ /dev/null @@ -1,25 +0,0 @@ -package bc1.gream.domain.admin.service; - -import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; -import bc1.gream.domain.user.entity.Refund; -import bc1.gream.domain.user.repository.RefundRepository; -import bc1.gream.domain.user.service.UserService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class AdminService { - - private final UserService userService; - private final RefundRepository refundRepository; - - public AdminRefundPassResponseDto approveRefund(Long refundId) { - - Refund refund = userService.findRefund(refundId); - - refundRepository.delete(refund); - - return new AdminRefundPassResponseDto(); - } -} From a7acc30a9fa51a0b00bb99ae13efddd65ba9267f Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:25:43 +0900 Subject: [PATCH 20/21] =?UTF-8?q?[#208]refactor:=20admin=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=EC=97=90=EC=84=9C=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=A0=20=EC=88=98=20=EC=9E=88=EA=B2=8C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/controller/AdminController.java | 6 +++--- .../user/service/command/RefundCommandService.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java index 942f18c8..5785c005 100644 --- a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java +++ b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java @@ -1,7 +1,7 @@ package bc1.gream.domain.admin.controller; import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; -import bc1.gream.domain.admin.service.AdminService; +import bc1.gream.domain.user.service.command.RefundCommandService; import bc1.gream.global.common.RestResponse; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -15,14 +15,14 @@ @RequestMapping("/api/admin") public class AdminController { - private final AdminService adminService; + private final RefundCommandService refundCommandService; @DeleteMapping("/refund/{id}") @Operation(summary = "유저 환급 승인", description = "유저가 신청한 환급 요청을 승인해주는 기능입니다.") public RestResponse approveRefund( @PathVariable Long id ) { - AdminRefundPassResponseDto responseDto = adminService.approveRefund(id); + AdminRefundPassResponseDto responseDto = refundCommandService.approveRefund(id); return RestResponse.success(responseDto); } diff --git a/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java b/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java index 15dd5a61..e327f146 100644 --- a/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java +++ b/src/main/java/bc1/gream/domain/user/service/command/RefundCommandService.java @@ -1,5 +1,6 @@ package bc1.gream.domain.user.service.command; +import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; import bc1.gream.domain.user.dto.request.UserPointRefundRequestDto; import bc1.gream.domain.user.dto.response.UserPointRefundResponseDto; import bc1.gream.domain.user.entity.Refund; @@ -7,15 +8,17 @@ import bc1.gream.domain.user.mapper.RefundMapper; import bc1.gream.domain.user.repository.RefundRepository; import bc1.gream.domain.user.service.UserService; -import jakarta.transaction.Transactional; +import bc1.gream.domain.user.service.query.RefundQueryService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class RefundCommandService { private final RefundRepository refundRepository; + private final RefundQueryService refundQueryService; private final UserService userService; @Transactional @@ -36,4 +39,12 @@ public UserPointRefundResponseDto refundsPoint(User user, UserPointRefundRequest return RefundMapper.INSTANCE.toUserPointRefundResponseDto(savedRefund, findUser); } + @Transactional + public AdminRefundPassResponseDto approveRefund(Long id) { + Refund refund = refundQueryService.findRefund(id); + + refundRepository.delete(refund); + + return new AdminRefundPassResponseDto(); + } } From 85ba5af1133af1da12c77ee39b62594097322c61 Mon Sep 17 00:00:00 2001 From: Mayst <48579987+Mayst1232@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:45:04 +0900 Subject: [PATCH 21/21] =?UTF-8?q?[#208]refactor:=20merge=20=EC=A0=84=20con?= =?UTF-8?q?flict=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/controller/AdminController.java | 16 ++++++---------- .../user/service/query/RefundQueryService.java | 4 ++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java index 20f56cfd..ded6d264 100644 --- a/src/main/java/bc1/gream/domain/admin/controller/AdminController.java +++ b/src/main/java/bc1/gream/domain/admin/controller/AdminController.java @@ -3,25 +3,22 @@ import bc1.gream.domain.admin.dto.request.AdminGetRefundRequestDto; import bc1.gream.domain.admin.dto.request.AdminProductRequestDto; +import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; import bc1.gream.domain.admin.dto.response.AdminGetRefundResponseDto; import bc1.gream.domain.admin.dto.response.AdminProductResponseDto; import bc1.gream.domain.admin.mapper.RefundMapper; import bc1.gream.domain.product.service.query.ProductService; +import bc1.gream.domain.user.service.command.RefundCommandService; import bc1.gream.domain.user.service.query.RefundQueryService; import bc1.gream.global.common.RestResponse; import io.swagger.v3.oas.annotations.Operation; import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import bc1.gream.domain.admin.dto.request.AdminRefundPassResponseDto; -import bc1.gream.domain.user.service.command.RefundCommandService; -import bc1.gream.global.common.RestResponse; -import io.swagger.v3.oas.annotations.Operation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -30,9 +27,9 @@ @RequestMapping("/api/admin") public class AdminController { - private final ProductService productService; private final RefundQueryService refundQueryService; + private final RefundCommandService refundCommandService; @GetMapping("/refunds") @Operation(summary = "신청된 환급 리스트 조회 요청", description = "사용자가 신청한 환급 요청 리스트를 반환합니다.") @@ -44,7 +41,6 @@ public RestResponse> getRefunds(AdminGetRefundRe .toList(); return RestResponse.success(response); - } @PostMapping("/products") @@ -52,10 +48,10 @@ public RestResponse addProducts( @RequestBody AdminProductRequestDto adminProductRequestDto ) { productService.addProduct(adminProductRequestDto); + return RestResponse.success(new AdminProductResponseDto()); } - private final RefundCommandService refundCommandService; @DeleteMapping("/refund/{id}") @Operation(summary = "유저 환급 승인", description = "유저가 신청한 환급 요청을 승인해주는 기능입니다.") diff --git a/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java b/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java index cd52bdad..70c9777c 100644 --- a/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java +++ b/src/main/java/bc1/gream/domain/user/service/query/RefundQueryService.java @@ -22,6 +22,10 @@ public class RefundQueryService { public List getRefunds() { return refundRepository.findAll(); } + + /** + * 특정 id에 해당하는 환급 정보를 반환 + */ public Refund findRefund(Long refundId) { return refundRepository.findById(refundId).orElseThrow( () -> new GlobalException(ResultCase.REFUND_NOT_FOUND)