Skip to content

Commit

Permalink
Feat/project
Browse files Browse the repository at this point in the history
Feat/project
  • Loading branch information
yj-leez authored Dec 28, 2023
2 parents 8aff1e0 + 899cd73 commit 0023cd8
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 78 deletions.
3 changes: 3 additions & 0 deletions src/main/java/wowmarket/wow_server/domain/DemandItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 11 additions & 16 deletions src/main/java/wowmarket/wow_server/domain/DemandProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@AllArgsConstructor
Expand All @@ -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")
Expand All @@ -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;
Expand All @@ -53,16 +60,4 @@ public void setCategory(Category category){
this.category = category;
}

public void setImage(List<String> 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);
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/wowmarket/wow_server/domain/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
63 changes: 31 additions & 32 deletions src/main/java/wowmarket/wow_server/domain/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Entity
Expand All @@ -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")
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -71,18 +82,6 @@ public void setCategory(Category category){
this.category = category;
}

public void setImage(List<String> 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);
}
}
}


8 changes: 8 additions & 0 deletions src/main/java/wowmarket/wow_server/domain/ReceiveType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package wowmarket.wow_server.domain;

import com.fasterxml.jackson.databind.annotation.EnumNaming;


public enum ReceiveType {
delivery, pickup;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import wowmarket.wow_server.domain.DemandProject;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Getter
Expand All @@ -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<RegisterItemDto> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class RegisterItemDto {
private String item_name;
private Long price;
private int goal;
private int limit;

@Builder
public Item toItemEntity(){
return Item.builder()
.name(item_name)
.price(price)
.goal(goal)
.limit(limit)
.build();
}

Expand All @@ -31,6 +33,7 @@ public DemandItem toDemandItemEntity(){
.name(item_name)
.price(price)
.goal(goal)
.limit(limit)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -32,48 +38,52 @@ public class RegisterProjectDto {
@NotNull
private List<RegisterItemDto> 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;


@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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 에러 반환
Expand Down

0 comments on commit 0023cd8

Please sign in to comment.