Java project: 318SSM hospital appointment registration system

Author’s homepage: Ye Weiyang 5788

Introduction: High-quality creators in the Java field, Java projects, learning materials, and technical mutual assistance

Get the source code at the end of the article

Project introduction

Hospital appointment registration system based on SSM

Role: Administrator, Doctor, User

After the administrator logs in to the system, he can perform corresponding operations and management on the homepage, personal center, user management, doctor management, outpatient information management, appointment registration management, appointment cancellation management, appointment change notification management, message board management, system management and other functions.

When a doctor logs in to the hospital appointment registration system, he can manage the home page, personal center, outpatient information management, appointment registration management, appointment cancellation management and other functions.

Users who log in to the hospital appointment registration system can manage functions such as the home page, personal center, appointment registration management, appointment cancellation management, and appointment change notification management.

Environmental needs

1. Operating environment: preferably java jdk 1.8, we run on this platform. Other versions are theoretically possible.
2. IDE environment: IDEA, Eclipse, Myeclipse are all available. Recommend IDEA;
3. Tomcat environment: Tomcat 7.x, 8.x, 9.x versions are available
4. Hardware environment: windows 7/8/10 1G memory or more; or Mac OS;
5. Whether it is a Maven project: No; check whether the source code directory contains pom.xml; if it is included, it is a Maven project, otherwise it is a non-Maven project

6. Database: MySql 5.7/8.0 and other versions are acceptable;

Technology stack

Backend: SSM (Spring + SpringMVC + Mybatis)

Front-end: JSP + CSS + JS + JQUERY + Layui

Instructions for use

1. Use Navicat or other tools to create a database with the corresponding name in mysql and import the project’s sql file;
2. Use IDEA/Eclipse/MyEclipse to import the project, modify the configuration, and run the project;

3. Change the database configuration in the db.xml configuration file in the project to your own configuration, and then run;

Run screenshot

Thesis

Front-end interface

Backend interface

Related code

UtilController

package com.hospital.controller;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.hospital.dao.MessageDao;
import com.hospital.entity.Message;
import com.hospital.entity.Records;
import com.hospital.service.DoctorService;
import com.hospital.service.MessageService;
import com.hospital.service.RecordsService;
import com.hospital.service.UserService;


@Controller

public class UtilController {
\t
@Autowired
MessageService messageService;
\t
@Autowired
RecordsService orderService;
\t
@Autowired
UserService userService;
\t
@Autowired
DoctorService doctorService;
\t
@RequestMapping("toRegister")
public String toRegsiteAct(HttpServletRequest request) {
return "view/register";
}
\t
@RequestMapping("toEcharts")
public String toEcharts(HttpServletRequest request) {
return "view/echarts";
}
\t
\t
@RequestMapping("toLogin")
public String toLogin(HttpSession session) {
session.removeAttribute("admin");
session.removeAttribute("user");
session.removeAttribute("doctor");
return "view/login";
}
\t
@RequestMapping("UserPageAct")
public String UserPageAct() {
return "view/userList";
}
\t
\t
@RequestMapping("toLoginOutAct")
public String toLoginOutAct(HttpSession session) {
session.removeAttribute("admin");
session.removeAttribute("user");
session.removeAttribute("doctor");
return "view/login";
}
@RequestMapping("toMain")
public String toMain(HttpServletRequest request,HttpSession session) {
Map<String,Object> maps = new HashMap<>();
List<Message> messageList = messageService.selectMessageList(maps);
request.setAttribute("messageList", messageList);
List<Records> recordsList = orderService.selectRecordsList(maps);
for(Records record : recordsList) {
record.setUser(userService.selectUserById(record.getUid()));
record.setDoctor(doctorService.selectDoctorById(record.getDid()));
}
request.setAttribute("recordsList", recordsList);
return "view/main";
}
@RequestMapping("toConsoleAct")
public String toWelocmeAct() {
return "view/console";
}
\t
    @ResponseBody
    @RequestMapping("/upload")
    public Map upload(MultipartFile file,HttpServletRequest request){

        String prefix="";
        String dateStr="";
        OutputStream out = null;
        InputStream fileInput=null;
        try{
            if(file!=null){
                String originalName = file.getOriginalFilename();
                prefix=originalName.substring(originalName.lastIndexOf(".") + 1);
                Date date = new Date();
                String uuid = UUID.randomUUID() + "";
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dateStr = simpleDateFormat.format(date);
                String filepath = "F:\workspace\flower_ssm\WebContent\img" + dateStr + "" + uuid + "." + prefix;
                
                File files=new File(filepath);
                System.out.println(filepath);
                if(!files.getParentFile().exists()){
                    files.getParentFile().mkdirs();
                }
                file.transferTo(files);
                Map<String,Object> map2=new HashMap<>();
                Map<String,Object> map=new HashMap<>();
                map.put("code",0);
                map.put("msg","");
                map.put("data",map2);
                map2.put("src","/img/" + dateStr + "/" + uuid + "." + prefix);
                return map;
            }

        }catch (Exception e){
        }finally{
            try {
                if(out!=null){
                    out.close();
                }
                if(fileInput!=null){
                    fileInput.close();
                }
            } catch (Exception e) {
            }
        }
        Map<String,Object> map=new HashMap<>();
        map.put("code",1);
        map.put("msg","");
        return map;

    }
    

    @ResponseBody
    @RequestMapping("/upload2")
    public Map upload2(MultipartFile file,HttpServletRequest request){

        String prefix="";
        String dateStr="";
        OutputStream out = null;
        InputStream fileInput=null;
        try{
            if(file!=null){
                String originalName = file.getOriginalFilename();
                prefix=originalName.substring(originalName.lastIndexOf(".") + 1);
                Date date = new Date();
                String uuid = UUID.randomUUID() + "";
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dateStr = simpleDateFormat.format(date);
                String filepath = "D:\upload" + dateStr + "" + uuid + "." + prefix;
                
                File files=new File(filepath);
                System.out.println(filepath);
                if(!files.getParentFile().exists()){
                    files.getParentFile().mkdirs();
                }
                file.transferTo(files);
                Map<String,Object> map2=new HashMap<>();
                Map<String,Object> map=new HashMap<>();
                map.put("code",0);
                map.put("msg","");
                map.put("data",map2);
                map2.put("src",dateStr + "/" + uuid + "." + prefix);
                return map;
            }

        }catch (Exception e){
        }finally{
            try {
                if(out!=null){
                    out.close();
                }
                if(fileInput!=null){
                    fileInput.close();
                }
            } catch (Exception e) {
            }
        }
        Map<String,Object> map=new HashMap<>();
        map.put("code",1);
        map.put("msg","");
        return map;

    }
    

}

UserController

package com.hospital.controller;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hospital.entity.Admin;
import com.hospital.entity.Doctor;
import com.hospital.entity.User;
import com.hospital.service.UserService;

@RestController
public class UserController {
\t
@Autowired
UserService us;
\t
\t
/**
* ?
* @param username
* @param request
* @param password
* @param session
* @param response
* @param mv
* @return
* @throwsServletException
* @throwsIOException
*/
@RequestMapping("/login")
@ResponseBody
     public boolean login(@RequestParam("username")String username,
    HttpServletRequest request,@RequestParam("password")String password,
    HttpSession session,HttpServletResponse response,ModelAndView mv) throws ServletException, IOException {
session.removeAttribute("admin");
session.removeAttribute("user");
String type=request.getParameter("type").toString();
User user =new User();
Admin admin = new Admin();
Doctor doctor = new Doctor();
request.getSession().setAttribute("type", type);
boolean re = false;
if(type != null & amp; & amp; type.equals("1")){
admin.setUsername(username);
admin.setPassword(password);
Admin admin1 = us.selectAdmin(admin);
if(admin1 != null){
request.getSession().setAttribute("admin", admin1);
session.setAttribute("admin", admin1);
re = true;
}
}else if(type != null & amp; & amp; type.equals("2")){
user.setUsername(username);
user.setPassword(password);
User te = us.selectUser(user);
if(te != null){
request.getSession().setAttribute("user", te);
session.setAttribute("user", te);
re = true;
}
}else if(type != null & amp; & amp; type.equals("3")) {
doctor.setPhone(username);
doctor.setPwd(password);
Doctor te = us.selectDoctor(doctor);
if(te != null){
request.getSession().setAttribute("doctor", te);
session.setAttribute("doctor", te);
re = true;
}
}
return re;
\t\t\t
}
\t

@RequestMapping("/userList")
    public ModelAndView UserList(
@RequestParam(defaultValue="1") Integer currentPage,HttpServletRequest request,
Map<String,Object> map){
User user = (User)request.getSession().getAttribute("user");
String userName = request.getParameter("key");
List<User> list = new ArrayList<>();
Map<String,Object> maps = new HashMap<>();
maps.put("username", userName);
maps.put("uid", user!=null?user.getId():null);
PageHelper.startPage(currentPage,10);
list=us.selectUserList(maps);
PageInfo<User> pageInfo=new PageInfo<User>(list,8);
map.put("pageInfo", pageInfo);
map.put("key", userName);
return new ModelAndView("view/user/list");
}
\t
\t

@RequestMapping("/toAddUser")
    public ModelAndView toAddUser(HttpServletRequest request,ModelAndView mv){
mv.setViewName("view/user/add");
return mv;
}
\t
@RequestMapping("/addUser")
@ResponseBody
public boolean addUser(User ss){
ss.setTimes(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
boolean re = false;
User user = us.selectUserByUserName(ss.getUsername());
if(user == null) {
us.addUser(ss);
re = true;
}
return re;
}
\t
@RequestMapping("/deleteUser")
    public boolean deleteUser(HttpServletRequest request,
HttpServletResponse response){
boolean re = false;
String id = request.getParameter("id");
us.deleteUser(Integer.parseInt(id));
re = true;
return re;
}
\t
\t
@RequestMapping("/toUpdateUser")
    public ModelAndView toUpdateUser(HttpServletRequest request,ModelAndView mv){
String id=request.getParameter("id");
User ff = us.selectUserById(Integer.parseInt(id));
mv.addObject("userDate", ff);
mv.setViewName("view/user/update");
return mv;
}
\t
@RequestMapping("/toUpdateAdminPassword")
    public ModelAndView toUpdateAdminPassword(HttpServletRequest request,ModelAndView mv){
mv.setViewName("view/admin/updatePassword");
return mv;
}
\t

@RequestMapping("/updateAdminPassword")
@ResponseBody
public boolean updateAdminPassword(HttpServletRequest request){
boolean re = false;
Admin admin = (Admin)request.getSession().getAttribute("admin");
String nowpass = request.getParameter("nowpass");
String newpass = request.getParameter("newpass");
if(admin !=null & amp; & amp; admin.getPassword().equals(nowpass)) {
us.updateAdminPassword(newpass,admin.getId());
re = true;
}
return re;
}
\t
@RequestMapping("/updateUser")
@ResponseBody
public boolean updateUser(HttpServletRequest request,User ss){
Admin admin = (Admin)request.getSession().getAttribute("admin");
boolean re = false;
us.updateUser(ss);
re = true;
if(admin ==null) {
request.getSession().setAttribute("user", ss);
}
return re;
}

}

If you also want to learn this system, get it below. Follow and reply: 318ssm

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Java Skill TreeHomepageOverview 139444 people are learning the system