@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import com.example.demo.entity.Book_collectionEntity ;
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.SearchConditionBookForm ;
import com.example.demo.model.LeadingListModel ;
@@ -155,4 +156,44 @@ public class ReturnService {
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 ( ) ;
}
}