图书管理系统程序代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
*字段编号
*/
Private int id;
Publicvoid setId(String id){
This.id = id;
}
PublicStringgetId(){
Return id;
}
添加书籍
代码片段
Book book = new Book();
book.setId(…..);
……Βιβλιοθήκη Baidu.
Book.setTitle(….);
……..
book.setTitle(….);
returnBook .save(“returnBook”,book,student);
归还书籍
代码片段
ReturnNook returnBook = new ReturnNook();
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
Book book = newBook();
book.setId(…..);
BooksManageDao bookDao = new BooksManageDao();
bookDao .delete(“deleteBook”,book);
更新书籍
代码片段
BookDao bookDao = newBookDao();
Book book =(Book) bookDao .getModel(id);
查询用户
代码片段
//数据库的自定义一页显示10条
Int pageNo = “当前页数”
StudentDao studentDao = new StudentDao();
studentDao .select(“selectStudent”, pageNo);
借阅书籍
代码片段
Borrow borrow = new Borrow();
book.setId(…..);
……..
Book.setTitle(….);
BooksManageDao bookDao = new BooksManageDao();bookDao .update(“updateBook”,book);
查询书籍
代码片段
//数据库的自定义一页显示10条
Int pageNo = “当前页数”
Studentstudent=(Student) studentDao.getModel(id);
student.setId(…..);
……..
student.setTitle(….);
StudentDao studentDao = new StudentDao();studentDao .update(“updeteStudent”,book);
/**
*保存利用mybatis的xml
* model保存的对象
*id mybatis的id名
*/
Public void Save(BaseModelmodel,String id){
sesson.inster(idmodel);
}
……
Model基础模块
所有的模型都继承于BaseModel;
代码片段
/**
SqlSessionFactory sqlSessionFactory =newSqlSessionFactoryBuilder().build(inputStream);
SqlSession sesson = sqlSessionFactory.openSession();
Dao基础模块
所有的dao都继承于BaseDao;代码
student.setId(…..);
StudentDao studentDao = new StudentDao();studentDao .delete(“deleteStudent”,book);
更新用户
代码片段
Int id = “字段编号”
StudentDao studentDao = new StudentDao()
BooksManageDao bookDao = new BooksManageDao();
bookDao .select(“selectteBook”, pageNo);
添加用户
代码片段
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
StudentDao studentDao = new StudentDao();
studentDao .save(“addStudent”,book);
删除用户
代码片段
Int id = “字段编号”
StudentDao studentDao = new StudentDao()
Studentstudent=(Student) studentDao.getModel(id);
模块设计
基础模块
SqlSession:
利用mybatis获取jdbc,其中有inter.select,update,select等方法
String resource ="mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
Bookbook = newBook();
book.setId(…..);
……..
book.setTitle(….);
borrow .save(“borrow”,book,student);
BooksManageDao bookDao= new BooksManageDao();
bookDao .save(“addBook”,book);
删除书籍
代码片段
BookDao bookDao = newBookDao();
Book book =(Book) bookDao .getModel(id);
*/
Private int id;
Publicvoid setId(String id){
This.id = id;
}
PublicStringgetId(){
Return id;
}
添加书籍
代码片段
Book book = new Book();
book.setId(…..);
……Βιβλιοθήκη Baidu.
Book.setTitle(….);
……..
book.setTitle(….);
returnBook .save(“returnBook”,book,student);
归还书籍
代码片段
ReturnNook returnBook = new ReturnNook();
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
Book book = newBook();
book.setId(…..);
BooksManageDao bookDao = new BooksManageDao();
bookDao .delete(“deleteBook”,book);
更新书籍
代码片段
BookDao bookDao = newBookDao();
Book book =(Book) bookDao .getModel(id);
查询用户
代码片段
//数据库的自定义一页显示10条
Int pageNo = “当前页数”
StudentDao studentDao = new StudentDao();
studentDao .select(“selectStudent”, pageNo);
借阅书籍
代码片段
Borrow borrow = new Borrow();
book.setId(…..);
……..
Book.setTitle(….);
BooksManageDao bookDao = new BooksManageDao();bookDao .update(“updateBook”,book);
查询书籍
代码片段
//数据库的自定义一页显示10条
Int pageNo = “当前页数”
Studentstudent=(Student) studentDao.getModel(id);
student.setId(…..);
……..
student.setTitle(….);
StudentDao studentDao = new StudentDao();studentDao .update(“updeteStudent”,book);
/**
*保存利用mybatis的xml
* model保存的对象
*id mybatis的id名
*/
Public void Save(BaseModelmodel,String id){
sesson.inster(idmodel);
}
……
Model基础模块
所有的模型都继承于BaseModel;
代码片段
/**
SqlSessionFactory sqlSessionFactory =newSqlSessionFactoryBuilder().build(inputStream);
SqlSession sesson = sqlSessionFactory.openSession();
Dao基础模块
所有的dao都继承于BaseDao;代码
student.setId(…..);
StudentDao studentDao = new StudentDao();studentDao .delete(“deleteStudent”,book);
更新用户
代码片段
Int id = “字段编号”
StudentDao studentDao = new StudentDao()
BooksManageDao bookDao = new BooksManageDao();
bookDao .select(“selectteBook”, pageNo);
添加用户
代码片段
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
StudentDao studentDao = new StudentDao();
studentDao .save(“addStudent”,book);
删除用户
代码片段
Int id = “字段编号”
StudentDao studentDao = new StudentDao()
Studentstudent=(Student) studentDao.getModel(id);
模块设计
基础模块
SqlSession:
利用mybatis获取jdbc,其中有inter.select,update,select等方法
String resource ="mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
Studentstudent= newStudent();
student.setId(…..);
……..
student.setTitle(….);
Bookbook = newBook();
book.setId(…..);
……..
book.setTitle(….);
borrow .save(“borrow”,book,student);
BooksManageDao bookDao= new BooksManageDao();
bookDao .save(“addBook”,book);
删除书籍
代码片段
BookDao bookDao = newBookDao();
Book book =(Book) bookDao .getModel(id);