Skip to content

Commit 76a4177

Browse files
committed
feat admin : project 별 funding 조회 api
1 parent 3348050 commit 76a4177

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/main/java/NextLevel/demo/admin/project/AdminProjectController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public ResponseEntity removeProject(@PathVariable("projectId") Long projectId) {
6767
return ResponseEntity.ok().body(new SuccessResponse("success", null));
6868
}
6969

70+
@GetMapping("/{projectId}")
71+
public ResponseEntity getProjectFundingData(@PathVariable("projectId") Long projectId) {
72+
return ResponseEntity.ok().body(new SuccessResponse("success", adminProjectService.getProjectFunding(projectId)));
73+
}
74+
75+
7076
@GetMapping("/funding")
7177
public ResponseEntity selectAllFunding(
7278
@RequestParam(value = "page", required = false) Long page,

src/main/java/NextLevel/demo/admin/project/AdminProjectService.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package NextLevel.demo.admin.project;
22

33
import NextLevel.demo.admin.AdminRepository;
4+
import NextLevel.demo.funding.dto.response.FreeFundingDto;
5+
import NextLevel.demo.funding.dto.response.ProjectTotalFundingDto;
6+
import NextLevel.demo.funding.entity.FreeFundingEntity;
47
import NextLevel.demo.funding.repository.FundingDslRepository;
8+
import NextLevel.demo.option.OptionEntity;
59
import NextLevel.demo.project.ProjectStatus;
610
import NextLevel.demo.project.project.dto.response.ProjectListWithFundingDto;
711
import NextLevel.demo.project.project.dto.response.ResponseProjectListDetailDto;
@@ -26,6 +30,7 @@ public class AdminProjectService {
2630
private final SelectProjectListDslRepository selectProjectListDslRepository;
2731
private final FundingDslRepository fundingDslRepository;
2832
private final AdminRepository adminRepository;
33+
private final ProjectValidateService projectValidateService;
2934

3035
@Transactional
3136
public ProjectListWithFundingDto getAllProjectListWithFundingData(Long page, Long pageCount) {
@@ -56,4 +61,16 @@ public List<ResponseFundingDataDto> selectAllFunding(Long page, Long pageCount)
5661
return fundingDaoList.stream().map(ResponseFundingDataDto::of).toList();
5762
}
5863

64+
@Transactional
65+
public ProjectTotalFundingDto getProjectFunding(Long projectId) {
66+
ProjectEntity project = projectValidateService.getProjectEntity(projectId);
67+
68+
List<OptionEntity> optionList = project.getOptions().stream().toList();
69+
for(OptionEntity optionEntity : optionList)
70+
optionEntity.getFundings();
71+
List<FreeFundingEntity> freeFundingList = project.getFreeFundings().stream().toList();
72+
73+
return ProjectTotalFundingDto.of(optionList, freeFundingList);
74+
}
75+
5976
}

src/main/java/NextLevel/demo/funding/dto/response/ProjectTotalFundingDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static ProjectTotalFundingDto of(List<OptionEntity> optionList, List<Free
3030
count += listDto.getCount();
3131
price += listDto.getPrice();
3232
}
33+
dto.optionFunding = optionFundingList;
3334

3435
List<FreeFundingDto> freeFundingDtoList = new ArrayList<>();
3536
for(FreeFundingEntity freeFunding : freeFundingList){
@@ -38,6 +39,7 @@ public static ProjectTotalFundingDto of(List<OptionEntity> optionList, List<Free
3839
count++;
3940
price += freeFundingDto.getPrice();
4041
}
42+
dto.freeFunding = freeFundingDtoList;
4143

4244
dto.total = new ProjectFundingDto(count, price);
4345

0 commit comments

Comments
 (0)