package cn.sfturing.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.sfturing.dao.FavouriteDao;
import cn.sfturing.entity.CommonUser;
import cn.sfturing.entity.Favourite;
import cn.sfturing.entity.Hospital;
import cn.sfturing.entity.OrderRecords;
import cn.sfturing.service.CommonUserService;
import cn.sfturing.service.HospitalService;
import cn.sfturing.service.OrderRecordsService;
/**
*
* @author sfturing
*
* @date 2017年5月6日
*/
@Controller
public class CommonUserController {
@Autowired
private CommonUserService commonUserService;
@Autowired
private OrderRecordsService orderRecordsService;
@Autowired
private FavouriteDao favouriteDao;
@Autowired
private HospitalService hospitalService;
/*
* @Autowired private CommonUserDao commonUserDao;
*/
private static Logger log = LoggerFactory.getLogger(CommonUserController.class);
/**
* 用户登陆界面
*
* @return
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpSession session) {
session.invalidate();
return "user/login";
}
/**
* 用户登陆验证
*
* @param email
* @param passWord
* @param code
* @return
* @throws Exception
*/
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(Model model, String userEmail, String userPassword, HttpSession session,
HttpServletRequest request) {
// 登录用户,并将登录后的状态码返回,如果是0用户不存在,如果是1那么密码错误,如果是2那么密码正确
int result = commonUserService.login(userEmail.trim(), userPassword, request);
// 错误信息
String error = "";
// 查找这个用户
CommonUser commonUser = commonUserService.findCommonUserByEmail(userEmail.trim());
if (result == 2) {
// 如果是2,那么登录成功,返回index
model.addAttribute("user", commonUser);
session.setAttribute("userInfo", commonUser);
return "index/index";
} else if (result == 1) {
error = "密码错误";
log.info(error);
model.addAttribute("error", error);
return "user/login";
} else {
error = "该用户不存在";
log.info(error);
model.addAttribute("error", error);
return "user/login";
}
}
/**
* 用户注册界面
*
* @return
*/
@RequestMapping(value = "/sign", method = RequestMethod.GET)
public String sign(HttpSession session) {
session.invalidate();
return "user/sign";
}
/**
* 用户注册
*
* @param commonUser
* @param request
* @return
*/
@RequestMapping(value = "/sign", method = RequestMethod.POST)
public String sign(Model model, CommonUser commonUser, HttpServletRequest request) {
// 注册用户: 0:用户身份证号已注册 1:用户邮箱已注册 2:用户手机号已注册 3:用户注册成功
//将输入邮箱去除空格
commonUser.setUserEmail(commonUser.getUserEmail().trim());
int result = commonUserService.sign(commonUser, request);
// 错误信息
String error = "";
/*
* if (result == 0) { error = "用户身份证已被注册"; log.info(error);
* model.addAttribute("error", error); return "user/sign"; }
*/
if (result == 1) {
error = "用户邮箱已被注册";
log.info(error);
model.addAttribute("error", error);
return "user/sign";
}
/*
* if (result == 2) { error = "用户手机号已被注册"; log.info(error);
* model.addAttribute("error", error); return "user/sign"; }
*/
error = "注册成功,请登录账号";
log.info(error);
model.addAttribute("error", error);
return "user/login";
}
/**
* 用户找回密码
*
* @return
*/
@RequestMapping(value = "/findPassword", method = RequestMethod.GET)
public String findPassword() {
return "user/findPassword";
}
/**
* 用户修改手机
*/
@RequestMapping(value = "/modifiPhone", method = RequestMethod.GET)
public String modifiPhone(final HttpSession session, Model model) {
final CommonUser commonUser = (CommonUser) session.getAttribute("userInfo");
// 单独开启线程发送邮件,防止用户等待时间过长,成功日志输出,失败也输出。
new Thread(new Runnable() {
public void run() {
boolean isSuccess = commonUserService.sendEmailCheck(commonUser);
if (isSuccess) {
log.info(commonUser.getUserEmail() + "发送成功" + commonUser.getUpdateTime());
CommonUser userMSG = commonUserService.findCommonUserByEmail(commonUser.getUserEmail());
userMSG.setStatus(2);
session.setAttribute("userMSG", userMSG);
} else {
log.info(commonUser.getUserEmail() + "发送失败" + commonUser.getUpdateTime());
}
}
}).start();
return "/user/checkVerification";
}
/**
* 用户修改手机
*/
@RequestMapping(value = "/modifiPhone", method = RequestMethod.POST)
public String modifiPhone(String userMobile, HttpSession session, Model model) {
CommonUser commonUser = (CommonUser) session.getAttribute("userInfo");
String error = "";
int result = commonUserService.modifyPhone(userMobile, commonUser.getUserEmail());
if (result == 2) {
error = "手机号已经被注册";
log.info(error);
model.addAttribute("error", error);
return "user/modifiPhone";
}
CommonUser commonUser1 = commonUserService.findCommonUserByEmail(commonUser.getUserEmail());
session.setAttribute("userInfo", commonUser1);
return "redirect:/userCenter";
}
/**
* 用户找回密码
*
* @return
*/
@RequestMapping(value = "/findPassword", method = RequestMethod.POST)
public String findPassword(Model model, final String userEmail, final HttpSession session) {
// 错误信息
String error = "";
// 通过输入的身份证查找用户
final CommonUser commonUser = commonUserService.findCommonUserByEmail(userEmail);
// 用户不存在返回找回密码页面
if (commonUser == null) {
error = "用户不存在,请检查后输入";
log.info(error);
model.addAttribute("error", error);
return "user/findPassword";
} else {
// 输入的邮箱与密码不匹配,返回找回密码界面
String email = commonUser.getUserEmail();
log.info(email);
if (!userEmail.equals(email)) {
error = "邮箱不匹配,请检查后输入";
log.info(error);
model.addAttribute("error", error);
return "user/findPassword";
} else {
if (commonUserService.findHeadway(commonUser.getUpdateTime()) < 300) {
error = "5分钟内只能发送一封邮件";
log.info(error);
model.addAttribute("error", error);
return "user/findPassword";
}
// 单独开启线程发送邮件,防止用户等待时间过长,成功日志输出,失败也输出。
new Thread(new Runnable() {
public void run() {
boolean isSuccess = commonUserService.sendEmailCheck(commonUser);
if (isSuccess) {
log.info(commonUser.getUserEmail() + "发送成功" + commonUser.getUpdateTime());
CommonUser userMSG = commonUserService.findCommonUserByEmail(userEmail);
userMSG.setStatus(0);
session.setAttribute("userMSG", userMSG);
} else {
log.info(commonUser.getUserEmail() + "发送失败" + commonUser.getUpdateTime());
}
}
}).start();
return "/user/checkVerification";
}
}
}
/**
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计:基于spring boot的医院挂号系统
共192个文件
java:53个
jsp:32个
png:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 199 浏览量
2022-07-05
23:16:24
上传
评论
收藏 2.74MB ZIP 举报
温馨提示
本系统力求结合实际找出一种切实可行的开发方案,经过反复研究和学习,借助java编程语言、Spring+MyBatis框架来完成系统的所有功能,最后进行系统测试,来检测系统的权限和漏洞,从而将系统完善,达到符合标准。
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计:基于spring boot的医院挂号系统 (192个子文件)
bootstrap.css 145KB
bootstrap.min.css 122KB
font-awesome.css 28KB
font-awesome.min.css 23KB
bootstrap-theme.css 22KB
bootstrap-theme.min.css 19KB
custom.css 6KB
style.css 4KB
form-elements.css 2KB
simple-sidebar.css 2KB
index.css 2KB
fontawesome-webfont.eot 59KB
glyphicons-halflings-regular.eot 20KB
.gitignore 20B
CommonUserController.java 14KB
HospitalServiceImpl.java 8KB
CommonUserServiceImpl.java 7KB
DateUtil.java 7KB
HospitalController.java 6KB
Hospital.java 6KB
OrderController.java 5KB
DoctorController.java 4KB
OfficeController.java 4KB
CommonUser.java 4KB
OrderRecords.java 3KB
MailUtil.java 3KB
DoctorServiceImpl.java 3KB
PageUtils.java 3KB
HospitalDao.java 3KB
Doctor.java 3KB
CommonCondition.java 3KB
WorkerScheduler.java 3KB
CommonUserDao.java 3KB
CommonUserService.java 2KB
OrderRecordsServiceImpl.java 2KB
Office.java 2KB
HelpController.java 2KB
NoticeController.java 2KB
MD5.java 2KB
HospitalService.java 2KB
DoctorDao.java 2KB
Notice.java 2KB
OfficeServiceImpl.java 1KB
AreaController.java 1KB
BaseController.java 1KB
OrderRecordsDao.java 1KB
OfficeDao.java 1KB
DoctorService.java 1KB
HelpQA.java 971B
Area.java 899B
AreaServiceImpl.java 867B
NoticeServiceImpl.java 844B
Favourite.java 831B
GetIP.java 822B
FeedBack.java 808B
AreaDao.java 804B
OfficeService.java 803B
OrderRecordsService.java 662B
FavouriteDao.java 614B
HelpQAServiceImpl.java 568B
BaseTest.java 507B
NoticeDao.java 431B
AreaService.java 409B
NoticeService.java 369B
HelpQAService.java 221B
HelpQADao.java 212B
FeedBackDao.java 171B
hos.jpg 315KB
1.jpg 167KB
1@2x.jpg 167KB
3.jpg 93KB
2.jpg 54KB
1.jpg 30KB
doc_nopicture.jpg 6KB
distpicker.js 98KB
jquery.js 94KB
jquery.min.js 82KB
bootstrap.js 66KB
bootstrap.min.js 35KB
jquery.backstretch.js 12KB
index.js 11KB
jquery.backstretch.min.js 4KB
scripts.js 709B
npm.js 484B
placeholder.js 126B
contactIndex.jsp 23KB
helpIndex.jsp 19KB
userCenter.jsp 12KB
hosInfoShow.jsp 11KB
doctorInfoShow.jsp 10KB
officeInfoShow.jsp 9KB
orderHos.jsp 9KB
allHospital.jsp 9KB
doctor.jsp 8KB
orderInfo.jsp 8KB
sign.jsp 7KB
orderOffice.jsp 6KB
officeIndex.jsp 5KB
addUserInfo.jsp 5KB
findPassword.jsp 5KB
共 192 条
- 1
- 2
资源评论
胥华引
- 粉丝: 96
- 资源: 439
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功