Skip to content

Spring base jp#14

Open
hjp1016 wants to merge 20 commits intoJavaBasefrom
SpringBase-jp
Open

Spring base jp#14
hjp1016 wants to merge 20 commits intoJavaBasefrom
SpringBase-jp

Conversation

@hjp1016
Copy link
Copy Markdown
Contributor

@hjp1016 hjp1016 commented Dec 6, 2023

still working

NotableDeveloper and others added 10 commits November 12, 2023 10:48
- 도서 검색 기능 구현 완료
- 도서 대여 기능 구현 예정
- 책 대여하기 추가
- 책 반납하기 추가
- ResponsBody 삭제
- 조회 접근 url PathVariable로 수정
- JdbcBookRepostiory 생성
- 데이터베이스 환경변수 설정
- 구현할 함수 선언
- 책 추가기능 구현
- 책 제목,  ISBN, 작가, 카테고리 조회 기능 구현
- 책 전체 조회 구현
- 데이터 추가 컬럼 수정
- 대여, 반납 시스템 진행중
public boolean existsByIsbn(String isbn) {

try {
String sql = "select * from book where isbn=?";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL의 exists 구문을 사용하면 아래에서 count 변수를 사용하지 않아도 될 것으로 보입니다.

@Override
public Book borrowBook(String isbn){
try {
String sql = "update book set book_status = 'BORROWING' where isbn=? ";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

book_status 에 BORROWING을 하드 코딩하지 않고, PreparedStatement의 장점을 살려서 값을 추가하는 방식으로 수정 바랍니다.

@Override
public Book returnBook(String isbn){
try {
String sql = "update book set book_status = 'AVAILABLE' where isbn=? ";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

book_status 에 AVAILABLE을 하드 코딩하지 않고, PreparedStatement의 장점을 살려서 값을 추가하는 방식으로 수정 바랍니다.

}catch(SQLException e){
e.printStackTrace();
}
return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드의 반환은 null이 되어서는 안됩니다.

}catch(SQLException e){
e.printStackTrace();
}
return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드의 반환은 null이 되어서는 안됩니다.

- JpaBookRepositroy 추가
- BookService에서 JpaRepositroy 타입을 주입받도록 수정
- JdbcRepository 생성자 주석처리
- application.properties에 db 접속관련 내용추가
- 접속을 위한 환경변수 추가
- Entity 어노테이션 추가
- 기본키를 사용하는 id 값 추가
- JPA를 이용한 ISBN으로 도서 조회하기
- BookService에서 사용하는 매서드를 findByIsbn으로 수정
- 제목을 포함하는 도서 찾기 구현
- 생성한 Repository를 service에서 사용
- 저자로 도서 검색하기 기능 추가
- 추가한 메서드를 Service에서 사용
- findAllByCategory 기능 구현
- service에서  추가한 메서드를 사용하도록 수정
- enum으로 인식 할 수 있도록 어노테이션 추가
- table을 create에서 update로 변경
- Transactionl 어노테이션 추가
- 도서 대여 반납 기능 구현
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants