Skip to content

Commit

Permalink
Merge pull request #171 from nhnacademy-be4-ckin/develop
Browse files Browse the repository at this point in the history
[DEPLOY] 배포
  • Loading branch information
nueag authored Mar 23, 2024
2 parents aa7fcc1 + 6c6b3bd commit f781bc0
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ResponseEntity<Void> updateAddress(@PathVariable("memberId") Long memberId,

@PutMapping("/addresses/{addressId}/default")
ResponseEntity<Void> setDefaultAddress(@PathVariable("memberId") Long memberId,
@PathVariable("addressId") Long addressId) {
@PathVariable("addressId") Long addressId) {
addressService.setDefaultAddress(memberId, addressId);

return ResponseEntity.status(HttpStatus.OK).build();
Expand All @@ -74,7 +74,7 @@ ResponseEntity<Void> deleteAddress(@PathVariable("memberId") Long memberId,
return ResponseEntity.status(HttpStatus.OK).build();
}

@ExceptionHandler({ MemberNotFoundException.class, AddressNotFoundException.class })
@ExceptionHandler({MemberNotFoundException.class, AddressNotFoundException.class})
public ResponseEntity<Void> handleNotFoundException() {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public List<MemberAddressResponseDto> getMemberAddressList(Long memberId) {
address.detail,
address.alias,
address.isDefault
))
))
.where(address.member.id.eq(memberId))
.fetch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public AuthorResponseDto updateAuthor(Long authorId, AuthorModifyRequestDto auth
Author existingAuthor = authorRepository.findById(authorId)
.orElseThrow(() -> new AuthorNotFoundException(authorId));

existingAuthor.updateAuthor(authorModifyRequestDto.getAuthorName());
existingAuthor.updateAuthor(authorModifyRequestDto.getAuthorName());

return AuthorResponseDto.builder()
.authorId(existingAuthor.getAuthorId())
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/store/ckin/api/book/controller/BookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,17 @@ public ResponseEntity<Page<BookResponseDto>> getRecentPublishedBook(@PageableDef
return ResponseEntity.ok().body(recentBookPage);
}

/**
* 인기도서, 추천도서 등을 태그 이름을 통해 가져옵니다.
*
* @param pageable 페이지 정보
* @return 도서 페이지 목록
*/
@GetMapping("/tag/{tagName}")
public ResponseEntity<Page<BookResponseDto>> getBookPageByTagName(@PageableDefault(size = 8) Pageable pageable,
@PathVariable("tagName") String tagName) {
Page<BookResponseDto> bookPageByTagName = bookService.getBookPageByTagName(pageable, tagName);

return ResponseEntity.ok().body(bookPageByTagName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public interface BookRepositoryCustom {
/**
* 태그 이름을 가진 도서 목록을 가져옵니다.
*
* @param limit 최대로 가져올 도서의 개수
* @param limit 최대로 가져올 도서의 개수
* @param tagName 태그 이름
* @return 도서 목록
*/
Expand All @@ -91,4 +91,13 @@ public interface BookRepositoryCustom {
* @return 신간 도서 페이지 목록
*/
Page<BookResponseDto> getRecentPublished(Pageable pageable);


/**
* 인기도서, 추천도서 등을 태그 이름을 통해 가져옵니다.
*
* @param pageable 페이지 정보
* @return 도서 페이지 목록
*/
Page<BookResponseDto> getBookPageByTagName(Pageable pageable, String tagName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.util.Calendar;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -362,24 +361,6 @@ public List<BookMainPageResponseDto> getMainPageBooksByTagName(Integer limit, St

@Override
public Page<BookResponseDto> getRecentPublished(Pageable pageable) {
List<String> authorNames = from(book)
.leftJoin(bookAuthor)
.on(book.bookId.eq(bookAuthor.book.bookId))
.select(author.authorName)
.fetch();

List<String> categoryNames = from(book)
.leftJoin(bookCategory)
.on(book.bookId.eq(bookCategory.book.bookId))
.select(category.categoryName)
.fetch();

List<String> tagNames = from(book)
.leftJoin(bookTag)
.on(book.bookId.eq(bookTag.book.bookId))
.select(tag.tagName)
.fetch();

List<BookResponseDto> results = from(book)
.leftJoin(book.authors, bookAuthor)
.leftJoin(bookAuthor.author, author)
Expand Down Expand Up @@ -408,25 +389,94 @@ public Page<BookResponseDto> getRecentPublished(Pageable pageable) {
.orderBy(book.bookPublicationDate.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.distinct()
.fetch();

results.forEach(bookResponseDto -> bookResponseDto.updateList(authorNames, categoryNames, tagNames));
List<BookResponseDto> resultList = results.stream().map(book -> {
List<String> tagNames = from(tag)
.leftJoin(bookTag)
.on(tag.tagId.eq(bookTag.tag.tagId))
.where(bookTag.book.bookId.eq(book.getBookId()))
.select(tag.tagName)
.fetch();
List<String> authorNames = from(author)
.leftJoin(bookAuthor)
.on(author.authorId.eq(bookAuthor.author.authorId))
.where(bookAuthor.book.bookId.eq(book.getBookId()))
.select(author.authorName)
.fetch();
List<String> categoryNames = from(category)
.leftJoin(bookCategory)
.on(category.categoryId.eq(bookCategory.category.categoryId))
.where(bookCategory.book.bookId.eq(book.getBookId()))
.select(category.categoryName)
.fetch();
book.updateList(authorNames, categoryNames, tagNames);
return book;
}).collect(Collectors.toList());


return new PageImpl<>(resultList, pageable, resultList.size());
}

long count = from(book)
@Override
public Page<BookResponseDto> getBookPageByTagName(Pageable pageable, String tagName) {
List<BookResponseDto> results = from(book)
.leftJoin(book.authors, bookAuthor)
.leftJoin(bookAuthor.author, author)
.leftJoin(book.categories, bookCategory)
.leftJoin(bookCategory.category, category)
.leftJoin(book.tags, bookTag)
.leftJoin(bookTag.tag, tag)
.leftJoin(book.thumbnail, file)
.select(book.count())
.orderBy(book.bookPublicationDate.desc())
.select(new QBookResponseDto(
book.bookId,
book.bookIsbn,
book.bookTitle,
book.bookDescription,
book.bookPublisher,
book.bookPublicationDate,
book.bookIndex,
book.bookPackaging,
book.bookStock,
book.bookRegularPrice,
book.bookDiscountRate,
book.bookState,
book.bookSalePrice,
book.bookReviewRate,
file.fileUrl
))
.where(tag.tagName.eq(tagName))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetchOne();
.distinct()
.fetch();

return new PageImpl<>(results, pageable, count);
List<BookResponseDto> resultList = results.stream().map(book -> {
List<String> tagNames = from(tag)
.leftJoin(bookTag)
.on(tag.tagId.eq(bookTag.tag.tagId))
.where(bookTag.book.bookId.eq(book.getBookId()))
.select(tag.tagName)
.fetch();
List<String> authorNames = from(author)
.leftJoin(bookAuthor)
.on(author.authorId.eq(bookAuthor.author.authorId))
.where(bookAuthor.book.bookId.eq(book.getBookId()))
.select(author.authorName)
.fetch();
List<String> categoryNames = from(category)
.leftJoin(bookCategory)
.on(category.categoryId.eq(bookCategory.category.categoryId))
.where(bookCategory.book.bookId.eq(book.getBookId()))
.select(category.categoryName)
.fetch();
book.updateList(authorNames, categoryNames, tagNames);
return book;
}).collect(Collectors.toList());


return new PageImpl<>(resultList, pageable, resultList.size());
}


Expand Down
9 changes: 9 additions & 0 deletions src/main/java/store/ckin/api/book/service/BookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public interface BookService {
* @return 신간 도서 페이지 목록
*/
Page<BookResponseDto> getRecentPublished(Pageable pageable);


/**
* 인기도서, 추천도서 등을 태그 이름을 통해 가져옵니다.
*
* @param pageable 페이지 정보
* @return 도서 페이지 목록
*/
Page<BookResponseDto> getBookPageByTagName(Pageable pageable, String tagName);
}


Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ public List<BookExtractionResponseDto> getExtractBookListByBookIds(List<Long> bo

@Override
public List<BookMainPageResponseDto> getMainPageBookListByCategoryId(Long categoryId, Integer limit) {
return bookRepository.getMainPageResponseDtoByCategoryId(categoryId,limit);
return bookRepository.getMainPageResponseDtoByCategoryId(categoryId, limit);
}

@Override
public List<BookMainPageResponseDto> getMainPageBookListOrderByBookPublicationDate( Integer limit) {
public List<BookMainPageResponseDto> getMainPageBookListOrderByBookPublicationDate(Integer limit) {
return bookRepository.getMainPageResponseDtoOrderByBookPublicationDate(limit);
}

Expand All @@ -248,6 +249,11 @@ public Page<BookResponseDto> getRecentPublished(Pageable pageable) {
return bookRepository.getRecentPublished(pageable);
}

@Override
public Page<BookResponseDto> getBookPageByTagName(Pageable pageable, String tagName) {
return bookRepository.getBookPageByTagName(pageable, tagName);
}


/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public interface MemberService {
/**
* 취소된 주문의 포인트를 업데이트하는 메서드입니다.
*
* @param saleId 주문 ID
* @param memberEmail 회원 이메일
* @param saleId 주문 ID
* @param memberEmail 회원 이메일
*/
void updateCancelSalePoint(Long saleId, String memberEmail);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package store.ckin.api.payment.service.impl;

import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
Expand Down Expand Up @@ -41,8 +42,8 @@ public void createPayment(Long saleId, PaymentRequestDto requestDto) {
.sale(sale)
.paymentKey(requestDto.getPaymentKey())
.paymentStatus(requestDto.getPaymentStatus())
.requestedAt(requestDto.getRequestedAt())
.approvedAt(requestDto.getApprovedAt())
.requestedAt(requestDto.getRequestedAt().plusHours(9))
.approvedAt(Objects.nonNull(requestDto.getApprovedAt()) ? requestDto.getApprovedAt().plusHours(9) : null)
.receipt(requestDto.getReceiptUrl())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ReviewController {
* 리뷰 업로드를 구현하는 메소드 입니다.
*
* @param createRequestDto 도서 아이디, 리뷰 점수, 리뷰 코멘트를 담고 있는 DTO 입니다.
* @param imageList 리뷰의 이미지 리스트를 담고 있는 MultipartFile 리스트 입니다.
* @param imageList 리뷰의 이미지 리스트를 담고 있는 MultipartFile 리스트 입니다.
*/
@PostMapping("/review")
public ResponseEntity<Void> postReview(@RequestPart ReviewCreateRequestDto createRequestDto,
Expand Down Expand Up @@ -90,7 +90,7 @@ public ResponseEntity<Page<MyPageReviewResponseDto>> getReviewPageListByMemberId
public ResponseEntity<Void> updateReview(@RequestBody ReviewUpdateRequestDto updateRequestDto,
@PathVariable Long memberId) {

reviewFacade.updateReview(updateRequestDto,memberId);
reviewFacade.updateReview(updateRequestDto, memberId);

return ResponseEntity.status(HttpStatus.OK).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import store.ckin.api.sale.entity.DeliveryStatus;
import store.ckin.api.sale.entity.SalePaymentStatus;
import store.ckin.api.sale.entity.Sale;
import store.ckin.api.sale.entity.SalePaymentStatus;

/**
* 주문 조회 응답 DTO.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import store.ckin.api.book.exception.BookNotFoundException;
import store.ckin.api.member.exception.MemberAlreadyExistsException;
import store.ckin.api.member.exception.MemberNotFoundException;
import store.ckin.api.wishlist.exception.WishListAlreadyExistsException;
import store.ckin.api.wishlist.service.WishListService;
Expand Down Expand Up @@ -38,7 +42,7 @@ public ResponseEntity<Void> addWishList(@PathVariable("memberId") Long memberId,
*/
@DeleteMapping("/members/{memberId}/wish-list/{bookId}")
public ResponseEntity<Void> deleteWishList(@PathVariable("memberId") Long memberId,
@PathVariable("bookId") Long bookId) {
@PathVariable("bookId") Long bookId) {
wishListService.deleteWishList(memberId, bookId);

return ResponseEntity.status(HttpStatus.OK).build();
Expand Down
8 changes: 1 addition & 7 deletions src/main/resources/application-prod1.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# DBCP2 - Connection Pool
ckin.mysql.url=8086208c84d048bd951118257c4b0faf

eureka.instance.instance-id=api-1
eureka.instance.hostname=api1
eureka.instance.ip-address=133.186.247.149

# Eureka config
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=30s

spring.application.name=ckin-api-service
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
eureka.instance.prefer-ip-address =true
eureka.instance.prefer-ip-address=true
eureka.client.service-url.defaultZone=http://admin:[email protected]:8761/eureka

management.endpoint.health.status.order=DOWN, UP
management.endpoint.jolokia.enabled=true
management.endpoint.metrics.enabled=true
Expand All @@ -24,12 +20,10 @@ management.endpoint.restart.enabled=true
management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=*
management.info.env.enabled=true

ckin.mysql.initial-size=20
ckin.mysql.max-total=20
ckin.mysql.max-idle=20
ckin.mysql.min-idle=20
ckin.mysql.max-wait=20

# profile
ckin.profile=api1
Loading

0 comments on commit f781bc0

Please sign in to comment.