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的医院挂号系统
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共192个文件
java:53个
jsp:32个
png:18个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 20 浏览量
2022-07-05
23:16:24
上传
评论
收藏 2.74MB ZIP 举报
温馨提示
本系统力求结合实际找出一种切实可行的开发方案,经过反复研究和学习,借助java编程语言、Spring+MyBatis框架来完成系统的所有功能,最后进行系统测试,来检测系统的权限和漏洞,从而将系统完善,达到符合标准。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 192 条
- 1
- 2
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/277522c9536d43f39ece39de3a2cb0c4_qq_44806047.jpg!1)
胥华引
- 粉丝: 95
- 资源: 439
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)