-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/#7-상품등록_페이지
- Loading branch information
Showing
35 changed files
with
691 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/wap/dingdong/backend/controller/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package wap.dingdong.backend.controller; | ||
|
||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class HelloController { | ||
|
||
@GetMapping("/demo/hello") | ||
public String HelloWorld(){ | ||
return "Hello World!! \n"; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/wap/dingdong/backend/controller/ProductController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package wap.dingdong.backend.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import wap.dingdong.backend.payload.request.ProductCreateRequest; | ||
import wap.dingdong.backend.payload.response.ProductInfoResponse; | ||
import wap.dingdong.backend.payload.response.ProductsResponse; | ||
import wap.dingdong.backend.service.ProductService; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class ProductController { | ||
|
||
private final ProductService productService; | ||
|
||
//상품 등록 | ||
@PostMapping("/product") | ||
public ResponseEntity<?> createProduct(@RequestBody ProductCreateRequest request) { | ||
productService.save(request); | ||
return new ResponseEntity<>(HttpStatus.OK); | ||
} | ||
|
||
// 전체 상품 조회 | ||
//ProductInfoResponse는 하나의 개별 상품의 정보를 담는 DTO (상품상세 DTO와 비슷) | ||
//ProductsResponse는 전체 상품 목록을 담는 DTO, | ||
// 여러 개의 ProductInfoResponse 객체를 리스트 형태로 가짐 | ||
@GetMapping("/product/list") | ||
public ResponseEntity<?> findAllProducts() { | ||
List<ProductInfoResponse> products = productService.getAllProducts(); | ||
ProductsResponse response = new ProductsResponse(products); | ||
return new ResponseEntity<>(response, HttpStatus.OK); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
backend/src/main/java/wap/dingdong/backend/domain/AuthProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
public enum AuthProvider { | ||
local, | ||
kakao | ||
} |
39 changes: 39 additions & 0 deletions
39
backend/src/main/java/wap/dingdong/backend/domain/Buy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Buy { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "buy_id") | ||
private Long id; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
|
||
@OneToOne(mappedBy = "buy", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | ||
private Wish wish; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
backend/src/main/java/wap/dingdong/backend/domain/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Comment { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "comment_id") | ||
private Long id; | ||
|
||
private String contents; | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/wap/dingdong/backend/domain/Image.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Image { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "image_id") | ||
private Long id; | ||
|
||
private String imageUrl; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/src/main/java/wap/dingdong/backend/domain/Location.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Location { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "location_id") | ||
private Long id; | ||
|
||
private String location; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
|
||
|
||
|
||
} |
60 changes: 60 additions & 0 deletions
60
backend/src/main/java/wap/dingdong/backend/domain/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter @Setter | ||
@AllArgsConstructor @NoArgsConstructor | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Product { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "product_id") | ||
private Long id; | ||
|
||
private String title; | ||
private Long price; | ||
private String contents; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ProductStatus status = ProductStatus.ON_SALE; //기본값 ON_SALE | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ProductLike productLike = ProductLike.UNLIKE; //기본값 UNLIKE | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@OneToOne(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | ||
private Buy buy; | ||
|
||
@OneToOne(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | ||
private Sell sell; | ||
|
||
@OneToOne(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | ||
private Wish wish; | ||
|
||
@OneToMany(mappedBy = "product",cascade = CascadeType.ALL) | ||
private List<Image> images = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "product", cascade = CascadeType.ALL) | ||
private List<Location> locations = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "product", cascade = CascadeType.ALL) | ||
private List<Comment> comments = new ArrayList<>(); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/wap/dingdong/backend/domain/ProductLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
public enum ProductLike { | ||
LIKE, UNLIKE | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/wap/dingdong/backend/domain/ProductStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
public enum ProductStatus { | ||
ON_SALE, SOLD_OUT | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/wap/dingdong/backend/domain/Sell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package wap.dingdong.backend.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EnableJpaAuditing | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Sell { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "sell_id") | ||
private Long id; | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_id") | ||
private Product product; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
} |
Oops, something went wrong.