diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index e7a1e28e..f1968255 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -9,7 +9,9 @@ on: branches: [ "main", "dev" ] # master branch로 pull request될 때 실행 env: + # 아무거나 해도 됨 PROJECT_NAME: nabi + # aws 이름 똑같아야됨 BUCKET_NAME: team-01-bucket CODE_DEPLOY_APP_NAME: team01-codedeploy DEPLOYMENT_GROUP_NAME: team01-instance-group @@ -64,29 +66,29 @@ jobs: run: ./gradlew build shell: bash - - name: Make zip file - run: zip -r ./$GITHUB_SHA.zip . - shell: bash - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_KEY }} - aws-region: ap-northeast-2 - - # script files 복사 - - name: Copy script - run: cp ./scripts/*.sh ./deploy - - # S3에 빌드 결과 업로드 - - name: Upload to S3 - run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip - - # Deploy 실행 - - name: Code Deploy To EC2 instance - run: aws deploy create-deployment - --application-name $CODE_DEPLOY_APP_NAME - --deployment-config-name CodeDeployDefault.AllAtOnce - --deployment-group-name $DEPLOYMENT_GROUP_NAME - --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip +# - name: Make zip file +# run: zip -r ./$GITHUB_SHA.zip . +# shell: bash +# +# - name: Configure AWS credentials +# uses: aws-actions/configure-aws-credentials@v1 +# with: +# aws-access-key-id: ${{ secrets.ACCESS_KEY }} +# aws-secret-access-key: ${{ secrets.SECRET_KEY }} +# aws-region: ap-northeast-2 +# +# # script files 복사 +# - name: Copy script +# run: cp ./scripts/*.sh ./deploy +# +# # S3에 빌드 결과 업로드 +# - name: Upload to S3 +# run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip +# +# # Deploy 실행 +# - name: Code Deploy To EC2 instance +# run: aws deploy create-deployment +# --application-name $CODE_DEPLOY_APP_NAME +# --deployment-config-name CodeDeployDefault.AllAtOnce +# --deployment-group-name $DEPLOYMENT_GROUP_NAME +# --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip diff --git a/build.gradle b/build.gradle index e2901112..d49ebcb0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,11 @@ plugins { id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } +// SNAPSHOT-plain 생성 막기위함 +jar { + enabled = false +} + group = 'org.prgrms' version = '0.0.1-SNAPSHOT' @@ -74,7 +79,7 @@ querydsl { sourceSets { main.java.srcDir querydslDir } -compileQuerydsl{ +compileQuerydsl { options.annotationProcessorPath = configurations.querydsl } configurations { diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardStatusUpdateRequestDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardStatusUpdateRequestDTO.java index 8dc97fba..1ab9f3bb 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardStatusUpdateRequestDTO.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardStatusUpdateRequestDTO.java @@ -4,7 +4,7 @@ import org.prgrms.nabimarketbe.global.annotation.ValidEnum; public record CardStatusUpdateRequestDTO( - @ValidEnum(enumClass = CardStatus.class, message = "유효하지 않은 상태입니다.") - CardStatus cardStatus + @ValidEnum(enumClass = CardStatus.class, message = "유효하지 않은 상태입니다.") + CardStatus status ) { } diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetailResponseDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetailResponseDTO.java index b8fc47f8..96c0e8f5 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetailResponseDTO.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetailResponseDTO.java @@ -1,8 +1,6 @@ package org.prgrms.nabimarketbe.domain.card.dto.response; -import java.time.LocalDateTime; -import java.util.List; - +import lombok.Builder; import org.prgrms.nabimarketbe.domain.card.entity.Card; import org.prgrms.nabimarketbe.domain.card.entity.CardStatus; import org.prgrms.nabimarketbe.domain.card.entity.TradeType; @@ -11,7 +9,8 @@ import org.prgrms.nabimarketbe.domain.category.entity.CategoryEnum; import org.prgrms.nabimarketbe.domain.item.entity.PriceRange; -import lombok.Builder; +import java.time.LocalDateTime; +import java.util.List; @Builder public record CardDetailResponseDTO( @@ -26,7 +25,7 @@ public record CardDetailResponseDTO( Integer viewCount, PriceRange priceRange, String content, - CardStatus cardStatus, + CardStatus status, TradeType tradeType, String tradeArea, Integer dibCount, @@ -50,7 +49,7 @@ public static CardDetailResponseDTO of( .viewCount(card.getViewCount()) .priceRange(card.getItem().getPriceRange()) .content(card.getContent()) - .cardStatus(card.getStatus()) + .status(card.getStatus()) .tradeType(card.getTradeType()) .tradeArea(card.getTradeArea()) .dibCount(card.getDibCount()) diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java index bf369742..31fd878a 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java @@ -1,9 +1,6 @@ package org.prgrms.nabimarketbe.domain.card.service; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - +import lombok.RequiredArgsConstructor; import org.prgrms.nabimarketbe.domain.card.dto.request.CardCreateRequestDTO; import org.prgrms.nabimarketbe.domain.card.dto.request.CardStatusUpdateRequestDTO; import org.prgrms.nabimarketbe.domain.card.dto.request.CardUpdateRequestDTO; @@ -38,7 +35,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import lombok.RequiredArgsConstructor; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; @Service @RequiredArgsConstructor @@ -61,14 +60,14 @@ public class CardService { @Transactional public CardResponseDTO createCard( - String token, - CardCreateRequestDTO cardCreateRequestDTO + String token, + CardCreateRequestDTO cardCreateRequestDTO ) { User user = userRepository.findById(checkService.parseToken(token)) - .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); + .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); Category category = categoryRepository.findCategoryByCategoryName(cardCreateRequestDTO.category()) - .orElseThrow(() -> new BaseException(ErrorCode.CATEGORY_NOT_FOUND)); + .orElseThrow(() -> new BaseException(ErrorCode.CATEGORY_NOT_FOUND)); Item item = cardCreateRequestDTO.toItemEntity(category); @@ -108,7 +107,7 @@ public CardResponseDTO updateCardById( CardUpdateRequestDTO cardUpdateRequestDTO ) { Long userId = checkService.parseToken(token); - if (userRepository.existsById(userId)) { + if (!userRepository.existsById(userId)) { throw new BaseException(ErrorCode.USER_NOT_FOUND); } @@ -162,44 +161,44 @@ public CardResponseDTO updateCardById( return new CardResponseDTO<>(cardUpdateResponseDTO); } - @Transactional(readOnly = true) - public CardUserResponseDTO getCardById( - String token, - Long cardId - ) { - Card card = cardRepository.findById(cardId) - .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); + @Transactional(readOnly = true) + public CardUserResponseDTO getCardById( + String token, + Long cardId + ) { + Card card = cardRepository.findById(cardId) + .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); - Boolean isMyDib = false; + Boolean isMyDib = false; - if(token != null) { - Long userId = checkService.parseToken(token); - User loginUser = userRepository.findById(userId) - .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); + if (token != null) { + Long userId = checkService.parseToken(token); + User loginUser = userRepository.findById(userId) + .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); - if (!checkService.isEqual(userId, card.getUser().getUserId())) { - card.updateViewCount(); - isMyDib = dibRepository.existsDibByCardAndUser(card, loginUser); - } - } + if (!checkService.isEqual(userId, card.getUser().getUserId())) { + card.updateViewCount(); + isMyDib = dibRepository.existsDibByCardAndUser(card, loginUser); + } + } - User cardOwner = card.getUser(); + User cardOwner = card.getUser(); - List cardImages = cardImageRepository.findAllByCard(card); + List cardImages = cardImageRepository.findAllByCard(card); - CardDetailResponseDTO cardInfo = CardDetailResponseDTO.of( - card, - cardImages, - isMyDib - ); + CardDetailResponseDTO cardInfo = CardDetailResponseDTO.of( + card, + cardImages, + isMyDib + ); - UserSummaryResponseDTO userInfo = UserSummaryResponseDTO.from(cardOwner); + UserSummaryResponseDTO userInfo = UserSummaryResponseDTO.from(cardOwner); - return CardUserResponseDTO.of( - cardInfo, - userInfo - ); - } + return CardUserResponseDTO.of( + cardInfo, + userInfo + ); + } @Transactional(readOnly = true) public CardPagingResponseDTO getCardsByCondition( @@ -227,7 +226,7 @@ public CardListResponseDTO getSuggestionAvailableCard ) { Long userId = checkService.parseToken(token); User requestUser = userRepository.findById(userId) - .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); + .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); Card suggestionTargetCard = cardRepository.findById(targetCardId) .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); @@ -282,7 +281,7 @@ public void updateCardStatusById( throw new BaseException(ErrorCode.USER_NOT_MATCHED); } - switch (cardStatusUpdateRequestDTO.cardStatus()) { + switch (cardStatusUpdateRequestDTO.status()) { case TRADE_AVAILABLE -> card.updateCardStatusToTradeAvailable(); case RESERVED -> card.updateCardStatusToReserved(); case TRADE_COMPLETE -> card.updateCardStatusToTradeComplete(); @@ -308,7 +307,7 @@ public void deleteCardById( cardRepository.delete(card); } - + @Transactional public List getSuggestionResultCardList( Long targetId, @@ -334,8 +333,7 @@ private List parseCardListWithPokeAndOffer( .peek(cardSuggestionResponseDTO -> { if (targetPriceRange.isHigherThan(cardSuggestionResponseDTO.getCardInfo().getPriceRange())) { cardSuggestionResponseDTO.getSuggestionInfo().updateSuggestionType(SuggestionType.POKE); - } - else { + } else { cardSuggestionResponseDTO.getSuggestionInfo().updateSuggestionType(SuggestionType.OFFER); } }).toList(); @@ -357,7 +355,7 @@ private List parseCardListWithOnlyOffer( return offerOnlyCardList; } - + private List addThumbnail( List cardImages, CardImage thumbnail diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/cardimage/repository/CardImageBatchRepository.java b/src/main/java/org/prgrms/nabimarketbe/domain/cardimage/repository/CardImageBatchRepository.java index 51495c6e..729093a2 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/cardimage/repository/CardImageBatchRepository.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/cardimage/repository/CardImageBatchRepository.java @@ -19,7 +19,7 @@ public class CardImageBatchRepository { private static final String sql = "INSERT INTO card_images (created_date, modified_date, image_url, card_id) VALUES (?, ?, ?, ?)"; - private static final Integer SUCCESS_SIGNAL = -2; + private static final Integer SUCCESS_SIGNAL = 1; @Transactional public boolean saveAll(List cardImages) { @@ -27,14 +27,14 @@ public boolean saveAll(List cardImages) { cardImages, cardImages.size(), (PreparedStatement preparedStatement, CardImage cardImage) -> { - preparedStatement.setTimestamp(1,Timestamp.valueOf(LocalDateTime.now())); - preparedStatement.setTimestamp(2,Timestamp.valueOf(LocalDateTime.now())); + preparedStatement.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now())); + preparedStatement.setTimestamp(2, Timestamp.valueOf(LocalDateTime.now())); preparedStatement.setString(3, cardImage.getImageUrl()); - preparedStatement.setLong(4,cardImage.getCard().getCardId()); + preparedStatement.setLong(4, cardImage.getCard().getCardId()); }); for (int[] value : result) { - if ( value[0] != SUCCESS_SIGNAL) { + if (value[0] != SUCCESS_SIGNAL) { return false; } } diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserSummaryResponseDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserSummaryResponseDTO.java index a18d2fc7..2c1c9f1d 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserSummaryResponseDTO.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserSummaryResponseDTO.java @@ -5,15 +5,15 @@ @Builder public record UserSummaryResponseDTO( - Long userId, - String nickname, - String profileUrl + Long userId, + String nickname, + String imageUrl ) { - public static UserSummaryResponseDTO from(User user) { - return UserSummaryResponseDTO.builder() - .userId(user.getUserId()) - .nickname(user.getNickname()) - .profileUrl(user.getImageUrl()) - .build(); - } + public static UserSummaryResponseDTO from(User user) { + return UserSummaryResponseDTO.builder() + .userId(user.getUserId()) + .nickname(user.getNickname()) + .imageUrl(user.getImageUrl()) + .build(); + } } diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserUpdateResponseDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserUpdateResponseDTO.java index c86b4f2e..7e58458c 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserUpdateResponseDTO.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/user/dto/response/UserUpdateResponseDTO.java @@ -6,15 +6,15 @@ @Builder public record UserUpdateResponseDTO( - Long userId, - String nickname, - String profileUrl + Long userId, + String nickname, + String imageUrl ) { - public static UserUpdateResponseDTO from(User user) { - return UserUpdateResponseDTO.builder() - .userId(user.getUserId()) - .nickname(user.getNickname()) - .profileUrl(user.getImageUrl()) - .build(); - } + public static UserUpdateResponseDTO from(User user) { + return UserUpdateResponseDTO.builder() + .userId(user.getUserId()) + .nickname(user.getNickname()) + .imageUrl(user.getImageUrl()) + .build(); + } }