基于javaweb+mysql的springboot医院预约挂号系统(java+springboot+thymeleaf+html+maven+layui+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot医院预约挂号系统(java+springboot+thymeleaf+html+maven+layui+mysql)
一、项目简述功能包括: 用户分为患者,医生,管理员,患者可进行注册选择医生挂号,选择日期,选择号源,医生可进行接诊,管理员可对用户,医生信息的维护等等功能。
二、项目运行环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
if(type == 1 ) {
return "doctorRegister";
}
return "adminRegister";
}
/**
* 医生注册界面
*/
@RequestMapping("/doctorRegisterPage")
public String doctorRegister(Model model) {
List<Section> sectionlist2 = null;
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
if(sectionlist.size() > 0 ) {
//科室详情
Section section = new Section();
section.setPid(sectionlist.get(0).getId());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
}
model.addAttribute("sectionlist", sectionlist);
model.addAttribute("sectionlist2", sectionlist2);
return "doctorRegister";
}
/**
* 管理员注册
*/
@RequestMapping("/admin_Register")
public String admin_Register(Admin admin,Model model) {
int insertSelective = adminService.insertSelective(admin);
model.addAttribute("type",2);
return "login";
}
/**
* 登陆验证
* @return
*/
@RequestMapping("/verificatio")
public String verificatio(String username, String password, Integer type, HttpServletRequest request,Model model) {
model.addAttribute("se",se);
return "admin/sectionBelow";
}
/**
* 跳转添加科室界面
*/
@RequestMapping("/sectionAddPage")
public String zuopinList() {
return "admin/sectionAdd";
}
/**
* 跳转添加科室下级界面
*/
@RequestMapping("/sectionAddBelowPage")
public String zuopinList(Model model,Integer id) {
if(id != null) {
Section se = sectionService.selectByPrimaryKey(id);
model.addAttribute("se",se);
}
return "admin/sectionAddBelow";
}
/**
* 跳转修改科室下级界面
*/
@RequestMapping("/sectionBelowUptatePage")
public String sectionBelowUptatePage(Model model,Integer id) {
if(id != null) {
Section se = sectionService.selectByPrimaryKey(id);
Section section = sectionService.selectByPrimaryKey(se.getPid());
model.addAttribute("se",se);
model.addAttribute("sname",section.getName());
}
return "admin/sectionBelowUptate";
}
* 后台登陆界面
* @return
*//*
@RequestMapping("/afterView")
public String afterLogin(Integer type,Model model) {
if(type == null){
type = 1;
}
model.addAttribute("type",type);
return "behind/login";
}
*//**
* 登陆验证
* @return
*//*
@RequestMapping("/verificatio")
public String signin(String username, String password, Integer type, HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
session.setAttribute("type",type);
//类型为1是商户后台 2是管理员
if(type == 1){
Merchant merchant = new Merchant();
merchant.setZhanghao(username);
merchant.setMima(password);
merchant.setState(1);
List<Merchant> merchants = merchantService.selectMerchant(merchant);
if(merchants.size() <= 0){
model.addAttribute("message","密码错误");
model.addAttribute("type",type);
return "behind/login";
}
session.setAttribute("MERCHANT",merchants.get(0));
return "redirect:/merchant/index";
}
Admin admin = new Admin();
admin.setUsername(username);
admin.setPassword(password);
List<Admin> adminlist = adminService.selectAdmin(admin);
if(adminlist.size() <= 0){
model.addAttribute("message","密码错误");
model.addAttribute("type",type);
return "behind/login";
}
session.setAttribute("ADMIN",adminlist.get(0));
return "redirect:/admin/index";
}
*//**
* 退出登录
* @param request
* @return
*//*
@RequestMapping("/sessionInvalidate")
public String boot(HttpServletRequest request,Model model) {
personService.deleteByPrimaryKey(id);
}
return "redirect:/admin/personList";
}
*//**
* 管理员
*//*
@RequestMapping("/feiyisList")
public String zuopinList(Model model,Feiyis feiyis,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
feiyis.setState(0);//0为正常 1是管理员下架的
PageInfo<Feiyis> pageInfo = feiyisService.selectFeiyis(feiyis,page,size);
model.addAttribute("feiyiList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("feiyis",feiyis);
return "behind/admin/feiyisList";
}
*//**
* 非遗视界删除
* @param model
* @return
*//*
@RequestMapping("/feiyisDelete")
public String feiyisDelete(Model model,Integer id,Integer type) {
if (id != null) {
Feiyis feiyis = feiyisService.selectByPrimaryKey(id);
//删除图片
// String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真实路径
if (feiyis.getImg() != null) {
String name = feiyis.getImg().substring(feiyis.getImg().indexOf("s") + 2);//获取文件
File file = new File(filePath + name);
if (file.exists()) {
file.delete();
}
}
feiyisService.deleteByPrimaryKey(id);
}
return "redirect:/admin/feiyisList?type=" + type;
}
patient++;
}
}
}
//预约总数
MessagesExample me = new MessagesExample();
MessagesExample.Criteria mecriteria = me.createCriteria();
mecriteria.andDidEqualTo(dt.getId());
int messages = messagesService.countByExample(me);
model.addAttribute("doctor",doctor);
model.addAttribute("section",section);
model.addAttribute("patient",patient);
model.addAttribute("messages",messages);
PageInfo<Doctor> pageInfo = doctorService.selectDoctorList(null,1,4);
if(pageInfo.getList() != null && pageInfo.getList().size() >0 ) {
List<Doctor> list = pageInfo.getList();
StringBuffer sb = new StringBuffer();
StringBuffer shu = new StringBuffer();
int v = list.size()-1;
for(int i=0;i<list.size();i++) {
if(v==i) {
sb.append(list.get(i).getName());
shu.append(list.get(i).getYipeoples());
}else {
sb.append(list.get(i).getName()+",");
shu.append(list.get(i).getYipeoples()+",");
}
}
model.addAttribute("name",sb.toString());
model.addAttribute("nu",shu.toString());
}
return "doctor/index";
}
/**
* 修改信息
* @param model
* @return
*/
@RequestMapping("/doctorUptatePage")
}
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt == null){
return "redirect:/login/index";
}
/*
* PageInfo<Patient> pageInfo =
* patientService.selectPatientList(patient,1,size); List<Patient> list =
* pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
* messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
* null && pa.getPid() != 0){ messages.setDid(dt.getId());
* messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
* List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
* 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
* pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
*
* } } if(list2.size() <= 8) { pageInfo.setPages(1); }
*/
Messages messages = new Messages();
// messages.setTime(new Date());
messages.setType(1);
messages.setDid(dt.getId());
PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
model.addAttribute("doctorList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("patient",patient);
return "doctor/patientList";
}
/**
*预约信息列表
* @throws ParseException
*/
@RequestMapping(value = "/tiaozhuanList")
@ResponseBody
public String messagesList(@RequestParam("xiao")Integer xiao,@RequestParam("da")Integer da) {
Messages message = new Messages();
if(xiao != null & da != null) {
Messages mexiao = messagesService.selectByPrimaryKey(xiao);
Integer px = mexiao.getPai();
Messages meda = messagesService.selectByPrimaryKey(da);
mexiao.setPai(meda.getPai());
meda.setPai(px);
messagesService.updateByPrimaryKeySelective(mexiao);
messagesService.updateByPrimaryKeySelective(meda);
}
return null;
}
messages.setType(type);
//底层数据
PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages,page,size);
//工作区数据
messages.setTime(new Date());
List<Messages> list = messagesService.selectMessagesPai(messages);
model.addAttribute("mlist",list);
model.addAttribute("messagesList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("messages",messages);
model.addAttribute("type",type);
return "doctor/messageList";
}
/**
*医生列表查询
*/
@RequestMapping(value = "/messageAjax")
@ResponseBody
public List<Messages> doctorList(HttpServletRequest request) {
Messages messages = new Messages();
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
messages.setDid(dt.getId());
messages.setType(1);
messages.setTime(new Date());
PageInfo<Messages> pageInfo2 = messagesService.selectMessagesListDemo(messages,1,99);
return pageInfo2.getList();
}
/**
*医生列表查询
*/
@RequestMapping(value = "/messagesQundingUptate")
@ResponseBody
public String messagesQundingUptate(Integer id) {
if(id != null) {
Messages messages = new Messages();
messages.setId(id);
messages.setType(3); //3表示预约成功
messagesService.updateByPrimaryKeySelective(messages);
Messages selectByPrimaryKey = messagesService.selectByPrimaryKey(id);
Messages mes = new Messages();
mes.setType(1);
mes.setTime(new Date());
/**
* 医生添加
* @param model
* @param zixun
* @return
*/
@RequestMapping("/zixunInsert")
public String zixunInsert(Model model,Doctor doctor){
if(doctor.getId() != null){
if(doctor.getSid() != null) {
Section selectByPrimaryKey = sectionService.selectByPrimaryKey(doctor.getSid());
doctor.setSname(selectByPrimaryKey.getName());
}
doctorService.updateByPrimaryKeySelective(doctor);
}
model.addAttribute("type",1);
return "login";
}
/**
* 管理员注册界面
*/
@RequestMapping("/mimaPageUptate")
public String mimaPageUptate(Integer type,Model model) {
//1医生 2 管理员
if(type == 1 ) {
return "doctorRegister";
}
return "adminRegister";
}
/**
* 医生注册界面
*/
@RequestMapping("/doctorRegisterPage")
public String doctorRegister(Model model) {
List<Section> sectionlist2 = null;
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
if(sectionlist.size() > 0 ) {
//科室详情
Section section = new Section();
section.setPid(sectionlist.get(0).getId());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
}
model.addAttribute("sectionlist", sectionlist);
model.addAttribute("sectionlist2", sectionlist2);
*/
@RequestMapping("/font/index")
public String fontIndex(Integer type,Model model) {
if(type == null){
type = 3;
}
model.addAttribute("type",type);
return "loginByPatient";
}
/* public static void main(String[] args) {
String filename ="C:\\Users\\Administrator\\Pictures\\项目图片\\1156.jpg_wh1200.jpg";
int indexOf = filename.indexOf(".");
String substring = filename.substring(indexOf);
System.out.println(substring);
}*/
/**
* 医生图片上传
* @param mufile
* @param id
* @return
* @throws IOException
*/
@RequestMapping(value ="/zixunAdd")
@ResponseBody
public Map<String, Object> zixunAdd(@RequestParam("mf")MultipartFile mufile,@RequestParam("id")Integer id) throws IOException{
Map<String, Object> map = new HashMap<String, Object>();
String random = StringRandom.getRandom();
String filename = mufile.getOriginalFilename();
//随机字符+原图片名用作新的图片名
filename = random+".jpg";
try {
//文件保存路径 D:/xxxx/xxxx/
File file = new File(filePath+filename);
//判断父级文件是否存在
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
mufile.transferTo(file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
Doctor doctor = new Doctor();
if(id != -1){
doctor.setId(id);
doctor.setImg("/files/"+filename);
doctorService.updateByPrimaryKeySelective(doctor);
}else {
model.addAttribute("type",type);
session.invalidate(); //session销毁
return "loginByPatient";
}
model.addAttribute("type",type);
session.invalidate(); //session销毁
return "login";
}
/*
*//**
* 跳转忘记密码界面
*//*
@RequestMapping("/mimaPageUptate")
public String passwordUpate() {
return "behind/merchant/mibaoUptate";
}
*//**
* 修改密码
*//*
@RequestMapping("/mimaUpate")
@ResponseBody
public Map<String,String> passwordUpate(Model model, String mima, String mibao, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
Merchant me = new Merchant();
me.setZhanghao(zhanghao);
me.setMibao(mibao);
List<Merchant> list = merchantService.selectMerchant(me);
if(list.size() > 0){
Merchant me2 = new Merchant();
me2.setId(list.get(0).getId());
me2.setMima(mima);
merchantService.updateByPrimaryKeySelective(me2);
map.put("pan","ok");
}else{
map.put("pan","err");
}
return map;
}
*//**
* 后台登陆界面
String filename = mufile[i].getOriginalFilename();
//随机字符+原图片名用作新的图片名
filename = random+filename;
//文件保存路径 D:/Java/hospital
File file = new File(filePath+filename);
//判断父级文件是否存在
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
path.append("/files/"+filename+",");
mufile[i].transferTo(file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
}
Banners banners = new Banners();
if(id != null){
//修改图片路径
Banners sh = bannersService.selectByPrimaryKey(id);
banners.setId(id);
if(sh.getImg() != null ){
banners.setImg(sh.getImg()+path.toString());
}else{
banners.setImg(path.toString());
}
bannersService.updateByPrimaryKeySelective(banners);
}
return map;
}
/*
*//**
* 管理员-非遗讲堂
*//*
@RequestMapping(value="/feiyi_videoList")
public String feiyi_VideoList(Model model, Video video, @RequestParam(value="page",defaultValue="1")Integer page) {
PageInfo<Video> pageInfo = videoService.selectPageList(video,page,size);
model.addAttribute("videoList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
if(video.getTitle() != null){
model.addAttribute("title",video.getTitle());
}
return "behind/admin/feiyi_videoList";
}
model.addAttribute("sectionlist2", sectionlist2);
model.addAttribute("se1", se1);
}
}
return "doctor/doctorUptate";
}
/**
* 修改医生信息
*/
@RequestMapping("/messageTime")
public String messageTime(String name,Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(name != null) {
Messages mess = new Messages();
mess.setDid(dt.getId());
mess.setUsername(name);
List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
model.addAttribute("messagesList", selectMessages);
}
return "doctor/messageTime";
}
/**
* 修改医生信息
*/
@RequestMapping("/admindoctorUptate")
public String adminUptatePassword(Doctor doctor,Model model) {
if(doctor != null && doctor.getId() != null) {
if(doctor.getSid() != null) {
Section section = sectionService.selectByPrimaryKey(doctor.getSid());
doctor.setSid(section.getId());
doctor.setSname(section.getName());
}
doctorService.updateByPrimaryKeySelective(doctor);
}
return "redirect:/doctor/index";
}
/**
* 预约信息列表
*/
@RequestMapping("/messageList")
model.addAttribute("doctor",doctor);
}
return "patient/doctorTime";
}
/**
*医生列表查询
*/
@RequestMapping(value = "/doctorList")
@ResponseBody
public List<Doctor> doctorList(Integer sid) {
Doctor doctor = new Doctor();
doctor.setSid(sid);
List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
return selectDoctor;
}
/**
*医生列表查询
*/
@RequestMapping(value = "/doctorLike")
@ResponseBody
public List<Doctor> doctorLike(String name) {
Doctor doctor = new Doctor();
doctor.setName(name);
List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
return selectDoctor;
}
/**
*科室查询
*/
@RequestMapping(value = "/doctorIdList")
@ResponseBody
public Section doctorIdList(Integer sid) {
Section selectByPrimaryKey = sectionService.selectByPrimaryKey(sid);
return selectByPrimaryKey;
}
/**
*医生列表查询
* @throws ParseException
*/
@RequestMapping(value = "/doctortimeSelect")
@ResponseBody
public List<Doctor> doctortimeSelect(@RequestParam("datetimei")String datetimei,@RequestParam("id")Integer id) throws ParseException {
@RequestMapping(value = "/userLoginView")
@ResponseBody
public String userLoginView(HttpServletRequest request) throws ParseException {
HttpSession session = request.getSession();
Patient patient =(Patient) session.getAttribute("USER");
System.out.println("*********登陆验证********");
System.out.println(patient);
if(patient != null) {
return "ok";
}
return "err";
}
/**
*banner图
*/
@RequestMapping(value = "/bannerList")
@ResponseBody
public String[] formAdd() {
Banners banners = bannersService.selectByPrimaryKey(1);
String[] split = null;
if(banners != null && banners.getImg() != null) {
split = banners.getImg().split(",");
}
return split;
}
/**
*科室查询
*/
@RequestMapping(value = "/sectionList")
@ResponseBody
public Map<String,List<Section>> sectionList() {
Map<String,List<Section>> map = new HashMap<String,List<Section>>();
List<Section> sectionlist2 = null;
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
if(sectionlist.size() > 0 ) {
//科室详情
Section section = new Section();
section.setPid(sectionlist.get(0).getId());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
}
map.put("sectionlist",sectionlist);
map.put("sectionlist2",sectionlist2);
return map;
}
@ResponseBody
public Map<String,String> passwordUpate(Model model, String mima, String mibao, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
Merchant me = new Merchant();
me.setZhanghao(zhanghao);
me.setMibao(mibao);
List<Merchant> list = merchantService.selectMerchant(me);
if(list.size() > 0){
Merchant me2 = new Merchant();
me2.setId(list.get(0).getId());
me2.setMima(mima);
merchantService.updateByPrimaryKeySelective(me2);
map.put("pan","ok");
}else{
map.put("pan","err");
}
return map;
}
*//**
* 后台登陆界面
* @return
*//*
@RequestMapping("/afterView")
public String afterLogin(Integer type,Model model) {
if(type == null){
type = 1;
}
model.addAttribute("type",type);
return "behind/login";
}
*//**
* 登陆验证
* @return
*//*
@RequestMapping("/verificatio")
public String signin(String username, String password, Integer type, HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
session.setAttribute("type",type);
//类型为1是商户后台 2是管理员
*/
@RequestMapping(value ="/bannersAdd")
@ResponseBody
public Map<String, Object> bannersAdd(@RequestParam("mf")MultipartFile[] mufile,@RequestParam("id")Integer id) throws IOException{
Map<String, Object> map = new HashMap<String, Object>();
StringBuffer path = new StringBuffer();
//图片上传并保存上传的路径
for (int i = 0; i < mufile.length; i++) {
try {
String random = StringRandom.getRandom();
String filename = mufile[i].getOriginalFilename();
//随机字符+原图片名用作新的图片名
filename = random+filename;
//文件保存路径 D:/Java/hospital
File file = new File(filePath+filename);
//判断父级文件是否存在
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
path.append("/files/"+filename+",");
mufile[i].transferTo(file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
}
Banners banners = new Banners();
if(id != null){
//修改图片路径
Banners sh = bannersService.selectByPrimaryKey(id);
banners.setId(id);
if(sh.getImg() != null ){
banners.setImg(sh.getImg()+path.toString());
}else{
banners.setImg(path.toString());
}
bannersService.updateByPrimaryKeySelective(banners);
}
return map;
}
/*
*//**
* 管理员-非遗讲堂
*//*
@RequestMapping(value="/feiyi_videoList")
public String feiyi_VideoList(Model model, Video video, @RequestParam(value="page",defaultValue="1")Integer page) {
PageInfo<Video> pageInfo = videoService.selectPageList(video,page,size);
model.addAttribute("videoList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
if(video.getTitle() != null){
model.addAttribute("title",video.getTitle());
}
/**
* 后端管理员控制层
*/
@Controller
@RequestMapping("/admin")
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
private SectionService sectionService;
@Autowired