From 596feb5ca05e672868b65049b9d99a775ef068e4 Mon Sep 17 00:00:00 2001 From: Dayeon-Hong Date: Fri, 24 Nov 2023 18:28:32 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20develop=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=ED=9B=84=20=EB=8B=A4=EC=8B=9C=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + build.gradle | 2 +- github/workflows/deploy.yml | 45 ++++++++++--------- .../domain/users/mapper/UserMapperImpl.java | 2 +- .../mypage/repository/UserLikeRepository.java | 2 + .../domain/mypage/service/MyPageService.java | 17 ++++++- .../controller/CategoryController.java | 1 + .../dto/response/ProductPreViewDto.java | 10 ++--- .../domain/products/mapper/ProductMapper.java | 1 - .../products/service/CategoryService.java | 13 +++++- .../products/service/ProductService.java | 6 +-- .../products/service/ProductSubService.java | 7 +++ .../global/exception/ErrorResponse.java | 1 + src/main/resources/application.yml | 4 -- 14 files changed, 69 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 381b52f..fa2af76 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.class .env .idea/ +.gradle/ # Log file *.log diff --git a/build.gradle b/build.gradle index b295f98..c59d647 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'org.springframework.boot' version '2.7.9' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' - id 'net.ltgt.apt' version '0.21' +// id 'net.ltgt.apt' version '0.21' } group = 'com.teamjo' diff --git a/github/workflows/deploy.yml b/github/workflows/deploy.yml index 58b2f38..2161078 100644 --- a/github/workflows/deploy.yml +++ b/github/workflows/deploy.yml @@ -2,38 +2,39 @@ name: techeer-market on: push: - -develop - workflow_dispath: + branches: + - develop + workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - -name: Checkout - uses: actions/checkout@c2 + - name: Checkout + uses: actions/checkout@v2 - -name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' - -name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash - -name: Build with Gradle - run: ./gradlew clean build - shell: bash + - name: Build with Gradle + run: ./gradlew clean build + shell: bash - -name: Get build time - usees: 1466587594/get-current-time@v2 + - name: Get build time id: current-time + uses: 1466587594/get-current-time@v2 with: - format: YYYY-MM-DDTHH-mm-ss - utcOffset: "+09:00" + format: 'YYYY-MM-DDTHH-mm-ss' + utcOffset: '+09:00' - -name: Show Current Time - run: echo "CurrentTime = ${{steps.current-time.outputs.formattedTime}}" - shell: bash \ No newline at end of file + - name: Show Current Time + run: echo "CurrentTime = ${{ steps.current-time.outputs.formattedTime }}" + shell: bash diff --git a/src/main/generated/com/teamjo/techeermarket/domain/users/mapper/UserMapperImpl.java b/src/main/generated/com/teamjo/techeermarket/domain/users/mapper/UserMapperImpl.java index 326d2f4..e1d7185 100644 --- a/src/main/generated/com/teamjo/techeermarket/domain/users/mapper/UserMapperImpl.java +++ b/src/main/generated/com/teamjo/techeermarket/domain/users/mapper/UserMapperImpl.java @@ -7,7 +7,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2023-11-01T22:09:42+0900", + date = "2023-11-24T18:06:05+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.15 (Oracle Corporation)" ) @Component diff --git a/src/main/java/com/teamjo/techeermarket/domain/mypage/repository/UserLikeRepository.java b/src/main/java/com/teamjo/techeermarket/domain/mypage/repository/UserLikeRepository.java index 66dab8a..b5350f2 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/mypage/repository/UserLikeRepository.java +++ b/src/main/java/com/teamjo/techeermarket/domain/mypage/repository/UserLikeRepository.java @@ -11,4 +11,6 @@ public interface UserLikeRepository extends JpaRepository { boolean existsByUsersAndProducts(Users users, Products products); Optional findByUsersAndProducts(Users users, Products products); + +// int countByProduct(Products products); } diff --git a/src/main/java/com/teamjo/techeermarket/domain/mypage/service/MyPageService.java b/src/main/java/com/teamjo/techeermarket/domain/mypage/service/MyPageService.java index 8bf185e..0536b7f 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/mypage/service/MyPageService.java +++ b/src/main/java/com/teamjo/techeermarket/domain/mypage/service/MyPageService.java @@ -1,13 +1,26 @@ package com.teamjo.techeermarket.domain.mypage.service; +import com.teamjo.techeermarket.domain.mypage.repository.UserLikeRepository; +import com.teamjo.techeermarket.domain.products.entity.Products; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -//@Service -//@RequiredArgsConstructor +@Service +@RequiredArgsConstructor public class MyPageService { + private final UserLikeRepository userLikeRepository; + /* + // 게시물 좋아요 수 계산하기 + */ +// @Transactional(readOnly = true) + // 상품에 대한 좋아요 개수 조회 +// public int getLikesCountByProduct(Products product) { +// return userLikeRepository.countByProduct(product); +// } diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/controller/CategoryController.java b/src/main/java/com/teamjo/techeermarket/domain/products/controller/CategoryController.java index 69d21a6..eb66dc0 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/controller/CategoryController.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/controller/CategoryController.java @@ -4,6 +4,7 @@ import com.teamjo.techeermarket.domain.products.mapper.ProductMapper; import com.teamjo.techeermarket.domain.products.service.CategoryService; import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Lazy; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/dto/response/ProductPreViewDto.java b/src/main/java/com/teamjo/techeermarket/domain/products/dto/response/ProductPreViewDto.java index 1ab5c38..bf75528 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/dto/response/ProductPreViewDto.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/dto/response/ProductPreViewDto.java @@ -1,14 +1,12 @@ package com.teamjo.techeermarket.domain.products.dto.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; @Data @Builder @AllArgsConstructor @NoArgsConstructor +@Setter // 게시물 목차로 보여지는 리스트 public class ProductPreViewDto { @@ -24,10 +22,8 @@ public class ProductPreViewDto { private String createdAt ; -// private int likes ; // 좋아요수 + private int likes ; // 좋아요수 private int views; // 뷰 수 - - } diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/mapper/ProductMapper.java b/src/main/java/com/teamjo/techeermarket/domain/products/mapper/ProductMapper.java index 11b671e..3f3b24c 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/mapper/ProductMapper.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/mapper/ProductMapper.java @@ -34,5 +34,4 @@ public ProductPreViewDto fromListEntity(Products product){ .build(); } - } diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/service/CategoryService.java b/src/main/java/com/teamjo/techeermarket/domain/products/service/CategoryService.java index 07aa060..c2657dc 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/service/CategoryService.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/service/CategoryService.java @@ -38,7 +38,7 @@ public class CategoryService { public List getCategoryList (Long categoryId, int pageNo, int pageSize) { Categorys category = categoryRepository.findCategorysById(categoryId); if (category == null) { - throw new CategoryNotFoundException(); + throw new CategoryNotFoundException(); // 카테고리 확인 } Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("id").descending()); // 1페이지부터 시작하도록 Page productPage = productRepository.findByCategorys(category,pageable); @@ -47,6 +47,15 @@ public List getCategoryList (Long categoryId, int pageNo, int .collect(Collectors.toList()); } - +/* + return productPage.stream() + .map(product -> { + ProductPreViewDto productPreViewDto = productMapper.fromListEntity(product); + productPreViewDto.setLikes(userLikeService.getLikesCountByProduct(product)); + return productPreViewDto; + }) + .collect(Collectors.toList()); + } + */ } diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductService.java b/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductService.java index 9f4a0b0..5216e8d 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductService.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductService.java @@ -2,7 +2,6 @@ import com.teamjo.techeermarket.domain.images.entity.ProductImage; import com.teamjo.techeermarket.domain.images.repository.ProductImageRepository; -import com.teamjo.techeermarket.domain.images.service.ProductImageService; import com.teamjo.techeermarket.domain.products.dto.request.ProductRequestDto; import com.teamjo.techeermarket.domain.products.entity.Categorys; import com.teamjo.techeermarket.domain.products.entity.ProductState; @@ -30,7 +29,6 @@ public class ProductService { private final ProductRepository productRepository; - private final ProductImageService productImageService; @Autowired private final UserRepository userRepository; @Autowired @@ -97,7 +95,9 @@ public Long saveProduct(ProductRequestDto request, String email) throws IOExcept - // 게시물 전체 조회 + /* + // 상품 게시물 전체 조회 + */ diff --git a/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductSubService.java b/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductSubService.java index 8737088..7880c55 100644 --- a/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductSubService.java +++ b/src/main/java/com/teamjo/techeermarket/domain/products/service/ProductSubService.java @@ -112,6 +112,13 @@ public void likeProduct(String email, Long productId) { Products products = productRepository.findById(productId) .orElseThrow(ProductNotFoundException::new); + /* + 아래 조건 추가 하도록 수정 + //addGoodPoint는 좋아요를 추가하는 메소드로써 이미 좋아요가 되어있는 글이라면 예외처리된다. + //deleteGoodPoint는 좋아요를 철회하는 메소드로써 좋아요된 이력이 없다면 예외처리된다. + // 커스텀 익셉션은 추후에 추가하기로하고 임시방편으로 런타임 익셉션을 사용하도록 하였다. + */ + // 사용자가 해당 상품에 이미 좋아요를 누른 적이 없으면 if (!userLikeRepository.existsByUsersAndProducts(users, products)) { // 좋아요 정보를 생성하여 저장 diff --git a/src/main/java/com/teamjo/techeermarket/global/exception/ErrorResponse.java b/src/main/java/com/teamjo/techeermarket/global/exception/ErrorResponse.java index 73a318f..883d301 100644 --- a/src/main/java/com/teamjo/techeermarket/global/exception/ErrorResponse.java +++ b/src/main/java/com/teamjo/techeermarket/global/exception/ErrorResponse.java @@ -25,4 +25,5 @@ public ErrorResponse(ErrorCode code){ this.code = code.getCode(); } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5a1113b..3efdebd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,15 +19,11 @@ hibernate: format_sql: true - - servlet: multipart: max-file-size: 1000MB max-request-size: 1000MB - - jwt.secret : kJlkhRU-b-p3nwYgbeNpgVii1rssccUKOP4yaUjeHbM logging: