Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

학원 상세보기 시도 중 #363

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/main/java/com/green/acamatch/book/BookMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface BookMapper {
List<BookGetRes> getBookListByClassId(Long classId);
List<GetBookListByAcaNameBookNameRes> getBookListByAcaNameBookName(GetBookListByAcaNameBookNameReq req);
GetBookInfo getBookInfo(long bookId);
long getProductIdByBookId(long bookId);
}
15 changes: 15 additions & 0 deletions src/main/java/com/green/acamatch/book/BookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ public int updateBook(BookUpdateReq req, MultipartFile file) {
bookMessage.setMessage("책 수량을 입력하지 않았습니다.");
return 0;
}
book.setBookAmount(req.getBookAmount());

if(file == null){
bookMessage.setMessage("책 사진을 입력하지 않았습니다.");
String originalPicName = book.getBookPic();
book.setBookPic(originalPicName);
bookRepository.save(book);

long productId = bookMapper.getProductIdByBookId(req.getBookId());
Product product = productRepository.findById(productId).orElse(null);
product.setProductName(req.getBookName());
product.setProductPrice(req.getBookPrice());
productRepository.save(product);

return 1;
}
String savedPicName = myFileUtils.makeRandomFileName(file);
Expand All @@ -139,6 +147,13 @@ public int updateBook(BookUpdateReq req, MultipartFile file) {

bookRepository.save(book);
}

long productId = bookMapper.getProductIdByBookId(req.getBookId());
Product product = productRepository.findById(productId).orElse(null);
product.setProductName(req.getBookName());
product.setProductPrice(req.getBookPrice());
productRepository.save(product);

bookMessage.setMessage("수정 완료");
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public class GetBookInfo {
private String manager;
private long classId;
private String createdAt;
private long productId;
}
17 changes: 17 additions & 0 deletions src/main/java/com/green/acamatch/config/SwaggerConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand Down Expand Up @@ -53,5 +54,21 @@ public OpenAPI openAPI() {
);
}

@Bean
public GroupedOpenApi groupAcademyApi() {
return GroupedOpenApi.builder()
.group("Academy")
.pathsToMatch("/api/academy/**")
.build();
}

@Bean
public GroupedOpenApi groupAcademyCostApi() {
return GroupedOpenApi.builder()
.group("결제")
.pathsToMatch("/api/academyCost/**", "/api/book/**", "/api/refund/**")
.build();
}


}
2 changes: 1 addition & 1 deletion src/main/resources/mappers/AcademyMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@
COALESCE(R.reviewUserId, 0) AS reviewUserId,
COALESCE(R.reviewUserNickName, '') AS reviewUserNickName,
COALESCE(R.reviewClassName, '') AS reviewClassName,
COALESCE(R.banReview, '') AS banReview,
COALESCE(R.banReview, 0) AS banReview,
COALESCE(R.roleType, '') AS roleType,
COALESCE(R.joinClassId, '') AS joinClassId

Expand Down
15 changes: 12 additions & 3 deletions src/main/resources/mappers/BookMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@
LIMIT #{startIdx}, #{size}
</select>
<select id="getBookInfo">
SELECT *
FROM book
WHERE book_id = #{bookId}
SELECT B.*, P.product_id
FROM book B
JOIN product P
ON B.book_id = P.book_id
WHERE B.book_id = #{bookId}
</select>
<select id="getProductIdByBookId">
select product_id
from book B
join product P
on B.book_id = P.book_id
where B.book_id = #{bookId}
</select>
</mapper>