Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/NextLevel/demo/summery/dto/TotalSummeryDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ public class TotalSummeryDto {
private Long totalFundingPrice;
private Long totalFundingCount;
private Long totalSuccessProjectCount;
private Long totalProgressProjectCount;
private Long totalSupporterCount;
private Long totalCreatorCount;

public TotalSummeryDto(Long totalFundingPrice, Long totalFundingCount, Long totalSuccessProjectCount, Long totalSupporterCount, Long totalCreatorCount) {
public TotalSummeryDto(
Long totalFundingPrice,
Long totalFundingCount,
Long totalSuccessProjectCount,
Long totalProgressProjectCount,
Long totalSupporterCount,
Long totalCreatorCount
) {
this.totalFundingPrice = totalFundingPrice;
this.totalFundingCount = totalFundingCount;
this.totalSuccessProjectCount = totalSuccessProjectCount;
this.totalProgressProjectCount = totalProgressProjectCount;
this.totalSupporterCount = totalSupporterCount;
this.totalCreatorCount = totalCreatorCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import NextLevel.demo.project.ProjectStatus;
import NextLevel.demo.user.entity.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
//org.springframework.data.repository.Repository
import org.springframework.data.repository.query.Param;

import java.util.List;

@org.springframework.stereotype.Repository
public interface SummeryRepository extends Repository<UserEntity, Long> {

Expand All @@ -23,8 +23,8 @@ public interface SummeryRepository extends Repository<UserEntity, Long> {
@Query("select count(of) from OptionFundingEntity of")
long getTotalOptionFundingCount();

@Query("select count(p) from ProjectEntity p where p.projectStatus = :status")
long getProjectCount(@Param("status")ProjectStatus status);
@Query("select count(p) from ProjectEntity p where p.projectStatus in :status")
long getProjectCount(@Param("status") List<ProjectStatus> status);

@Query("select count(distinct u) from UserEntity u " +
"left join ProjectEntity p on p.user.id = u.id " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class SummeryService {
Expand All @@ -17,11 +19,12 @@ public class SummeryService {
public TotalSummeryDto projectSummery() {
Long totalFundingPrice = summeryRepository.getTotalFreeFundingPrice() + summeryRepository.getTotalOptionFundingPrice();
Long totalFundingCount = summeryRepository.getFreeFundingCount() + summeryRepository.getTotalOptionFundingCount();
Long totalSuccessProjectCount = summeryRepository.getProjectCount(ProjectStatus.SUCCESS);
Long totalSuccessProjectCount = summeryRepository.getProjectCount(List.of(ProjectStatus.SUCCESS));
Long totalProgressProjectCount = summeryRepository.getProjectCount(List.of(ProjectStatus.PROGRESS));
Long totalSupporterCount = summeryRepository.getSupporterCount();
Long totalCreatorCount = summeryRepository.getCreatorCount();

return new TotalSummeryDto(totalFundingPrice, totalFundingCount, totalSuccessProjectCount, totalSupporterCount, totalCreatorCount);
return new TotalSummeryDto(totalFundingPrice, totalFundingCount, totalSuccessProjectCount, totalProgressProjectCount, totalSupporterCount, totalCreatorCount);
}

}
Loading