Skip to content

Commit

Permalink
Merge pull request #67 from Donut-DONationUTile/feature/wallet
Browse files Browse the repository at this point in the history
Feature/wallet
  • Loading branch information
Kang1221 authored Apr 28, 2024
2 parents cec44b5 + 5b3164e commit e8f7cbd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/main/java/zero/eight/donut/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public boolean isDuplicatedID(String id) {
return !receiverRepository.findByName(id).isEmpty();
}

@Transactional
public ApiResponse<?> receiverSignIn(AuthRequestDto requestDto) {

Optional<Receiver> receiver = receiverRepository.findByName(requestDto.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zero.eight.donut.common.response.ApiResponse;
import zero.eight.donut.config.jwt.AuthUtils;
import zero.eight.donut.domain.Benefit;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/zero/eight/donut/service/ReportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ReportService {
private final ReportRepository reportRepository;
private final GiftRepository giftRepository;
private final GiftboxRepository giftboxRepository;

@Transactional
public ApiResponse<?> createUsed(Long giftId){
//Gift 있는지 확인
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/zero/eight/donut/service/WalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import zero.eight.donut.domain.Giver;
import zero.eight.donut.domain.enums.Store;
import zero.eight.donut.dto.auth.Role;
import zero.eight.donut.dto.donation.DonateGiftRequestDto;
import zero.eight.donut.dto.home.receiver.GetGiftResponseDto;
import zero.eight.donut.dto.wallet.WalletGiftInfoResponseDto;
import zero.eight.donut.dto.wallet.WalletResponseDto;
import zero.eight.donut.dto.wallet.WalletUploadRequestDto;
Expand Down Expand Up @@ -45,10 +45,7 @@ public class WalletService {
private final ReceiverRepository receiverRepository;
private final GiftRepository giftRepository;
private final GiftboxRepository giftboxRepository;
private final HomeReceiverService homeReceiverService;

@Transactional
// 월렛 화면 조회
public ApiResponse<?> walletMain() {
// 변수 선언
LocalDateTime now = LocalDateTime.now(); // 조회 시각
Expand Down Expand Up @@ -141,9 +138,23 @@ public ApiResponse<?> walletDetail(Long giftId) {

Gift gift = giftOptional.get();

return ApiResponse.success(Success.HOME_RECEIVER_GIFT_SUCCESS, homeReceiverService.getGiftInfo(giftId, gift));
GetGiftResponseDto responseDto = GetGiftResponseDto.builder()
.product(gift.getProduct())
.price(gift.getPrice())
.dueDate(gift.getDueDate())
.imgUrl(gift.getImageUrl())
.store(gift.getStore())
.status(gift.getStatus())
.boxId(gift.getGiftbox().getId())
.build();

// 조회 시 일단 사용처리
gift.updateStatus("SELF_USED");

return ApiResponse.success(Success.HOME_RECEIVER_GIFT_SUCCESS, responseDto);
}

@Transactional
public ApiResponse<?> walletUpload(WalletUploadRequestDto requestDto) throws IOException {
// 기부자 여부 검증
if (!authUtils.getCurrentUserRole().equals(Role.ROLE_GIVER)) {
Expand Down

0 comments on commit e8f7cbd

Please sign in to comment.