Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
114fdb3
fix: Redis 관련 에러를 방지하기 위해 주석처리
Ji-eun1 Mar 27, 2025
dfcf335
test(product): 제품 단건 조회 및 제품 삭제 테스트 코드 작성
Ji-eun1 Mar 27, 2025
fc83cf1
merge: dev 와 병합
Ji-eun1 Mar 27, 2025
f86fa21
chore: 환경 변수 AWS_ACCESS_KEY, AWS_SECRET_KEY 를 S3_ACCESS_KEY, S3_SECRE…
Ji-eun1 Mar 27, 2025
c683020
test(product): 제품 생성 및 수정 테스트 코드 작성 #28
Ji-eun1 Mar 28, 2025
0e010b5
test(review): 리뷰 CRUD 테스트 코드 작성 #28
Ji-eun1 Mar 28, 2025
37e3d92
test(productImage): mock 주입 #28
Ji-eun1 Mar 28, 2025
8ca619d
config: Redis 호스트와 S3 버킷 정보 env 파일에 추가
Ji-eun1 Mar 28, 2025
cc78153
test(productImage): 이미지 업로드 및 이미지 삭제 테스트 코드 작성 #28
Ji-eun1 Mar 28, 2025
06ea779
merge: dev 와 병합
Ji-eun1 Mar 28, 2025
e4caf73
test(product): 제품 생성 및 제품 수정 테스트 코드 수정 #28
Ji-eun1 Mar 28, 2025
000e65b
refactor: Redis 관련 주석 해제
Ji-eun1 Mar 28, 2025
f97f111
refactor: KEY 명칭 변경
Ji-eun1 Mar 28, 2025
ed74c7f
merge: dev 와 병합
Ji-eun1 Mar 28, 2025
9fae290
Merge branch 'dev' into test/product-productImage-review
Ji-eun1 Mar 28, 2025
1d1f14f
refactor(product): update 이름 ifNotNull 붙여서 변경
Ji-eun1 Mar 28, 2025
609fb78
refactor(review): update 이름 ifNotNull 붙여서 변경
Ji-eun1 Mar 28, 2025
e580188
refactor(product): find, get 이름 변경
Ji-eun1 Mar 28, 2025
c9e2a67
refactor(review): find, get 이름 변경
Ji-eun1 Mar 28, 2025
96b5528
refactor(product): category, salestate enums 도메인 따로 관리
Ji-eun1 Mar 28, 2025
f7800fb
feat(review): findReviews 엔드포인트 확장성 있게 변경
Ji-eun1 Mar 28, 2025
843c9aa
refactor(product): 공백 제거
Ji-eun1 Mar 28, 2025
b787710
refactor(review): 공백 제거
Ji-eun1 Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.eightyage.domain.product.entity;
package com.example.eightyage.domain.product.category;

public enum Category {
SKINCARE("스킨케어"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.example.eightyage.domain.product.dto.response.ProductSaveResponseDto;
import com.example.eightyage.domain.product.dto.response.ProductSearchResponseDto;
import com.example.eightyage.domain.product.dto.response.ProductUpdateResponseDto;
import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.service.ProductService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -46,8 +46,8 @@ public ResponseEntity<ProductUpdateResponseDto> updateProduct(

// 제품 단건 조회
@GetMapping("/v1/products/{productId}")
public ResponseEntity<ProductGetResponseDto> getProduct(@PathVariable Long productId){
ProductGetResponseDto responseDto = productService.findProductById(productId);
public ResponseEntity<ProductGetResponseDto> findProduct(@PathVariable Long productId){
ProductGetResponseDto responseDto = productService.getProductById(productId);

return ResponseEntity.ok(responseDto);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.example.eightyage.domain.product.dto.request;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.global.dto.ValidationMessage;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ProductSaveRequestDto {

@NotBlank(message= ValidationMessage.NOT_BLANK_PRODUCT_NAME)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package com.example.eightyage.domain.product.dto.request;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.salestate.SaleState;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ProductUpdateRequestDto {

private String productName;

private Category category;

private String content;

private SaleState saleState;

private Integer price;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.eightyage.domain.product.dto.response;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.salestate.SaleState;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -12,18 +12,11 @@
@Builder
@AllArgsConstructor
public class ProductGetResponseDto {

private final String productName;

private final String content;

private final Category category;

private final Integer price;

private final SaleState saleState;

private final LocalDateTime createdAt;

private final LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.eightyage.domain.product.dto.response;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.salestate.SaleState;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -12,18 +12,11 @@
@Builder
@AllArgsConstructor
public class ProductSaveResponseDto {

private final String productName;

private final Category category;

private final Integer price;

private final String content;

private final SaleState saleState;

private final LocalDateTime createdAt;

private final LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.eightyage.domain.product.dto.response;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.eightyage.domain.product.dto.response;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.salestate.SaleState;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -12,18 +12,11 @@
@Builder
@AllArgsConstructor
public class ProductUpdateResponseDto {

private final String productName;

private final Integer price;

private final String content;

private final Category category;

private final SaleState saleState;

private final LocalDateTime createdAt;

private final LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.example.eightyage.domain.product.entity;

import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.salestate.SaleState;
import com.example.eightyage.domain.review.entity.Review;
import com.example.eightyage.global.entity.TimeStamped;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -14,6 +17,7 @@
@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "product",
indexes = @Index(name = "index_saleState_category_name", columnList = "saleState, category, name")
)
Expand Down Expand Up @@ -50,31 +54,31 @@ public Product(String name, Category category, String content, Integer price, Sa
this.saleState = saleState;
}

public void updateName(String newName){
public void updateNameIfNotNull(String newName){
if(newName != null){
this.name = newName;
}
}

public void updateCategory(Category newCategory) {
public void updateCategoryIfNotNull(Category newCategory) {
if (newCategory != null) {
this.category = newCategory;
}
}

public void updateContent(String newContent) {
public void updateContentIfNotNull(String newContent) {
if (newContent != null) {
this.content = newContent;
}
}

public void updatePrice(Integer newPrice) {
public void updatePriceIfNotNull(Integer newPrice) {
if (newPrice != null) {
this.price = newPrice;
}
}

public void updateSaleState(SaleState newSaleState) {
public void updateSaleStateIfNotNull(SaleState newSaleState) {
if (newSaleState != null) {
this.saleState = newSaleState;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.eightyage.domain.product.repository;

import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.entity.Product;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.salestate.SaleState;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.eightyage.domain.product.repository;

import com.example.eightyage.domain.product.entity.ProductImage;
import com.example.eightyage.global.exception.NotFoundException;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.eightyage.domain.product.repository;

import com.example.eightyage.domain.product.dto.response.ProductSearchResponseDto;
import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.entity.Product;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.eightyage.domain.product.salestate;

public enum SaleState {
FOR_SALE,
SOLD_OUT
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.example.eightyage.domain.product.dto.request.ProductSaveRequestDto;
import com.example.eightyage.domain.product.dto.request.ProductUpdateRequestDto;
import com.example.eightyage.domain.product.dto.response.*;
import com.example.eightyage.domain.product.entity.Category;
import com.example.eightyage.domain.product.category.Category;
import com.example.eightyage.domain.product.entity.Product;
import com.example.eightyage.domain.product.entity.SaleState;
import com.example.eightyage.domain.product.salestate.SaleState;
import com.example.eightyage.domain.product.repository.ProductRepository;
import com.example.eightyage.domain.review.entity.Review;
import com.example.eightyage.domain.review.repository.ReviewRepository;
Expand Down Expand Up @@ -57,11 +57,11 @@ public ProductSaveResponseDto saveProduct(ProductSaveRequestDto requestDto) {
public ProductUpdateResponseDto updateProduct(Long productId, ProductUpdateRequestDto requestDto) {
Product findProduct = findProductByIdOrElseThrow(productId);

findProduct.updateName(requestDto.getProductName());
findProduct.updateCategory(requestDto.getCategory());
findProduct.updateContent(requestDto.getContent());
findProduct.updateSaleState(requestDto.getSaleState());
findProduct.updatePrice(requestDto.getPrice());
findProduct.updateNameIfNotNull(requestDto.getProductName());
findProduct.updateCategoryIfNotNull(requestDto.getCategory());
findProduct.updateContentIfNotNull(requestDto.getContent());
findProduct.updateSaleStateIfNotNull(requestDto.getSaleState());
findProduct.updatePriceIfNotNull(requestDto.getPrice());

return ProductUpdateResponseDto.builder()
.productName(findProduct.getName())
Expand All @@ -76,7 +76,7 @@ public ProductUpdateResponseDto updateProduct(Long productId, ProductUpdateReque

// 제품 단건 조회
@Transactional(readOnly = true)
public ProductGetResponseDto findProductById(Long productId) {
public ProductGetResponseDto getProductById(Long productId) {
Product findProduct = findProductByIdOrElseThrow(productId);

return ProductGetResponseDto.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public ResponseEntity<ReviewUpdateResponseDto> updateReview(
}

// 리뷰 다건 조회
@GetMapping("/v1/products/{productId}/reviews")
public ResponseEntity<Page<ReviewsGetResponseDto>> getReviews(
@PathVariable Long productId,
@GetMapping("/v1/reviews")
public ResponseEntity<Page<ReviewsGetResponseDto>> findReviews(
@RequestParam(required = true) Long productId,
@RequestParam(required = false, defaultValue = "score") String orderBy,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size
){
PageRequest pageRequest = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, orderBy));

Page<ReviewsGetResponseDto> reviews = reviewService.findReviews(productId, pageRequest);
Page<ReviewsGetResponseDto> reviews = reviewService.getReviews(productId, pageRequest);

return ResponseEntity.ok(reviews);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.example.eightyage.global.dto.ValidationMessage;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ReviewSaveRequestDto {

@NotNull(message = ValidationMessage.NOT_NULL_SCORE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class ReviewUpdateRequestDto {

private Double score;

private String content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@
@Builder
@AllArgsConstructor
public class ReviewSaveResponseDto {

private final Long id;

private final Long userId;

private final Long productId;

private final String nickname;

private final Double score;

private final String content;

private final LocalDateTime createdAt;

private final LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@
@Builder
@AllArgsConstructor
public class ReviewUpdateResponseDto {

private final Long id;

private final Long userId;

private final String nickname;

private final Double score;

private final String content;

private final LocalDateTime createdAt;

private final LocalDateTime modifiedAt;
}
Loading
Loading