Skip to content

Commit

Permalink
Merge pull request #35 from Donut-DONationUTile/feature/history/giver
Browse files Browse the repository at this point in the history
Feat: 기부자 히스토리 필드 추가
  • Loading branch information
Ganghee-Lee-0522 authored Feb 18, 2024
2 parents a7c821e + 564c6eb commit 78c7dd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public class GiverDonationDetailResponseDto {
private Boolean isAssigned;
private Status status;
private String message;
private LocalDateTime donateDate;
}
16 changes: 9 additions & 7 deletions src/main/java/zero/eight/donut/service/HistoryGiverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ public class HistoryGiverService {

@Transactional
public ApiResponse<?> getDonationList(LocalDateTime donateDate){
log.info("기부자 검증 시작");
//기부자 여부 검증
if (!authUtils.getCurrentUserRole().equals(Role.ROLE_GIVER)) {
return ApiResponse.failure(Error.NOT_AUTHENTICATED_EXCEPTION);
}
Giver giver = authUtils.getGiver();
log.info("기부자 정보 확인 -> {}", giver.getName());

//기부한 기간 계산
Integer period = Period.between(giver.getCreatedAt().toLocalDate(), LocalDate.now()).getYears();
Expand All @@ -66,16 +68,15 @@ public ApiResponse<?> getDonationList(LocalDateTime donateDate){

//gift 개별 정보 가져오기
donationList.add(Donation.builder()
.giftId(gift.getId())
.product(gift.getProduct())
.price(gift.getPrice())
.dueDate(gift.getDueDate())
.status(gift.getStatus())
.isAssigned(gift.getIsAssigned())
.giftId(gift.getId())
.product(gift.getProduct())
.price(gift.getPrice())
.dueDate(gift.getDueDate())
.status(gift.getStatus())
.isAssigned(gift.getIsAssigned())
.build());
}


GiverDonationListResponseDto responseDto = GiverDonationListResponseDto.builder()
.period(period)
.totalAmount(totalAmount)
Expand Down Expand Up @@ -117,6 +118,7 @@ public ApiResponse<?> getDonationDetail(Long giftId){
.isAssigned(gift.getIsAssigned())
.status(gift.getStatus())
.message(message)
.donateDate(gift.getCreatedAt())
.build();

return ApiResponse.success(Success.GET_HISTORY_GIVER_DONATION_SUCCESS, responseDto);
Expand Down

0 comments on commit 78c7dd0

Please sign in to comment.