功能包括关于感动的名言(管理员和学生角色): 管理员和学生登录,图书管理,图书添加删除修改,图书 借阅,图书归还,图书查看,学生管理,借还管理,读者 管理,密码管理,信息修改等等功能。
环境配置: jdk1.8 + tomcat8.5 + mysql + eclispe (intellij idea,eclispe,myeclispe,sts 都支持)
项目技术: jsp +spring + springmvc + mybatis + html+ css + javascri寄明信片pt + jquery + ajax + layui+ maven等等。
@controllerpublic class readercontroller { @autowired private readerinforvice readerinforvice; @autowired private loginrvice loginrvice; @autowired private readercardrvice readercardrvice; private readerinfo getreaderinfo(long readerid, string name, string x, string birth, string address, string phone) { readerinfo readerinfo = new readerinfo(); date date = new date(); try { simpledateformat df = new simpledateformat("yyyy-mm-dd"); date = df.par(birth); } catch (parexception e) { e.printstacktrace(); } readerinfo.taddress(address); readerinfo.tname(name); readerinfo.treaderid(readerid); readerinfo.tphone(phone); readerinfo.tx(x); readerinfo.tbirth(date); return readerinfo; } @requestmapping("allreaders.html") public modelandview allbooks() { arraylist<readerinfo> readers = readerinforvice.readerinfos(); modelandview modelandview = new modelandview("admin_readers"); modelandview.addobject("readers", readers); return modelandview; } @requestmapping("reader_delete.html") public string readerdelete(httprvletrequest request, redirectattributes redirectattributes) { long readerid = long.parlong(request.getparameter("readerid")); if (readerinforvice.deletereaderinfo(readerid) && readercardrvice.deletereadercard(readerid)) { redirectattributes.addflashattribute("succ", "删除成功!"); } el { redirectattributes.addflashattribute("error", "删除失败!"); } return "redirect:/allreaders.html"; } @requestmapping("/reader_info.html") public modelandview toreaderinfo(httprvletrequest request) { readercard readercard = (readercard) request.getssion().getattribute("readercard"); readerinfo readerinfo = readerinforvice.getreaderinfo(readercard.getreaderid()); modelandview modelandview = new modelandview("reader_info"); modelandview.addobject("readerinfo", readerinfo); return modelandview; } @requestmapping("reader_edit.html") public modelandview readerinfoedit(httprvletrequest request) { long readerid = long.parlong(request.getparameter("readerid")); readerinfo readerinfo = readerinforvice.getreaderinfo(readerid); modelandview modelandview = new modelandview("admin_reader_edit"); modelandview.addobject("readerinfo", readerinfo); return modelandview; } @requestmapping("reader_edit_do.html") public string readerinfoeditdo(httprvletrequest request, string name, string x, string birth, string address, string phone, redirectattributes redirectattributes) { long readerid = long.parlong(request.getparameter("readerid")); readerinfo readerinfo = getreaderinfo(readerid, name, x, birth, address, phone); if (readerinforvice.editreaderinfo(readerinfo) && readerinforvice.editreadercard(readerinfo)) { redirectattributes.addflashattribute("succ", "读者信息修改成功!"); } el { redirectattributes.addflashattribute("error", "读者信息修改失败!"); } return "redirect:/allreaders.html"; } @requestmapping("reader_add.html") public modelandview readerinfoadd() { return new modelandview("admin_reader_add"); } @requestmapping("reader_add_do.html") public string readerinfoadddo(string name, string x, string birth, string address, string phone, string password, redirectattributes redirectattributes) { readerinfo readerinfo = getreaderinfo(0, name, x, birth, address, phone); long readerid = readerinforvice.addreaderinfo(readerinfo); readerinfo.treaderid(readerid); if (readerid > 0 && readercardrvice.addreadercard(readerinfo, password)) { redirectattributes.addflashattribute("succ", "添加读者信息成功!"); } el { redirectattributes.addflashattribute("succ", "添加读者信息失败!"); } return "redirect:/allreaders.html"; } @requestmapping("reader_info_edit.html") public modelandview readerinfoeditreader(httprvletrequest request) { readercard readercard = (readercard) request.getssion().getattribute("readercard"); readerinfo readerinfo = readerinforvice.getreaderinfo(readercard.getreaderid()); modelandview modelandview = new modelandview("reader_info_edit"); mode家国天下landview.addob唯美古诗句ject("readerinfo", readerinfo); return modelandview; } @requestmapping("reader_edit_do_r.html") public string readerinfoeditdoreader(httprvletrequest request, string name, string x, string birth, string address, string phone, redirectattributes redirectattributes) { readercard readercard = (readercard) request.getssion().getattribute("readercard"); readerinfo readerinfo = getreaderinfo(readercard.getreaderid(), name, x, birth, address, phone); if (readerinforvice.editreaderinfo(readerinfo) && readerinforvice.editreadercard(readerinfo)) { readercard readercardnew = loginrvice.findreadercardbyreaderid(readercard.getreaderid()); request.getssion().tattribute("readercard", readercardnew); redirectattributes.addflashattribute("succ", "信息修改成功!"); } el { redirectattributes.addflashattribute("error", "信息修改失败!"); } return "redirect:/reader_info.html"; }}
@controllerpublic class logincontroller { private loginrvice loginrvice; @autowired public void tloginrvice(loginrvice loginrvice) { this.loginrvice = loginrvice; } @requestmapping(value = {"/", "/login.html"}) public string tologin(httprvletrequest request) { request.getssion().invalidate(); return "index"; } @requestmapping("/logout.html") public string logout(httprvletrequest request) { request.getssion().invalidate(); return "redirect:/login.html"; } //负责处理logincheck.html请求 //请求参数会根据参数名称默认契约自动绑定到相应方法的入参中 @requestmapping(value = "/api/logincheck", method = requestmethod.post) public @responbody object logincheck(httprvletrequest request) { long id = long.parlong(request.getparameter("id")); string passwd = request.getparameter("passwd"); boolean isreader = loginrvice.hasmatchreader(id, passwd); boolean isadmin = loginrvice.hasmatchadmin(id, passwd); hashmap<string, string> res = new hashmap<>(); if (isadmin) { admin admin = new admin(); admin.tadminid(id); admin.tpassword(passwd); string urname = loginrvice.getadminurname(id); admin.turname(urname); request.getssion().tattribute("admin", admin); res.put("statecode", "1"); res.put("msg", "管理员登陆成功!"); } el if (isreader) { readercard readercard = loginrvice.findreadercardbyreaderid(id); request.getssion().tattribute("readercard", readercard); res.put("statecode", "2"); res.put("msg", "读者登陆成功!"); } el { res.put("statecode", "0"); res.put("msg", "账号或密码错误!"); } return res; } @requestmapping("/admin_main.html") public modelandview toadminmain(httprvletrespon respon) { return new modelandview("admin_main"); } @requestmapping("/reader_main.html") public modelandview toreadermain(httprvletrespon respon) { return new modelandview("reader_main"); } @requestmapping("/admin_repasswd.html") public modelandview readminpasswd() { return new modelandview("admin_repasswd"); } @requestmapping("/admin_repasswd_do") public string readminpasswddo(httprvletrequest request, string oldpasswd, string newpasswd, string renewpasswd, redirectattributes redirectattributes) { admin admin = (admin) request.getssion().getattribute("admin"); long id = admin.getadminid(); string password = loginrvice.getadminpassword(id); if (password.equals(oldpasswd)) { if (loginrvice.adminrepassword(id, newpasswd)) { redirectattributes.addflashattribute("succ", "密码修改成功!"); return "redirect:/admin_repasswd.html"; } el { redirectattributes.addflashattribute("error", "密码修改失败!"); return "redirect:/admin_repasswd.html"; } } el { redirectattributes.addflashattribute("error", "旧密码错误!"); return "redirect:/admin_repasswd.html"; } } @requestmapping("/reader_repasswd.html") public modelandview rereaderpasswd() { return new modelandview("reader_repasswd"); } @requestmapping("/reader_repasswd_do") public string rereaderpasswddo(httprvletrequest request, string oldpasswd, string newpasswd, string renewpasswd, redirectattributes redirectattributes) { readercard reader = (readercard) request.getssion().getattribute("readercard"); long id = reader.getreaderid(); string password = loginrvice.getreaderpassword(id); if (password.equals(oldpasswd)) { if (loginrvice.readerrepassword(id, newpasswd)) { redirectattributes.addflashattribute("succ", "密码修改成功!"); return "redirect:/reader_repasswd.html"; } el { redirectattributes.addflashattribute("error", "密码修改失败!"); return "redirect:/reader_repasswd.html"; } } el { redirectattributes.addflashattribute("error", "旧密码错误!"); return "redirect:/reader_repasswd.html"; } } //配置404页面 @requestmapping("*") public string notfind() { return "404"; } }
@controllerpublic class bookcontroller { @autowired private bookrvice bookrvice; @autowired private lendrvice lendrvice; private date getdate(string pubstr) { try { simpledateformat df = new simpledateformat("yyyy-mm-dd"); return df.par(pubstr); } catch (parexception e) { e.printstacktrace(); return new date(); } } @requestmapping("/querybook.html") public modelandview querybookdo(string archword) { if (bookrvice.matchbook(archword)) { arraylist<book> books = bookrvice.querybook(archword); modelandview modelandview = new modelandview("admin_books"); modelandview.addobject("books", books); return modelandview; } el { return new modelandview("admin_books", "error", "没有匹配的图书"); } } @requestmapping("/reader_querybook_do.html") public modelandview readerquerybookdo(string archword) { if (bookrvice.matchbook(archword)) { arraylist<book> books = bookrvice.querybook(archword); modelandview modelandview = new modelandview("reader_books"); modelandview.addobject("books", books); return modelandview; } el { return new modelandview("reader_books", "error", "没有匹配的图书"); } } @requestmapping("/admin_books.html") public modelandview adminbooks() { arraylist<book> books = bookrvice.getallbooks(); modelandview modelandview = new modelandview("admin_books"); modelandview.addobject("books", books); return modelandview; } @requestmapping("/book_add.html") public modelandview addbook() { return new modelandview("admin_book_add"); } @requestmapping("/book_add_do.html") public string addbookdo(@requestparam(value = "pubstr") string pubstr, book book, redirectattributes redirectattributes) { book.tpubdate(getdate(pubstr)); if (bookrvice.addbook(book)) { redirectattributes.addflashattribute("succ", "图书添加成功!"); } el { redirectattributes.addflashattribute("succ", "图书添加失败!"); } return "redirect:/admin_books.html"; } @requestmapping("/updatebook.html") public modelandview bookedit(httprvletrequest request) { long bookid = long.parlong(request.getparameter("bookid")); book book = bookrvice.getbook(bookid); modelandview modelandview = new modelandview("admin_book_edit"); modelandview.addobject("detail", book); return modelandview; } @requestmapping("/book_edit_do.html") public string bookeditdo(@requestparam(value = "pubstr") string pubstr, book book, redirectattributes redirectattributes) { book.tpubdate(getdate(pubstr)); if (bookrvice.editbook(book)) { redirectattributes.addflashattribute("succ", "图书修改成功!"); } el { redirectattributes.addflashattribute("error", "图书修改失败!"); } return "redirect:/admin_books.html"; } @requestmapping("/admin_book_detail.html") public modelandview adminbookdetail(httprvletrequest request) { long bookid = long.parlong(request.getparameter("bookid")); book book = bookrvice.getbook(bookid); modelandview modelandview = new modelandview("admin_book_detail"); modelandview.addobject("detail", book); return modelandview; } @requestmapping("/reader_book_detail.html") public modelandview readerbookdetail(httprvletrequest request) { long bookid = long.parlong(request.getparameter("bookid")); book book = bookrvice.getbook(bookid); modelandview modelandview = new modelandview("reader_book_detail"); modelandview.addobject("detail", book); return modelandview; } @requestmapping("/admin_header.html") public modelandview admin_header() { return new modelandview("admin_header"); } @requestmapping("/reader_header.html") public modelandview reader_header() { return new modelandview("reader_header"); } @requestmapping("/reader_books.html") public modelandview readerbooks(httprvletrequest request) { arraylist<book> books = bookrvice.getallbooks(); 中秋祝福语 readercard readercard = (readercard) request.getssion().getattribute("readercard"); arraylist<lend> myalllendlist = lendrvice.mylendlist(readercard.getreaderid()); arraylist<long> mylendlist = new arraylist<>(); for (lend lend : myalllendlist) { // 是否已归还 if (lend.getbackdate() == null) { mylendlist.add(lend.getbookid()); } } modelandview modelandview = new modelandview("reader_books"); modelandview.addobject("books", books); modelandview.addobject("mylendlist", mylendlist); return modelandview; }}
@controllerpublic class lendcontroller { @autowired private lendrvice lendrvice; @autowired private bookrvice bookrvice; @requestmapping("/deletebook.html") public string deletebook(httprvletrequest request, redirectattributes redirectattributes) { long bookid = long.parlong(request.getparameter("bookid")); if (bookrvice.deletebook(bookid)) { redirectattributes.addflashattribute("succ", "图书删除成功!"); } el { redirectattributes.addflashattribute("error", "图书删除失败!"); } return "redirect:/admin_books.html"; } @requestmapping("/lendlist.html") public modelandview lendlist(httprvletrequest request) { modelandview modelandview = new modelandview("admin_lend_list"); modelandview.addobject("list", lendrvice.lendlist()); return modelandview; } @requestmapping("/mylend.html") public modelandview mylend(httprvletrequest request) { readercard readercard = (readercard) request.getssion().getattribute("readercard"); modelandview modelandview = new modelandview("reader_lend_list"); modelandview.addobject("list", lendrvice.mylendlist(readercard.getreaderid())); return modelandview; } @requestmapping("/deletelend.html") public string deletelend(httprvletrequest request, redirectattributes redirectattributes) { long rnum = long.parlong(request.getparameter("rnum")); if (lendrvice.deletelend(rnum) > 0) { redirectattributes.addflashattribute("succ", "记录删除成功!"); } el { redirectattributes.addflashattribute("error", "记录删除失败!"); } return "redirect:/lendlist.html"; } @requestmapping("/lendbook.html") public string booklend(httprvletrequest request, redirectattributes redirectattributes) { long bookid = long.parlong(request.getparameter("bookid")); long readerid = ((readercard) request.getssion().getattribute("readercard")).getreaderid(); if (lendrvice.lendbook(bookid, readerid)) { redirectattributes.addflashattribute("succ", "图书借阅成功!"); } el { redirectattributes.addflashattribute("succ", "图书借阅成功!"); } return "redirect:/reader_books.html"; } @requestmapping("/returnbook.html") public string bookreturn(httprvletrequest request, redirectattributes redirectattributes) { long bookid = long.parlong(request.getparameter("bookid")); long readerid = ((readercard) request.getssion().getattribute("readercard")).getreaderid(); if (lendrvice.returnbook(bookid, readerid)) { redirectattributes.addflashattribute("succ", "图书归还成功!"); } el { redirectattributes.addflashattribute("error", "图书归还失败!"); } return "redirect:/reader_books.html"; }}
以上就是java 实战图书管理系统的实现流程的详细内容,更多关于java 图书管理系统的资料请关注www.887551.com其它相关文章!
本文发布于:2023-04-03 22:30:35,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/2dab6bb4be887799de8bca5a819adc8a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Java 实战图书管理系统的实现流程.doc
本文 PDF 下载地址:Java 实战图书管理系统的实现流程.pdf
留言与评论(共有 0 条评论) |