-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
befd8a0
commit 47f3478
Showing
8 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
### 4.1 전체 온기 통계 조회 | ||
// @no-log | ||
GET {{host_url}}/api/v1/onjung/summaries | ||
Authorization: Bearer {{access_token}} | ||
GET {{host_url}}/api/v1/onjungs/summaries | ||
Authorization: Bearer {{access_token}} | ||
|
||
### 4.2 후원 횟수 조회 | ||
// @no-log | ||
GET {{host_url}}/api/v1/onjungs/count | ||
Authorization: Bearer {{access_token}} | ||
|
19 changes: 18 additions & 1 deletion
19
...ain/java/com/daon/onjung/onjung/application/controller/query/OnjungQueryV1Controller.java
This file contains 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 |
---|---|---|
@@ -1,22 +1,39 @@ | ||
package com.daon.onjung.onjung.application.controller.query; | ||
|
||
import com.daon.onjung.core.annotation.security.AccountID; | ||
import com.daon.onjung.core.dto.ResponseDto; | ||
import com.daon.onjung.onjung.application.dto.response.ReadOnjungCountResponseDto; | ||
import com.daon.onjung.onjung.application.dto.response.ReadOnjungSummaryResponseDto; | ||
import com.daon.onjung.onjung.application.usecase.ReadOnjungCountUseCase; | ||
import com.daon.onjung.onjung.application.usecase.ReadOnjungSummaryUseCase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.UUID; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class OnjungQueryV1Controller { | ||
|
||
private final ReadOnjungSummaryUseCase readOnjungSummaryUseCase; | ||
private final ReadOnjungCountUseCase readOnjungCountUseCase; | ||
|
||
/** | ||
* 4.1 전체 온기 통계 조회하기 | ||
*/ | ||
@GetMapping("/api/v1/onjung/summaries") | ||
@GetMapping("/api/v1/onjungs/summaries") | ||
public ResponseDto<ReadOnjungSummaryResponseDto> readOnjungSummary() { | ||
return ResponseDto.ok(readOnjungSummaryUseCase.execute()); | ||
} | ||
|
||
/** | ||
* 4.2 후원 횟수 조회하기 | ||
*/ | ||
@GetMapping("/api/v1/onjungs/count") | ||
public ResponseDto<ReadOnjungCountResponseDto> readOnjungCount( | ||
@AccountID UUID accountId | ||
) { | ||
return ResponseDto.ok(readOnjungCountUseCase.execute(accountId)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...main/java/com/daon/onjung/onjung/application/dto/response/ReadOnjungCountResponseDto.java
This file contains 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,17 @@ | ||
package com.daon.onjung.onjung.application.dto.response; | ||
|
||
import com.daon.onjung.core.dto.SelfValidating; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
|
||
public class ReadOnjungCountResponseDto extends SelfValidating<ReadOnjungCountResponseDto> { | ||
|
||
@JsonProperty("total_onjung_count") | ||
private final Integer totalOnjungCount; | ||
|
||
@Builder | ||
public ReadOnjungCountResponseDto(Integer totalOnjungCount) { | ||
this.totalOnjungCount = totalOnjungCount; | ||
this.validateSelf(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/daon/onjung/onjung/application/service/ReadOnjungCountService.java
This file contains 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,64 @@ | ||
package com.daon.onjung.onjung.application.service; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.account.repository.mysql.UserRepository; | ||
import com.daon.onjung.core.exception.error.ErrorCode; | ||
import com.daon.onjung.core.exception.type.CommonException; | ||
import com.daon.onjung.onjung.application.dto.response.ReadOnjungCountResponseDto; | ||
import com.daon.onjung.onjung.application.usecase.ReadOnjungCountUseCase; | ||
import com.daon.onjung.onjung.domain.Donation; | ||
import com.daon.onjung.onjung.domain.Onjung; | ||
import com.daon.onjung.onjung.domain.Receipt; | ||
import com.daon.onjung.onjung.domain.Share; | ||
import com.daon.onjung.onjung.domain.service.OnjungService; | ||
import com.daon.onjung.onjung.repository.mysql.DonationRepository; | ||
import com.daon.onjung.onjung.repository.mysql.ReceiptRepository; | ||
import com.daon.onjung.onjung.repository.mysql.ShareRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReadOnjungCountService implements ReadOnjungCountUseCase { | ||
|
||
private final UserRepository userRepository; | ||
private final DonationRepository donationRepository; | ||
private final ReceiptRepository receiptRepository; | ||
private final ShareRepository shareRepository; | ||
|
||
private final OnjungService onjungService; | ||
|
||
@Override | ||
@Transactional(readOnly = true) | ||
public ReadOnjungCountResponseDto execute( | ||
UUID accountId | ||
) { | ||
|
||
// User 조회 | ||
User user = userRepository.findById(accountId) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_RESOURCE)); | ||
|
||
// User의 모든 동참 내역 조회 | ||
List<Donation> donations = donationRepository.findAllByUser(user); | ||
|
||
// User의 모든 영수증 인증 내역 조회 | ||
List<Receipt> receipts = receiptRepository.findAllByUser(user); | ||
|
||
// User의 모든 공유 내역 조회 | ||
List<Share> shares = shareRepository.findAllByUser(user); | ||
|
||
// Onjung 생성 | ||
Onjung onjung = onjungService.createOnjung(donations, receipts, shares); | ||
|
||
// User의 총 온정 횟수 조회 | ||
Integer totalOnjungCount = onjungService.calculateTotalOnjungCount(onjung); | ||
|
||
return ReadOnjungCountResponseDto.builder() | ||
.totalOnjungCount(totalOnjungCount) | ||
.build(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/daon/onjung/onjung/application/usecase/ReadOnjungCountUseCase.java
This file contains 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,11 @@ | ||
package com.daon.onjung.onjung.application.usecase; | ||
|
||
import com.daon.onjung.core.annotation.bean.UseCase; | ||
import com.daon.onjung.onjung.application.dto.response.ReadOnjungCountResponseDto; | ||
|
||
import java.util.UUID; | ||
|
||
@UseCase | ||
public interface ReadOnjungCountUseCase { | ||
ReadOnjungCountResponseDto execute(UUID accountId); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/daon/onjung/onjung/repository/mysql/DonationRepository.java
This file contains 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.daon.onjung.onjung.repository.mysql; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.onjung.domain.Donation; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface DonationRepository extends JpaRepository <Donation, Long> { | ||
|
||
List<Donation> findAllByUser(User user); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/daon/onjung/onjung/repository/mysql/ReceiptRepository.java
This file contains 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.daon.onjung.onjung.repository.mysql; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.onjung.domain.Receipt; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ReceiptRepository extends JpaRepository <Receipt, Long> { | ||
|
||
List<Receipt> findAllByUser(User user); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/daon/onjung/onjung/repository/mysql/ShareRepository.java
This file contains 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.daon.onjung.onjung.repository.mysql; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.onjung.domain.Share; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ShareRepository extends JpaRepository <Share, Long> { | ||
|
||
List<Share> findAllByUser(User user); | ||
} |