-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
광고 상품 삭제 api 개발(#23 PR close+rebase 후 다시 Pull request)
- Loading branch information
Showing
17 changed files
with
207 additions
and
0 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/backend/soullive_a/entity/model/ProductModel.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,43 @@ | ||
package com.backend.soullive_a.entity.model; | ||
|
||
import com.backend.soullive_a.entity.Product; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDateTime; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "PRODUCT_MODEL") | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ProductModel { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "PRODUCT_ID", nullable = false) | ||
private Product product; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "MODEL_ID", nullable = false) | ||
private Model model; | ||
|
||
@Column(name = "SEARCH_TIME", nullable = false) | ||
private LocalDateTime searchTime; | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/backend/soullive_a/exception/base/BaseResponse.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
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
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/backend/soullive_a/repository/ProductModelRepository.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,8 @@ | ||
package com.backend.soullive_a.repository; | ||
|
||
import com.backend.soullive_a.entity.model.ProductModel; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ProductModelRepository extends JpaRepository<ProductModel, Long> { | ||
|
||
} |
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
108 changes: 108 additions & 0 deletions
108
src/test/java/com/backend/soullive_a/service/impl/ProductServiceImplTest.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,108 @@ | ||
//package com.backend.soullive_a.service.impl; | ||
// | ||
// | ||
// | ||
//import com.backend.soullive_a.constant.AgeType; | ||
//import com.backend.soullive_a.constant.GenderType; | ||
//import com.backend.soullive_a.entity.Age; | ||
//import com.backend.soullive_a.entity.BrandImage; | ||
//import com.backend.soullive_a.entity.Gender; | ||
//import com.backend.soullive_a.entity.Product; | ||
//import com.backend.soullive_a.entity.ProductImage; | ||
//import com.backend.soullive_a.entity.Range; | ||
//import com.backend.soullive_a.repository.AgeRepository; | ||
//import com.backend.soullive_a.repository.BrandImageRepository; | ||
//import com.backend.soullive_a.repository.GenderRepository; | ||
//import com.backend.soullive_a.repository.ProductImageRepository; | ||
//import com.backend.soullive_a.repository.ProductRepository; | ||
//import com.backend.soullive_a.repository.RangeRepository; | ||
//import org.junit.jupiter.api.Assertions; | ||
//import org.junit.jupiter.api.Test; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.test.context.SpringBootTest; | ||
//import org.springframework.test.annotation.Rollback; | ||
//import org.springframework.transaction.annotation.Transactional; | ||
// | ||
//@SpringBootTest | ||
//class ProductServiceImplTest { | ||
// | ||
// @Autowired | ||
// ProductRepository productRepository; | ||
// @Autowired | ||
// AgeRepository ageRepository; | ||
// @Autowired | ||
// BrandImageRepository brandImageRepository; | ||
// @Autowired | ||
// GenderRepository genderRepository; | ||
// @Autowired | ||
// ProductImageRepository productImageRepository; | ||
// @Autowired | ||
// RangeRepository rangeRepository; | ||
// | ||
// @Test | ||
// @Transactional | ||
// @Rollback(value = false) | ||
// void deleteProduct() { | ||
// | ||
// /* | ||
// * given | ||
// */ | ||
// // 광고 상품 entity 생성 | ||
// Product product = Product.builder() | ||
// .company("큐시즘") | ||
// .brand("소울라이브-A") | ||
// .product("백엔드 개발") | ||
// .characteristic("characteristic") | ||
// .build(); | ||
// | ||
// productRepository.save(product); | ||
// // 브랜드 이미지 entity 생성 | ||
// BrandImage brandImage = BrandImage.builder() | ||
// .product(product) | ||
// .brandImage("브랜드 이미지 url") | ||
// .build(); | ||
// brandImageRepository.save(brandImage); | ||
// // 상품 이미지 entity 생성 | ||
// ProductImage productImage = ProductImage.builder() | ||
// .product(product) | ||
// .productImage("상품 이미지 url") | ||
// .build(); | ||
// productImageRepository.save(productImage); | ||
// // 성별 entity 생성 | ||
// Gender gender = Gender.builder() | ||
// .product(product) | ||
// .gender(GenderType.MALE) | ||
// .build(); | ||
// genderRepository.save(gender); | ||
// // 나이 entity 생성 | ||
// Age age = Age.builder() | ||
// .product(product) | ||
// .age(AgeType.FIFTY) | ||
// .build(); | ||
// ageRepository.save(age); | ||
// // 범주 entity 생성 | ||
// Range range = Range.builder() | ||
// .product(product) | ||
// .range("범주 예시") | ||
// .build(); | ||
// rangeRepository.save(range); | ||
// | ||
// | ||
// /* | ||
// * when | ||
// */ | ||
// productRepository.deleteById(1L); | ||
// | ||
// | ||
// /* | ||
// * then | ||
// */ | ||
// Assertions.assertTrue(ageRepository.findByProductId(1L).isEmpty()); | ||
// Assertions.assertTrue(brandImageRepository.findByProductId(1L).isEmpty()); | ||
// Assertions.assertTrue(genderRepository.findByProductId(1L).isEmpty()); | ||
// Assertions.assertTrue(productImageRepository.findByProductId(1L).isEmpty()); | ||
// Assertions.assertTrue(rangeRepository.findByProductId(1L).isEmpty()); | ||
// | ||
// } | ||
//} | ||
// |