Skip to content

Commit a59748b

Browse files
authored
Merge pull request #44 from DMU-NextLevel/feat/project-status
feat project status
2 parents 423abd1 + fb140cb commit a59748b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1222
-323
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ dependencies {
5858

5959
// email
6060
implementation("com.sun.mail:javax.mail:1.6.2")
61+
62+
// test h2 db
63+
testImplementation 'com.h2database:h2'
64+
6165
}
6266

6367
tasks.named('test') {

settings.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
pluginManagement {
2+
plugins {
3+
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
4+
}
5+
}
16
rootProject.name = 'demo'

src/main/java/NextLevel/demo/exception/ErrorCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public enum ErrorCode {
3030

3131
// project
3232
NOT_CORRECT_TAG_SIZE(HttpStatus.BAD_REQUEST, "04001","invalidated tag input") ,
33-
ERROR_EXPIRED_DATE_CONVERSION(HttpStatus.BAD_REQUEST, "04003","can not convert expired : %s"),
33+
ERROR_EXPIRED_DATE_CONVERSION(HttpStatus.BAD_REQUEST, "04003","can not convert date : %s"),
34+
START_MUST_BEFORE_EXPIRED(HttpStatus.BAD_REQUEST, "04004","start must be before expired"),
3435

3536
// funding
3637
NOT_ENOUGH_POINT(HttpStatus.BAD_REQUEST, "05001","not enough point left:%s, need:%s"),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
project 별 funding 정보 dto : my page 메이커
2+
project dto : project total funding dto
3+
project funding dto (기본 정보)
4+
option funding list dto : input ( OptionEntity(with List<OptionFundingEntity (with UserEntity) > ) ) + option 정렬, option funding 날짜 정렬
5+
option dto
6+
List<option funding dto>
7+
List<free funding dto>
8+
9+
project funding dto : project 기본 funding 정보 (총 금액, 총 펀딩 수, ... )
10+
option funding list dto : { option dto, List<option funding dto> }
11+
option dto : option 정보, 금액
12+
option funding dto : user funding Info dto, coupon dto, 금액, 날짜, 갯수
13+
free funding dto : user funding Info, 금액, 날짜
14+
15+
project list with my funding 정보 dto : my page 서포터 (내가 한 펀딩 리스트)
16+
project list dto : project list with funding dto
17+
project list detail dto
18+
List<option funding list dto>
19+
option dto,
20+
option funding dto
21+
free funding dto
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package NextLevel.demo.funding.dto.response;
2+
3+
import NextLevel.demo.funding.entity.FreeFundingEntity;
4+
import NextLevel.demo.user.dto.user.response.UserFundingInfoDto;
5+
import com.fasterxml.jackson.annotation.JsonIgnore;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
9+
10+
import java.time.LocalDateTime;
11+
import java.util.Optional;
12+
13+
@Getter
14+
@Setter
15+
@NoArgsConstructor
16+
public class FreeFundingDto {
17+
18+
private UserFundingInfoDto user;
19+
private Long price;
20+
private LocalDateTime createdAt;
21+
22+
public static FreeFundingDto of(FreeFundingEntity freeFunding) {
23+
if(freeFunding == null) return null;
24+
FreeFundingDto dto = new FreeFundingDto();
25+
dto.user = UserFundingInfoDto.of(freeFunding.getUser());
26+
dto.price = freeFunding.getPrice();
27+
dto.createdAt = freeFunding.getCreatedAt();
28+
return dto;
29+
}
30+
31+
public static FreeFundingDto of(Optional<FreeFundingEntity> freeFunding) {
32+
if(freeFunding == null || freeFunding.isEmpty()) return null;
33+
return FreeFundingDto.of(freeFunding.get());
34+
}
35+
36+
}

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

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package NextLevel.demo.funding.dto.response;
2+
3+
import NextLevel.demo.funding.entity.CouponEntity;
4+
import NextLevel.demo.funding.entity.OptionFundingEntity;
5+
import NextLevel.demo.user.dto.user.response.UserFundingInfoDto;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
9+
10+
import java.time.LocalDateTime;
11+
12+
@NoArgsConstructor
13+
@Getter
14+
@Setter
15+
//option funding dto : user funding Info dto, 갯수
16+
public class OptionFundingDto {
17+
18+
private UserFundingInfoDto user;
19+
private ResponseCouponDto coupon;
20+
private LocalDateTime createdAt;
21+
private long price;
22+
private Long count;
23+
24+
public static OptionFundingDto of(OptionFundingEntity optionFunding) {
25+
OptionFundingDto dto = new OptionFundingDto();
26+
dto.user = UserFundingInfoDto.of(optionFunding.getUser());
27+
dto.coupon = ResponseCouponDto.of(optionFunding.getCoupon());
28+
dto.createdAt = optionFunding.getCreatedAt();
29+
dto.count = optionFunding.getCount();
30+
dto.price = ( optionFunding.getOption().getPrice() * dto.count ) - (optionFunding.getCoupon() != null ? optionFunding.getCoupon().getPrice() : 0);
31+
return dto;
32+
}
33+
34+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package NextLevel.demo.funding.dto.response;
2+
3+
import NextLevel.demo.funding.entity.OptionFundingEntity;
4+
import NextLevel.demo.option.OptionDto;
5+
import NextLevel.demo.option.OptionEntity;
6+
import com.fasterxml.jackson.annotation.JsonIgnore;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
import lombok.Setter;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
@NoArgsConstructor
15+
@Getter
16+
@Setter
17+
// option 정보, List<option funding dto>
18+
public class OptionFundingListDto {
19+
private OptionDto option;
20+
private List<OptionFundingDto> optionFunding;
21+
22+
@JsonIgnore
23+
private Long price;
24+
25+
@JsonIgnore
26+
private Long count;
27+
28+
public static OptionFundingListDto of(OptionEntity option){
29+
OptionFundingListDto dto = new OptionFundingListDto();
30+
dto.option = OptionDto.of(option);
31+
32+
//dto.optionFunding = option.getFundings().stream().map(OptionFundingDto::of).toList();
33+
Long price = 0L;
34+
Long count = 0L;
35+
List<OptionFundingDto> optionFundingDtoList = new ArrayList<>();
36+
37+
for(OptionFundingEntity optionFunding : option.getFundings()){
38+
count++;
39+
price += optionFunding.getOption().getPrice() * optionFunding.getCount();
40+
optionFundingDtoList.add(OptionFundingDto.of(optionFunding));
41+
}
42+
43+
dto.optionFunding = optionFundingDtoList;
44+
dto.price = price;
45+
dto.count = count;
46+
47+
return dto;
48+
}
49+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package NextLevel.demo.funding.dto.response;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
import lombok.Setter;
7+
8+
@Getter
9+
@Setter
10+
@NoArgsConstructor
11+
@AllArgsConstructor
12+
// 기본 funding 정보 (총 금액, 총 funding 수)
13+
public class ProjectFundingDto {
14+
private Long count;
15+
private Long price;
16+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package NextLevel.demo.funding.dto.response;
2+
3+
import NextLevel.demo.funding.entity.FreeFundingEntity;
4+
import NextLevel.demo.option.OptionEntity;
5+
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
7+
import lombok.Setter;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
@Getter
13+
@Setter
14+
@NoArgsConstructor
15+
public class ProjectTotalFundingDto {
16+
17+
private ProjectFundingDto total; // count, price
18+
private List<OptionFundingListDto> optionFunding; // List<OptionEntity> (with OptionFunding, User, Coupon)
19+
private List<FreeFundingDto> freeFunding; // List<FreeFundingEntity>
20+
21+
public static ProjectTotalFundingDto of(List<OptionEntity> optionList, List<FreeFundingEntity> freeFundingList) {
22+
ProjectTotalFundingDto dto = new ProjectTotalFundingDto();
23+
24+
Long count = 0L;
25+
Long price = 0L;
26+
List<OptionFundingListDto> optionFundingList = new ArrayList<>();
27+
for(OptionEntity option : optionList){
28+
OptionFundingListDto listDto = OptionFundingListDto.of(option);
29+
optionFundingList.add(listDto);
30+
count += listDto.getCount();
31+
price += listDto.getPrice();
32+
}
33+
34+
List<FreeFundingDto> freeFundingDtoList = new ArrayList<>();
35+
for(FreeFundingEntity freeFunding : freeFundingList){
36+
FreeFundingDto freeFundingDto = FreeFundingDto.of(freeFunding);
37+
freeFundingDtoList.add(freeFundingDto);
38+
count++;
39+
price += freeFundingDto.getPrice();
40+
}
41+
42+
dto.total = new ProjectFundingDto(count, price);
43+
44+
return dto;
45+
}
46+
47+
}

0 commit comments

Comments
 (0)