4、models
BookModel
package org.app
package models
// 图书类
// id, 书名,作者,available:是否可外借
case class BookModel(id: Int, name: String, author: String, var available:Boolean){
override def toString: String = {
val availableStr = if(available) "可外借" else "已借出"
s"编号:$id \t $name \t $author, $availableStr"
}
}
BorrowRecordModel
package org.app
package models
// 借阅记录类
case class BorrowRecordModel(
userName: String, // 借书人
bookID:Int, // 书ID
bookName: String, // 书名
borrowDate: String, // 借书日期
returnDate: Option[String] = None // 归还日期
)
UserModel
package org.app
package models
case class UserModel(
username:String,
password:String,
role: String // 普通用户,管理员
) {
}