diff --git a/src/main/java/wowmarket/wow_server/domain/DemandItem.java b/src/main/java/wowmarket/wow_server/domain/DemandItem.java index 48a56b0..d736ffb 100644 --- a/src/main/java/wowmarket/wow_server/domain/DemandItem.java +++ b/src/main/java/wowmarket/wow_server/domain/DemandItem.java @@ -28,6 +28,9 @@ public class DemandItem extends BaseEntity{ @ColumnDefault("0") private int goal; + @ColumnDefault("0") + private int limit; + public void setDemandProject(DemandProject demandProject){ this.demandProject=demandProject; } diff --git a/src/main/java/wowmarket/wow_server/domain/DemandProject.java b/src/main/java/wowmarket/wow_server/domain/DemandProject.java index 1b11250..cfe3e8b 100644 --- a/src/main/java/wowmarket/wow_server/domain/DemandProject.java +++ b/src/main/java/wowmarket/wow_server/domain/DemandProject.java @@ -4,6 +4,7 @@ import lombok.*; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; @AllArgsConstructor @@ -21,7 +22,12 @@ public class DemandProject extends BaseEntity{ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "seller_id", referencedColumnName = "user_id") private User user; - private String nickname; + + /* 등록 */ + private String sellerName; // 판매자명 + private String phoneNumber; // 전화번호 + private String email; // 이메일 + private String sellerEtc; // 기타 연락 수단 @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id", referencedColumnName = "category_id") @@ -32,10 +38,11 @@ public class DemandProject extends BaseEntity{ private String image2; private String image3; - private String name; + private String projectName; private String description; - private LocalDate startDate; - private LocalDate endDate; + + private LocalDateTime startDate; + private LocalDateTime endDate; private int participant_number; private Long final_achievement_rate; @@ -53,16 +60,4 @@ public void setCategory(Category category){ this.category = category; } - public void setImage(List uploaded){ - switch (uploaded.size()){ - case 4: - image3 = uploaded.get(3); - case 3: - image2 = uploaded.get(2); - case 2: - image1 = uploaded.get(1); - case 1: - thumbnail = uploaded.get(0); - } - } } diff --git a/src/main/java/wowmarket/wow_server/domain/Item.java b/src/main/java/wowmarket/wow_server/domain/Item.java index 929ab32..fa21fc1 100644 --- a/src/main/java/wowmarket/wow_server/domain/Item.java +++ b/src/main/java/wowmarket/wow_server/domain/Item.java @@ -24,6 +24,9 @@ public class Item { @ColumnDefault("0") private int goal; + @ColumnDefault("0") + private int limit; // 구매제한 + public void setProject(Project project){ this.project = project; } diff --git a/src/main/java/wowmarket/wow_server/domain/Project.java b/src/main/java/wowmarket/wow_server/domain/Project.java index 02ccd6c..c940501 100644 --- a/src/main/java/wowmarket/wow_server/domain/Project.java +++ b/src/main/java/wowmarket/wow_server/domain/Project.java @@ -4,6 +4,7 @@ import lombok.*; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; @Entity @@ -15,13 +16,20 @@ public class Project extends BaseEntity{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "project_id") private Long id; - private String name; - private String description; + + /* 등록 */ + private String projectName; // 프로젝트 이름 + private String description; // 프로젝트 설명 + + private String sellerName; // 판매자명 + private String phoneNumber; // 전화번호 + private String email; // 이메일 + private String sellerEtc; // 기타 연락 수단 @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "seller_id", referencedColumnName = "user_id") - private User user; - private String nickname; + private User user; // 판매자 + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id") @@ -32,10 +40,26 @@ public class Project extends BaseEntity{ private String image2; private String image3; - private LocalDate startDate; - private LocalDate endDate; + private LocalDateTime startDate; + private LocalDateTime endDate; + private int participant_number; + + @Enumerated(EnumType.STRING) + private ReceiveType receive_type; //delivery, pickup + private String receive_address; //직접수령 시 픽업장소 + private String deliveryType; // 배송 시 배송 방법 + private Long delivery_fee; // 배송비 + + + private String bank; // 은행 + private String account; // 계좌 + private String account_holder_name; // 예금주 + + @Column(columnDefinition = "tinyint(0) default 1") + private boolean sellToAll; // 0-> 소속 대학 학생, 1-> 전체 학생 + @Column(columnDefinition="tinyint(0) default 0") @Setter private boolean isDel; @@ -44,25 +68,12 @@ public class Project extends BaseEntity{ @Setter private boolean isEnd; - - private String receive_type; //delivery, pickup - private String receive_address; //직접수령 시 픽업장소 - private Long delivery_fee; //배송비 - private String address_detail; - private String zipcode; - - private String bank; - private String account; - private String account_holder_name; - - + /* 조회 */ private Long final_achievement_rate; @Column(columnDefinition = "integer default 0", nullable = false) private int view; //조회수 - @Column(columnDefinition = "tinyint(0) default 1") - private boolean sellToAll; // 0-> 소속 대학 학생, 1-> 전체 학생 public void setUser(User user){ this.user = user; @@ -71,18 +82,6 @@ public void setCategory(Category category){ this.category = category; } - public void setImage(List uploaded){ - switch (uploaded.size()){ - case 4: - image3 = uploaded.get(3); - case 3: - image2 = uploaded.get(2); - case 2: - image1 = uploaded.get(1); - case 1: - thumbnail = uploaded.get(0); - } - } } diff --git a/src/main/java/wowmarket/wow_server/domain/ReceiveType.java b/src/main/java/wowmarket/wow_server/domain/ReceiveType.java new file mode 100644 index 0000000..ac0d407 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/domain/ReceiveType.java @@ -0,0 +1,8 @@ +package wowmarket.wow_server.domain; + +import com.fasterxml.jackson.databind.annotation.EnumNaming; + + +public enum ReceiveType { + delivery, pickup; +} diff --git a/src/main/java/wowmarket/wow_server/register/dto/RegisterDemandProjectDto.java b/src/main/java/wowmarket/wow_server/register/dto/RegisterDemandProjectDto.java index 998f75e..627a402 100644 --- a/src/main/java/wowmarket/wow_server/register/dto/RegisterDemandProjectDto.java +++ b/src/main/java/wowmarket/wow_server/register/dto/RegisterDemandProjectDto.java @@ -8,6 +8,7 @@ import wowmarket.wow_server.domain.DemandProject; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; @Getter @@ -16,39 +17,53 @@ @Builder public class RegisterDemandProjectDto { @NotNull - private String project_name; + private String projectName; @NotNull private String description; @NotNull private Long category_id; + @NotNull + private String sellerName; // 판매자명 + + private String phoneNumber; // 전화번호 + private String email; // 이메일 + private String sellerEtc; // 기타 연락 수단 + @NotNull private String thumbnail; @NotNull private String image1; private String image2; private String image3; + @NotNull private List item; @NotNull - private LocalDate start_date; - @NotNull - private LocalDate end_date; + private LocalDateTime startDate; @NotNull - private String nickname; + private LocalDateTime endDate; + @Builder public DemandProject toEntity(){ return DemandProject.builder() - .name(project_name) + .projectName(projectName) .description(description) + .sellerName(sellerName) + .phoneNumber(phoneNumber) + .email(email) + .sellerEtc(sellerEtc) .thumbnail(thumbnail) .image1(image1) .image2(image2) .image3(image3) - .startDate(start_date) - .endDate(end_date) - .nickname(nickname) + .startDate(startDate) + .endDate(endDate) + .participant_number(0) + .final_achievement_rate(0L) + .isEnd(Boolean.FALSE) + .view(0) .build(); } diff --git a/src/main/java/wowmarket/wow_server/register/dto/RegisterItemDto.java b/src/main/java/wowmarket/wow_server/register/dto/RegisterItemDto.java index d1f8d25..760029b 100644 --- a/src/main/java/wowmarket/wow_server/register/dto/RegisterItemDto.java +++ b/src/main/java/wowmarket/wow_server/register/dto/RegisterItemDto.java @@ -15,6 +15,7 @@ public class RegisterItemDto { private String item_name; private Long price; private int goal; + private int limit; @Builder public Item toItemEntity(){ @@ -22,6 +23,7 @@ public Item toItemEntity(){ .name(item_name) .price(price) .goal(goal) + .limit(limit) .build(); } @@ -31,6 +33,7 @@ public DemandItem toDemandItemEntity(){ .name(item_name) .price(price) .goal(goal) + .limit(limit) .build(); } } diff --git a/src/main/java/wowmarket/wow_server/register/dto/RegisterProjectDto.java b/src/main/java/wowmarket/wow_server/register/dto/RegisterProjectDto.java index d50c74e..bdd6bc3 100644 --- a/src/main/java/wowmarket/wow_server/register/dto/RegisterProjectDto.java +++ b/src/main/java/wowmarket/wow_server/register/dto/RegisterProjectDto.java @@ -6,8 +6,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; import wowmarket.wow_server.domain.Project; - -import java.time.LocalDate; +import wowmarket.wow_server.domain.ReceiveType; +import java.time.LocalDateTime; import java.util.List; @Getter @@ -16,11 +16,17 @@ @Builder public class RegisterProjectDto { @NotNull - private String project_name; + private String projectName; @NotNull private String description; @NotNull private Long category_id; + @NotNull + private String sellerName; // 판매자명 + + private String phoneNumber; // 전화번호 + private String email; // 이메일 + private String sellerEtc; // 기타 연락 수단 @NotNull private String thumbnail; @@ -32,23 +38,22 @@ public class RegisterProjectDto { @NotNull private List item; @NotNull - private LocalDate start_date; + private LocalDateTime start_date; @NotNull - private LocalDate end_date; + private LocalDateTime end_date; @NotNull - private String receive_type; - private String address; - private Long delivery_fee; -// private String address_detail; 추후에 추가 예정 -// private String zipcode; - @NotNull - private String bank; + private String receive_type; //delivery, pickup + private String receive_address; //직접수령 시 픽업장소 + private String deliveryType; // 배송 시 배송 방법 + private Long delivery_fee; // 배송비 + + @NotNull - private String account; + private String bank; //은행명 @NotNull - private String account_holder_name; + private String account; //계좌 @NotNull - private String nickname; + private String account_holder_name; //예금주 @NotNull private Boolean sell_to_all; @@ -56,24 +61,29 @@ public class RegisterProjectDto { @Builder public Project toEntity(){ return Project.builder() - .name(project_name) + .projectName(projectName) .description(description) + .sellerName(sellerName) + .phoneNumber(phoneNumber) + .email(email) + .sellerEtc(sellerEtc) .thumbnail(thumbnail) .image1(image1) .image2(image2) .image3(image3) .startDate(start_date) .endDate(end_date) - .isDel(Boolean.FALSE) - .isEnd(Boolean.FALSE) - .receive_type(receive_type) - .receive_address(address) + .participant_number(0) + .receive_type(ReceiveType.valueOf(receive_type)) + .receive_address(receive_address) + .deliveryType(deliveryType) .delivery_fee(delivery_fee) .bank(bank) .account(account) .account_holder_name(account_holder_name) - .nickname(nickname) .sellToAll(sell_to_all) + .isDel(Boolean.FALSE) + .isEnd(Boolean.FALSE) .build(); } } diff --git a/src/main/java/wowmarket/wow_server/register/service/RegisterService.java b/src/main/java/wowmarket/wow_server/register/service/RegisterService.java index 4853a0f..c7d3548 100644 --- a/src/main/java/wowmarket/wow_server/register/service/RegisterService.java +++ b/src/main/java/wowmarket/wow_server/register/service/RegisterService.java @@ -31,6 +31,7 @@ public Long registerProject(RegisterProjectDto requestDto, User user) throws Exc //category 연관관계 설정 project.setCategory(categoryRepository.findById(requestDto.getCategory_id()) .orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "일치하는 카테고리가 없습니다"))); + //user 연관관계 설정 if(user != null) project.setUser(user); else throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "유저를 찾을 수 없습니다"); //유저 없을 시 400 에러 반환