package com.library.controller;
import com.library.bean.ReaderCard;
import com.library.bean.ReaderInfo;
import com.library.bean.ReaderInfoDate;
import com.library.service.LoginService;
import com.library.service.ReaderCardService;
import com.library.service.ReaderInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.SocketUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@Controller
public class ReaderController {
@Autowired
private ReaderInfoService readerInfoService;
@Autowired
private LoginService loginService;
@Autowired
private ReaderCardService readerCardService;
private ReaderInfo getReaderInfo(long readerId, String name, String sex, String birth, String address, String phone) {
ReaderInfo readerInfo = new ReaderInfo();
Date date = new Date();
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
date = df.parse(birth);
} catch (ParseException e) {
e.printStackTrace();
}
readerInfo.setAddress(address);
readerInfo.setName(name);
readerInfo.setReaderId(readerId);
readerInfo.setPhone(phone);
readerInfo.setSex(sex);
readerInfo.setBirth(birth);
return readerInfo;
}
@RequestMapping("allreaders.html")
public ModelAndView allBooks() throws ParseException {
ArrayList<ReaderInfo> readers = readerInfoService.readerInfos();
ModelAndView modelAndView = new ModelAndView("admin_readers");
modelAndView.addObject("readers", readers);
return modelAndView;
}
@RequestMapping("reader_delete.html")
public String readerDelete(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long readerId = Long.parseLong(request.getParameter("readerId"));
if (readerInfoService.deleteReaderInfo(readerId) && readerCardService.deleteReaderCard(readerId)) {
redirectAttributes.addFlashAttribute("succ", "删除成功!");
} else {
redirectAttributes.addFlashAttribute("error", "删除失败!");
}
return "redirect:/allreaders.html";
}
@RequestMapping("reader_info.html")
public ModelAndView toReaderInfo(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());
ModelAndView modelAndView = new ModelAndView("reader_info_edit");
modelAndView.addObject("readerinfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_info_show.html")
public ModelAndView toReaderInfoShow(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());
ModelAndView modelAndView = new ModelAndView("reader_info");
modelAndView.addObject("readerinfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_edit.html")
public ModelAndView readerInfoEdit(HttpServletRequest request) {
long readerId = Long.parseLong(request.getParameter("readerId"));
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerId);
ModelAndView modelAndView = new ModelAndView("admin_reader_edit");
modelAndView.addObject("readerInfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_edit_do.html")
public String readerInfoEditDo(HttpServletRequest request, String name, String sex, String birth, String address, String phone, RedirectAttributes redirectAttributes) {
long readerId = Long.parseLong(request.getParameter("readerId"));
ReaderInfo readerInfo = getReaderInfo(readerId, name, sex, birth, address, phone);
if (readerInfoService.editReaderInfo(readerInfo) && readerInfoService.editReaderCard(readerInfo)) {
redirectAttributes.addFlashAttribute("succ", "读者信息修改成功!");
} else {
redirectAttributes.addFlashAttribute("error", "读者信息修改失败!");
}
return "redirect:/allreaders.html";
}
@RequestMapping("reader_add.html")
public ModelAndView readerInfoAdd() {
return new ModelAndView("admin_reader_add");
}
@RequestMapping("reader_add_do")
public String readerInfoAddDo(String name, String sex, String birth, String address, String phone, String password, RedirectAttributes redirectAttributes) {
ReaderInfo readerInfo = getReaderInfo(0, name, sex, birth, address, phone);
long readerId = readerInfoService.addReaderInfo(readerInfo);
readerInfo.setReaderId(readerId);
if (readerId > 0 && readerCardService.addReaderCard(readerInfo, password)) {
redirectAttributes.addFlashAttribute("succ", "添加读者信息成功!");
} else {
redirectAttributes.addFlashAttribute("succ", "添加读者信息失败!");
}
return "redirect:/allreaders.html";
}
//注册
@RequestMapping("reader_add")
public ModelAndView reader_add(String name, String sex, String birth, String address, String phone, String password, RedirectAttributes redirectAttributes) {
ReaderInfo readerInfo = getReaderInfo(0, name, sex, birth, address, phone);
long readerId = readerInfoService.addReaderInfo(readerInfo);
readerInfo.setReaderId(readerId);
if (readerId > 0 && readerCardService.addReaderCard(readerInfo, password)) {
redirectAttributes.addFlashAttribute("succ", "注册成功!");
} else {
redirectAttributes.addFlashAttribute("succ", "注册失败!");
}
return new ModelAndView("index");
}
@RequestMapping("reader_info_edit.html")
public ModelAndView readerInfoEditReader(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());
ModelAndView modelAndView = new ModelAndView("reader_info_edit");
ReaderInfoDate readerInfoDate = new ReaderInfoDate();
String format = new SimpleDateFormat("yyyy-MM-dd").format(readerInfo.getBirth());
readerInfoDate.setBirthday(format);
BeanUtils.copyProperties(readerInfo,readerInfoDate);
modelAndView.addObject("readerinfo", readerInfoDate);
return modelAndView;
}
@RequestMapping("reader_edit_do_r.html")
public String readerInfoEditDoReader(HttpServletRequest request, String name, String sex, String birth, String address, String phone, RedirectAttributes redirectAttributes) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = getReaderInfo(readerCard.getReaderId(), name, sex, birth, address, phone);
if (readerInfoService.editReaderInfo(readerInfo)) {
ReaderCard readerCardNew = loginService.findReaderCardByReaderId(readerCard.getName());
request.getSession().setAttribute("readercard", readerCardNew);
redirectAttributes.addFlashAttribute("succ", "信息修改成功!");
} else {
redirectA
没有合适的资源?快使用搜索试试~ 我知道了~
Java毕业设计项目分享
共155个文件
jsp:22个
class:22个
java:22个
需积分: 0 0 下载量 57 浏览量
2023-11-20
17:29:16
上传
评论
收藏 12.28MB ZIP 举报
温馨提示
近几年毕业设计和毕业答辩的要求和难度不断提升,传统的毕业项目缺少创新和亮点,往往达不到毕业答辩的要求,这几年教育机构专门针对各大院校毕业设计进行培训指导,衍生出很多届优秀学员的毕业项目,为了让广大同学都可以顺利通过答辩,我作为过来人给大家准备了一些资料,同学们可以互相参考,我建议大家是要有自己的想法来重构项目,而不是照搬抄袭。近几年毕业设计和毕业答辩的要求和难度不断提升,传统的毕业项目缺少创新和亮点,往往达不到毕业答辩的要求,这几年教育机构专门针对各大院校毕业设计进行培训指导,衍生出很多届优秀学员的毕业项目,为了让广大同学都可以顺利通过答辩,我作为过来人给大家准备了一些资料,同学们可以互相参考,我建议大家是要有自己的想法来重构项目,而不是照搬抄袭。
资源推荐
资源详情
资源评论
收起资源包目录
Java毕业设计项目分享 (155个子文件)
ReaderController.class 9KB
BookController.class 6KB
LoginController.class 6KB
LendController.class 6KB
ReaderCardDao.class 3KB
BookDao.class 3KB
ReaderInfoDao.class 3KB
LendDao.class 3KB
Book.class 3KB
WebConfig.class 2KB
LoginService.class 2KB
AdminDao.class 2KB
ReaderInfo.class 2KB
ReaderInfoService.class 2KB
BookService.class 2KB
LendService.class 1KB
Lend.class 1KB
ReaderCardService.class 1KB
ReaderCard.class 977B
Admin.class 939B
ReaderInfoDate.class 891B
LendDate.class 762B
.classpath 3KB
org.eclipse.wst.common.component 473B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.min.css 118KB
datepicker.css 4KB
datepicker.css 4KB
WdatePicker.css 143B
img.gif 2KB
img.gif 2KB
datePicker.gif 1KB
My97DatePicker.htm 1KB
mybatis-3.4.1.jar 1.51MB
jackson-databind-2.9.9.jar 1.29MB
spring-context-4.2.2.RELEASE.jar 1.04MB
spring-core-4.2.2.RELEASE.jar 1.02MB
mysql-connector-java-5.1.29.jar 856KB
spring-webmvc-4.2.2.RELEASE.jar 852KB
spring-web-4.2.2.RELEASE.jar 751KB
spring-beans-4.2.2.RELEASE.jar 713KB
spring-jdbc-4.2.2.RELEASE.jar 413KB
jstl-1.2.jar 405KB
spring-aop-4.2.2.RELEASE.jar 358KB
jackson-core-2.9.9.jar 318KB
spring-tx-4.2.2.RELEASE.jar 259KB
spring-expression-4.2.2.RELEASE.jar 256KB
commons-dbcp-1.4.jar 157KB
commons-pool-1.5.4.jar 94KB
javax.servlet-api-3.1.0.jar 94KB
jackson-annotations-2.9.0.jar 65KB
commons-logging-1.2.jar 59KB
mybatis-spring-1.3.0.jar 52KB
aopalliance-1.0.jar 4KB
ReaderController.java 8KB
BookController.java 6KB
LoginController.java 6KB
LendController.java 5KB
Book.java 2KB
ReaderCardDao.java 2KB
LendDao.java 2KB
ReaderInfoDao.java 2KB
BookDao.java 1KB
WebConfig.java 1KB
ReaderInfo.java 1KB
LoginService.java 1KB
AdminDao.java 1KB
ReaderInfoService.java 1KB
Lend.java 1011B
BookService.java 986B
LendService.java 902B
ReaderCardService.java 723B
ReaderCard.java 650B
Admin.java 593B
LendDate.java 567B
ReaderInfoDate.java 452B
u5.jpeg 241KB
book2(1).jpg 1.48MB
book2.jpg 211KB
wolf.jpg 109KB
sky.jpg 105KB
lizhi.jpg 93KB
u2.jpg 70KB
login_bg.jpg 45KB
timg.jpg 42KB
library1.jpg 39KB
library2.jpg 39KB
scut.jpg 28KB
u1.jpg 27KB
school.jpg 26KB
book1.jpg 26KB
library.jpg 26KB
classroom.jpg 22KB
book3.jpg 16KB
bg.jpg 307B
jquery-3.2.1.js 262KB
bootstrap.min.js 36KB
calendar.js 19KB
WdatePicker.js 8KB
register.js 5KB
共 155 条
- 1
- 2
资源评论
诚信赢天下
- 粉丝: 3140
- 资源: 102
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功