Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
341365aa81 | ||
|
|
5a5bfd9112 | ||
|
|
85d1d3715b | ||
|
|
16f4aacf23 | ||
|
|
307f8951b3 | ||
|
|
773284fd04 |
@@ -0,0 +1,18 @@
|
|||||||
|
package com.example.demo.model;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LeadingListModel {
|
||||||
|
//データの保持
|
||||||
|
private final Integer idRequest;
|
||||||
|
private final String nmBook;
|
||||||
|
private final String nmEmployee;
|
||||||
|
private final Date dateRequest;
|
||||||
|
private final Date dateBorrow;
|
||||||
|
private final Date dateScheduledReturn;
|
||||||
|
}
|
||||||
@@ -1,11 +1,28 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.example.demo.entity.Book_collectionEntity;
|
import com.example.demo.entity.Book_collectionEntity;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> {
|
public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> {
|
||||||
|
List<Book_collectionEntity> findByFlgLending(Character flgLending);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT b FROM Book_collectionEntity b
|
||||||
|
WHERE b.flgLending='0'
|
||||||
|
AND (:nmBook = '' OR b.nmBook LIKE CONCAT('%', :nmBook,'%'))
|
||||||
|
AND (:pubLisher = '' OR b.pubLisher LIKE CONCAT('%', :pubLisher,'%'))
|
||||||
|
AND (:noteText = '' OR b.noteText LIKE CONCAT('%',:noteText,'%'))
|
||||||
|
ORDER BY b.idBook
|
||||||
|
""")
|
||||||
|
List<Book_collectionEntity> searchBooks(
|
||||||
|
@Param("nmBook") String nmBook,
|
||||||
|
@Param("pubLisher") String pubLisher,
|
||||||
|
@Param(" noteText") String noteText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -7,5 +9,5 @@ import com.example.demo.entity.Borrow_booksEntity;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
|
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
|
||||||
|
List<Borrow_booksEntity> findByStatus(Character status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -8,5 +10,7 @@ import com.example.demo.entity.EmployeeEntity;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||||
|
|
||||||
|
//メールアドレスとパスワードに合致するレコード
|
||||||
|
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
package com.example.demo.service;
|
package com.example.demo.service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.entity.Book_collectionEntity;
|
||||||
import com.example.demo.entity.Borrow_booksEntity;
|
import com.example.demo.entity.Borrow_booksEntity;
|
||||||
|
import com.example.demo.form.LendingForm;
|
||||||
|
import com.example.demo.form.LoginInfoForm;
|
||||||
import com.example.demo.form.ReturnForm;
|
import com.example.demo.form.ReturnForm;
|
||||||
|
import com.example.demo.form.SearchConditionBookForm;
|
||||||
|
import com.example.demo.model.LeadingListModel;
|
||||||
import com.example.demo.repository.Book_CollectionRepository;
|
import com.example.demo.repository.Book_CollectionRepository;
|
||||||
import com.example.demo.repository.Borrow_BooksRepository;
|
import com.example.demo.repository.Borrow_BooksRepository;
|
||||||
import com.example.demo.repository.EmployeeRepository;
|
import com.example.demo.repository.EmployeeRepository;
|
||||||
@@ -94,4 +101,99 @@ public class ReturnService {
|
|||||||
book_CollectionRepository.save(book.get());
|
book_CollectionRepository.save(book.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//貸し出し可能な書籍の全権取得
|
||||||
|
public List<Book_collectionEntity> availableSelectAll() {
|
||||||
|
return book_CollectionRepository.findByFlgLending('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
//書籍名・出版社・特記事項の部分一致検索
|
||||||
|
public List<Book_collectionEntity> searchByWithLike(
|
||||||
|
SearchConditionBookForm form) {
|
||||||
|
String nmBook = form.getNmBook();
|
||||||
|
String pubLisher = form.getPubLisher();
|
||||||
|
String noteText = form.getNoteText();
|
||||||
|
nmBook = nmBook == null ? "" : nmBook;
|
||||||
|
pubLisher = pubLisher == null ? "" : pubLisher;
|
||||||
|
noteText = noteText == null ? "" : noteText;
|
||||||
|
return book_CollectionRepository.searchBooks(
|
||||||
|
nmBook,
|
||||||
|
pubLisher,
|
||||||
|
noteText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LeadingListModel> getBorrowList() {
|
||||||
|
List<LeadingListModel> result = new ArrayList<LeadingListModel>();
|
||||||
|
|
||||||
|
List<Borrow_booksEntity> borrow = borrowRepository.findByStatus('2');
|
||||||
|
for (Borrow_booksEntity borrow_booksEntity : borrow) {
|
||||||
|
String nmEmployee = employeeRepository.findById(borrow_booksEntity.getIdApplicant()).get().getNmEmployee();
|
||||||
|
String nmBook = book_CollectionRepository.findById(borrow_booksEntity.getIdBook()).get().getNmBook();
|
||||||
|
LeadingListModel a = new LeadingListModel(borrow_booksEntity.getIdRequest(),
|
||||||
|
nmEmployee,
|
||||||
|
nmBook,
|
||||||
|
borrow_booksEntity.getDateRequest(),
|
||||||
|
borrow_booksEntity.getDateBorrow(),
|
||||||
|
borrow_booksEntity.getDateScheduledReturn());
|
||||||
|
result.add(a);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//書籍貸出申請機能
|
||||||
|
public void executeLending(LendingForm form, int idEmployee) {
|
||||||
|
var book_collection = book_CollectionRepository.findById(form.getId_book());//更新したい本のEntityを取得
|
||||||
|
book_collection.get().setFlgLending('1');//フラグだけ書き換え
|
||||||
|
book_CollectionRepository.save(book_collection.get());
|
||||||
|
|
||||||
|
Borrow_booksEntity borrow = new Borrow_booksEntity();//空の申請レコード
|
||||||
|
borrow.setIdApproval(idEmployee);//申請者ID
|
||||||
|
borrow.setIdBook(form.getId_book());//蔵書ID
|
||||||
|
borrow.setDateRequest(new Date());//申請日
|
||||||
|
borrow.setStatus('1');//ステータスを承認待ちに
|
||||||
|
borrow.setIdUpdate(idEmployee);//更新者ID
|
||||||
|
borrow.setDateUpdate(new Date());//更新日
|
||||||
|
|
||||||
|
borrowRepository.save(borrow);
|
||||||
|
}
|
||||||
|
|
||||||
|
//貸出テーブルの「ステータス」が「1:承認待」の情報を全件取得
|
||||||
|
public List<LeadingListModel> getAwaitingApprovalList() {
|
||||||
|
List<LeadingListModel> result = new ArrayList<LeadingListModel>();
|
||||||
|
|
||||||
|
List<Borrow_booksEntity> borrow = borrowRepository.findByStatus('1');
|
||||||
|
for (Borrow_booksEntity borrow_booksEntity : borrow) {
|
||||||
|
String nmEmployee = employeeRepository.findById(borrow_booksEntity.getIdApplicant()).get().getNmEmployee();
|
||||||
|
String nmBook = book_CollectionRepository.findById(borrow_booksEntity.getIdBook()).get().getNmBook();
|
||||||
|
LeadingListModel a = new LeadingListModel(borrow_booksEntity.getIdRequest(),
|
||||||
|
nmEmployee,
|
||||||
|
nmBook,
|
||||||
|
borrow_booksEntity.getDateRequest(),
|
||||||
|
borrow_booksEntity.getDateBorrow(),
|
||||||
|
borrow_booksEntity.getDateScheduledReturn());
|
||||||
|
result.add(a);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//メアドとパスワードが合っていればtureで返す
|
||||||
|
public boolean canlogin(String mail, String pass) {
|
||||||
|
if (mail == null || mail.isEmpty() || pass == null || pass.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return employeeRepository.findByMailAddressAndPassword(mail, pass).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
//LoginInfoFormの情報からidEmployeeを返す
|
||||||
|
public int getUserID(LoginInfoForm form) {
|
||||||
|
return employeeRepository.findByMailAddressAndPassword(form.getMailAddress(), form.getPassword()).get()
|
||||||
|
.getIdEmployee();
|
||||||
|
}
|
||||||
|
|
||||||
|
//LoginInfoFormの情報からFlgを返す 0なら一般,1なら管理
|
||||||
|
public Character getUserFlg(LoginInfoForm form) {
|
||||||
|
return employeeRepository.findByMailAddressAndPassword(form.getMailAddress(), form.getPassword()).get()
|
||||||
|
.getFlgAdmin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user