首页 > 数据库 >SSM框架(spring+springmvc+mybatis)+layui+Mysql实现的医院在线预约挂号管理系统(功能包含分角色,登录/注册、病历列表、患者管理、科室管理、医生管理、挂号预约等)

SSM框架(spring+springmvc+mybatis)+layui+Mysql实现的医院在线预约挂号管理系统(功能包含分角色,登录/注册、病历列表、患者管理、科室管理、医生管理、挂号预约等)

时间:2022-10-30 17:31:07浏览次数:74  
标签:return String 管理 预约 hospital 挂号 user import public

(博客目录)

SSM框架(spring+springmvc+mybatis)+layui+Mysql实现的医院在线预约挂号管理系统

本系统为了患者线下预约挂号难的问题,打通医院和患者之间的一个渠道,通过在线透明化的方式,让患者进行预约,同时医院端也提高了看病的效率,可以在线维护科室、医生,以及查看患者病历等。 完整源码点击头像查看个人签名

实现功能截图

用户注册 请添加图片描述 登录 请添加图片描述 预约挂号 请添加图片描述 病历列表 请添加图片描述 管理员首页 请添加图片描述 患者管理 请添加图片描述 患者信息维护 请添加图片描述 科室管理 请添加图片描述 医生列表 请添加图片描述 医生管理 请添加图片描述 公告管理 请添加图片描述 修改病历 请添加图片描述

系统功能

本系统实现了以下功能: 分普通用户和管理员 1、注册登录 2、在线挂号预约 3、修改病历 4、医生列表 5、公告 管理员端 5、患者管理 6、科室管理 7、医生管理 8、患者信息维护 9、公告管理 等

使用技术

数据库:mysql 开发工具:Idea(Myeclispe、Eclipse也可以) 知识点:SSM+layui

项目结构 请添加图片描述

代码

实体类 Doctor.java

package com.code2life.hospital.entity;

import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class Doctor {
    private Integer doctor_id;
    private String username;
    private String password;
    private String gender;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    private String phone;
    private String email;
    private String address;
    private Integer roleId;
    private String rank; //职称
    private String photo_path;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    private Integer depart_id;
    private String realname;

    private Depart depart;

    public Depart getDepart() {
        return depart;
    }

    public void setDepart(Depart depart) {
        this.depart = depart;
    }

    public Integer getDoctor_id() {
        return doctor_id;
    }

    public void setDoctor_id(Integer doctor_id) {
        this.doctor_id = doctor_id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

    public String getPhoto_path() {
        return photo_path;
    }

    public void setPhoto_path(String photo_path) {
        this.photo_path = photo_path;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getDepart_id() {
        return depart_id;
    }

    public void setDepart_id(Integer depart_id) {
        this.depart_id = depart_id;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }
}

患者实体类User.java


package com.code2life.hospital.entity;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

public class User {
	
	private int user_id;
	
	private String username;
	private String photo_path;
	private String password;
	
	private String gender;
	
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date birthday;
	//@DateTimeFormat(pattern = "yyyy-MM-dd") 很重要 必须加上 不然jsp中
	// 数据类型和这里绑定不了 ajax请求进入不了controller

	
	private String phone;
	
	private String email;
	
	private String address;
	
	private String note;
	
	private int status;
	private String realname;
	private int levelId;


	public Long getRoleId() {
		return roleId;
	}

	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	private Long roleId;
	
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public int getUser_id() {
		return user_id;
	}

	public void setUser_id(int user_id) {
		this.user_id = user_id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public Date getBirthday() {
		return birthday;
	}

	public String getPhoto_path() {
		return photo_path;
	}

	public void setPhoto_path(String photo_path) {
		this.photo_path = photo_path;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}


	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getLevelId() {
		return levelId;
	}

	public void setLevelId(int levelId) {
		this.levelId = levelId;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


}

Dao层 DoctorDao.java

package com.code2life.hospital.dao;

import com.code2life.hospital.entity.Doctor;
import com.code2life.hospital.entity.DoctorSearch;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface DoctorDao {
    void insDoctor(Doctor doctor);

    Doctor login(@Param("username")String username, @Param("password")String password);

    Doctor getDoctorById(Integer doctor_id);

    void updateDoctor(Doctor doctor);

    Doctor getDoctorByUserName(String username);

    List<Doctor> getAllDoctorList(DoctorSearch search);

    void deleteDoctorById(int doctor_id);

    List<Doctor> getDoctorByDepartId(Integer depart_id);
}

UserDao.java

package com.code2life.hospital.dao;


import com.code2life.hospital.entity.User;
import com.code2life.hospital.entity.UserSearch;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface UserDao {
    void insUser(User user);

    User login(@Param("username")String username, @Param("password")String password);

    User getUserById(Integer user_id);

    void updateUser(User user);

    User getUserByUserName(String username);

    List<User> getAllUserList(UserSearch search);

    void updateUserStatusById(@Param("user_id")int user_id, @Param("status")int status);

    void deleteUserById(int user_id);


}

service层 DoctorServiceImpl.java

在这里插入代码片package com.code2life.hospital.service;

import com.code2life.hospital.dao.MenuDao;
import com.code2life.hospital.dao.RoleMenuDao;
import com.code2life.hospital.entity.Doctor;
import com.code2life.hospital.entity.DoctorSearch;
import com.code2life.hospital.entity.Menu;
import com.code2life.hospital.entity.RoleMenu;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.code2life.hospital.dao.DoctorDao;
import com.code2life.hospital.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Service
public class DoctorServiceImpl implements DoctorService{

    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private RoleMenuDao roleMenuDao;
    @Autowired
    private MenuDao menuDao;

    @Override
    public void insDoctor(Doctor doctor) {
        doctorDao.insDoctor(doctor);
    }

    @Override
    public Doctor login(String username, String encrypt) {
        return doctorDao.login(username,encrypt);
    }

    @Override
    public Doctor getDoctorById(Integer doctor_id) {
        return doctorDao.getDoctorById(doctor_id);
    }

    @Override
    public List<Menu> getMenus(Doctor doctor1) {
        List<Menu> menuList=new ArrayList<>();
        Long roleId=(long)doctor1.getRoleId();
        List<RoleMenu> roleMenus=roleMenuDao.selMenusByRoleId(roleId);
        //rolemenu里面就是一个中间表 两个字段 roleId menuId 关联起来
        if(roleMenus!=null&&roleMenus.size()>0)
        {
            List<Menu> noChildrenMenus=new ArrayList<>();
            for(int i=0;i<roleMenus.size();i++)
            {
                Menu menu=menuDao.getMenuById(roleMenus.get(i).getMenuId()); //获取rolemenu中的menuId
                noChildrenMenus.add(menu); //就是根据这个登陆者的roleid 所拥有的菜单取出来
            }
            for(int i=0;i<noChildrenMenus.size();i++)
            {
                if(noChildrenMenus.get(i).getParentId()==0)
                //说明这个菜单是一级菜单 没有上一级菜单
                //如果这里不为0 表示这个菜单是二级菜单 或者三级菜单 ParentId对应了属于哪个上级菜单
                {
                    Menu menu=new Menu();
                    menu=noChildrenMenus.get(i); //把这个一级菜单取出来
                    List<Menu> menus=new ArrayList<>();
                    for(int j=0;j<noChildrenMenus.size();j++) //把所有菜单过一遍
                    {
                        //如果有菜单属于这个一级菜单
                        if(noChildrenMenus.get(j).getParentId()==noChildrenMenus.get(i).getMenuId())
                        {
                            Menu menu2=new Menu();
                            menu2=noChildrenMenus.get(j);//取出这个二级菜单
                            menus.add(menu2);
                        }
                    }
                    menu.setChildren(menus); //存放了属于这个一级菜单的所有二级菜单
                    menuList.add(menu);//存放了所有的一级菜单和其对应的所有二级菜单
                }
            }

        }
        //下面是根据menu的sorting进行排序 升序排列 这样左侧菜单就会按照升序排列
        Collections.sort(menuList, new Comparator<Menu>() {
            @Override
            public int compare(Menu o1, Menu o2) {

                return o1.getSorting().compareTo(o2.getSorting());
            }
        });

        return menuList;
    }

    @Override
    public ResultUtil updateDoctor(Doctor doctor) {
        doctorDao.updateDoctor(doctor);
        return ResultUtil.ok();
    }

    @Override
    public Doctor getDoctorByUserName(String username) {
        return doctorDao.getDoctorByUserName(username);
    }

    @Override
    public ResultUtil getAllDoctorList(Integer page, Integer limit, DoctorSearch search) {
        PageHelper.startPage(page,limit);
        List<Doctor> doctors=doctorDao.getAllDoctorList(search);
        PageInfo<Doctor> pageInfo=new PageInfo<>(doctors);
        ResultUtil resultUtil=new ResultUtil();
        resultUtil.setCode(0);
        resultUtil.setCount(pageInfo.getTotal());
        resultUtil.setData(pageInfo.getList());
        return resultUtil;
    }

    @Override
    public ResultUtil deleteDoctorById(int doctor_id) {
        doctorDao.deleteDoctorById(doctor_id);
        return ResultUtil.ok();
    }

    @Override
    public List<Doctor> getDoctorByDepartId(Integer depart_id) {
        return doctorDao.getDoctorByDepartId(depart_id);
    }


}

UserServiceImpl.java

package com.code2life.hospital.service;

import com.code2life.hospital.dao.MenuDao;
import com.code2life.hospital.dao.RoleMenuDao;
import com.code2life.hospital.entity.Menu;
import com.code2life.hospital.entity.RoleMenu;
import com.code2life.hospital.entity.User;
import com.code2life.hospital.entity.UserSearch;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.code2life.hospital.dao.UserDao;
import com.code2life.hospital.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Service
@Transactional

public class UserServiceImpl implements UserService
{

    @Autowired
    private UserDao userDao;

    @Autowired
    private RoleMenuDao roleMenuDao;
    @Autowired
    private MenuDao menuDao;

    @Override
    public void insUser(User user) {
        userDao.insUser(user);
    }

    @Override
    public User login(String username, String password) {
        return userDao.login(username,password);
    }

    @Override
    public List<Menu> getMenus(User user1)
    {
        List<Menu> menuList=new ArrayList<>();
        Long roleId=user1.getRoleId();
        List<RoleMenu> roleMenus=roleMenuDao.selMenusByRoleId(roleId);
        //rolemenu是一个中间表 两个字段 roleId menuId 关联起来
        if(roleMenus!=null&&roleMenus.size()>0)
        {
            List<Menu> noChildrenMenus=new ArrayList<>();
            for(int i=0;i<roleMenus.size();i++)
            {
                Menu menu=menuDao.getMenuById(roleMenus.get(i).getMenuId()); //获取rolemenu中的menuId
                noChildrenMenus.add(menu); //根据登陆者的roleid 所拥有的菜单取出来
            }
            for(int i=0;i<noChildrenMenus.size();i++)
            {
                if(noChildrenMenus.get(i).getParentId()==0)
                //说明这个菜单是一级菜单 没有上一级菜单
                //如果这里不为0 表示这个菜单是二级菜单 或者三级菜单 ParentId对应了属于哪个上级菜单
                {
                    Menu menu=new Menu();
                    menu=noChildrenMenus.get(i); //把这个一级菜单取出来
                    List<Menu> menus=new ArrayList<>();
                    for(int j=0;j<noChildrenMenus.size();j++) //把所有菜单过一遍
                    {
                        //如果有菜单属于这个一级菜单
                        if(noChildrenMenus.get(j).getParentId()==noChildrenMenus.get(i).getMenuId())
                        {
                            Menu menu2=new Menu();
                            menu2=noChildrenMenus.get(j);//取出这个二级菜单
                            menus.add(menu2);
                        }
                    }
                    menu.setChildren(menus); //存放了属于这个一级菜单的所有二级菜单
                    menuList.add(menu);//存放了所有的一级菜单和其对应的所有二级菜单
                }
            }

        }
        //下面是根据menu的sorting进行排序 升序排列 这样左侧菜单就会按照升序排列
        Collections.sort(menuList, new Comparator<Menu>() {
            @Override
            public int compare(Menu o1, Menu o2) {

                return o1.getSorting().compareTo(o2.getSorting());
            }
        });

        return menuList;
    }

    @Override
    public User getUserById(Integer user_id) {
        return userDao.getUserById(user_id);
    }

    @Override
    public ResultUtil updateUser(User user) {
        userDao.updateUser(user);
        return ResultUtil.ok();
    }

    @Override
    public User getUsertByUserName(String username) {
        return userDao.getUserByUserName(username);
    }

    @Override
    public ResultUtil getAllUserList(Integer page, Integer limit, UserSearch search) {
        PageHelper.startPage(page,limit);
        List<User> users=userDao.getAllUserList(search);
        PageInfo<User> pageInfo=new PageInfo<>(users);
        ResultUtil resultUtil=new ResultUtil();
        resultUtil.setCode(0);
        resultUtil.setCount(pageInfo.getTotal());
        resultUtil.setData(pageInfo.getList());
        return resultUtil;
    }

    @Override
    public ResultUtil updateUserStatusById(int user_id, int status) {
         userDao.updateUserStatusById(user_id,status);
         return ResultUtil.ok();
    }

    @Override
    public ResultUtil deleteUserById(int user_id) {
        userDao.deleteUserById(user_id);
        return ResultUtil.ok();
    }

}

Controller层 DoctorController.java

package com.code2life.hospital.web;

import com.code2life.hospital.entity.Admin;
import com.code2life.hospital.entity.Doctor;
import com.code2life.hospital.entity.Menu;
import com.code2life.hospital.service.DoctorService;
import com.code2life.hospital.util.EncryptUtil;
import com.code2life.hospital.util.ResultUtil;
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.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/doctor")
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @RequestMapping("/login")
    @ResponseBody
    public ResultUtil login(String username, String password, HttpServletRequest request, HttpSession session) {
        Doctor doctor = doctorService.login(username, EncryptUtil.encrypt(password));

        if (doctor != null) {

            Integer depart_id = doctor.getDepart_id();
            if (depart_id != 0) //说明已经分配科室 可以登录
            {
                Admin admin = new Admin();
                session.setAttribute("user", admin); //拦截器中用 跳过拦截器
                session.setAttribute("hospital_user", doctor);
                session.setAttribute("usertype", 3);//代表医生登陆
                session.setAttribute("hospital_user_id", doctor.getDoctor_id());
                session.setAttribute("hospital_user_photo", doctor.getPhoto_path());//获得头像图片名
                return ResultUtil.ok();
            } else {
                return ResultUtil.error("对不起,请先联系管理员分配科室");
            }

        } else {
            return ResultUtil.error("用户名或者密码错误,请重新输入");
        }

    }


    @RequestMapping("/info")
    public String info(HttpSession session) {
        //覆盖一下之前的hospital_user 不然显示的还是之前的hospital_user
        Integer doctor_id = (Integer) session.getAttribute("hospital_user_id");
        Doctor doctor = doctorService.getDoctorById(doctor_id);
        session.setAttribute("hospital_user", doctor);
        return "/jsp/doctor/editDoctor";
    }

    @RequestMapping("/updateDoctor")
    @ResponseBody
    public ResultUtil updateDoctor(Doctor doctor) throws ParseException {
        return doctorService.updateDoctor(doctor);
    }

    @RequestMapping("/changePassword")
    public String changePassword() {
        return "/jsp/doctor/changePassword";
    }

    @RequestMapping("/changeDoctorPassword")
    @ResponseBody
    public ResultUtil changeDoctorPassword(String username, String oldPassword, String newPassword1) {

        Doctor doctor = doctorService.getDoctorByUserName(username);

        if (doctor != null) {
            if (doctor.getPassword().equals(EncryptUtil.encrypt(oldPassword))) {
                doctor.setPassword(EncryptUtil.encrypt(newPassword1));
                doctorService.updateDoctor(doctor);
                return ResultUtil.ok();
            } else {
                return ResultUtil.error("旧密码错误,请重新填写");
            }
        }
        return ResultUtil.error("请求出错!!");

    }

    //医生注册
    @RequestMapping("/newUser")
    @ResponseBody
    public ResultUtil newUser(Doctor doctor) {
        try {
            doctor.setRoleId(3); //角色里表示医生
            doctor.setDepart_id(1);//新注册医生 未分配科室
            doctor.setRank(String.valueOf(5)); //新注册的医生默认是实习
            doctor.setPassword(EncryptUtil.encrypt(doctor.getPassword()));
            Date date = new Date();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String nowTime = simpleDateFormat.format(date);
            Date create_time = simpleDateFormat.parse(nowTime);

            doctor.setCreateTime(create_time);
            doctorService.insDoctor(doctor);
            return ResultUtil.ok();

        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error();
        }

    }

    @RequestMapping("/getMenus")
    @ResponseBody
    public List<Menu> getMenus(HttpSession session) {
        List<Menu> menus = null;
        Doctor doctor = (Doctor) session.getAttribute("hospital_user");
        Doctor doctor1 = doctorService.getDoctorById(doctor.getDoctor_id());
        if (doctor1 != null) {
            menus = doctorService.getMenus(doctor1);
        }
        return menus;
    }

    @RequestMapping("/logOut")
    public ModelAndView logOut(ModelAndView modelAndView, HttpSession session) {
        session.invalidate();
        modelAndView.setViewName("redirect:/index.jsp");
        return modelAndView;
    }
}

UserController.java

package com.code2life.hospital.web;

import com.code2life.hospital.entity.Admin;
import com.code2life.hospital.entity.Depart;
import com.code2life.hospital.entity.Menu;
import com.code2life.hospital.entity.User;
import com.code2life.hospital.service.DepartService;
import com.code2life.hospital.service.DoctorService;
import com.code2life.hospital.service.UserService;
import com.code2life.hospital.util.EncryptUtil;
import com.code2life.hospital.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("/user")
public class UserController
{

    @Autowired
    private UserService userService;

    @Autowired
    private DepartService departService;

    @Autowired
    private DoctorService doctorService;

    @RequestMapping("/login")
    @ResponseBody
    public ResultUtil login(String username, String password, HttpServletRequest request, HttpSession session)
    {
        User user=userService.login(username, EncryptUtil.encrypt(password));

        if(user!=null)
        {
            Integer status=user.getStatus();
            if(status==0)
            {
                 return ResultUtil.error("对不起,此用户被禁用,请联系超级管理员");
            }
            Admin admin=new Admin();
            session.setAttribute("user",admin); //拦截器中用 跳过拦截器
            session.setAttribute("hospital_user",user);
            session.setAttribute("usertype",2);//代表患者登陆
            session.setAttribute("hospital_user_id",user.getUser_id());
            session.setAttribute("hospital_user_photo",user.getPhoto_path());//获得头像图片名
            return ResultUtil.ok();
        }
        else
        {
            return ResultUtil.error("用户名或者密码错误,请重新输入");
        }

    }

    @RequestMapping("/getMenus")
    @ResponseBody
    public List<Menu> getMenus(HttpSession session)
    {
        //System.out.println("学生获取菜单进来了");
        List<Menu> menus=null;
        User user= (User) session.getAttribute("hospital_user");
        User user1=userService.getUserById(user.getUser_id());
        if(user1!=null)
        {
            menus=userService.getMenus(user1);
        }
        return menus;
    }

    @RequestMapping("/logOut")
    public ModelAndView logOut(ModelAndView modelAndView, HttpSession session)
    {
        session.invalidate();
        modelAndView.setViewName("redirect:/index.jsp");
        return modelAndView;
    }


    @RequestMapping("/info")
    public String info(HttpSession session)
    {
        //覆盖一下之前的hospital_user 不然显示的还是之前的hospital_user
        Integer user_id= (Integer) session.getAttribute("hospital_user_id");
        User user=userService.getUserById(user_id);
        session.setAttribute("hospital_user",user);
        return "/jsp/user/editUser";
    }
    @RequestMapping("/updateUser")
    @ResponseBody
    public ResultUtil updateUser(User user)throws ParseException
    {


        return userService.updateUser(user);
    }

    @RequestMapping("/changePassword")
    public  String changePassword()
    {
        return "/jsp/user/changePassword";
    }
    @RequestMapping("/changeUserPassword")
    @ResponseBody
    public ResultUtil changeStudentPassword(String oldPassword,String newPassword1,String username)
    {
        User user=userService.getUsertByUserName(username);
        if(user!=null)
        {
            if(user.getPassword().equals(EncryptUtil.encrypt(oldPassword)))
            {
                user.setPassword(EncryptUtil.encrypt(newPassword1));
                userService.updateUser(user);
                return ResultUtil.ok();
            }
            else
            {
                return ResultUtil.error("旧密码错误,请重新填写");
            }
        }
        return ResultUtil.error("请求出错!!");

    }

    @RequestMapping("/newUser")
    @ResponseBody
    public  ResultUtil newUser(User user)
    {
        try
        {
            user.setStatus(1); //1表示正常
            user.setRoleId((long) 2); //角色里表示一般用户
            user.setLevelId(1); //普通用户
            user.setPassword(EncryptUtil.encrypt(user.getPassword()));
            Date date=new Date();
            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String nowTime=simpleDateFormat.format(date);
            Date create_time=simpleDateFormat.parse(nowTime);

            user.setCreateTime(create_time);
            userService.insUser(user);
            return ResultUtil.ok();

        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ResultUtil.error();
        }

    }


    //下面是用户注册的时候 上传的头像
    @RequestMapping(value = "/image", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> image(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request, HttpServletResponse response)
    {
        Map<String, Object> map2 = new HashMap<String, Object>();
        Map<String, Object> map = new HashMap<String, Object>();
        String filename = "";

        String localPath = "D:\\IdeaWorkSpace\\hospital_img\\"; //存放我们上传的头像
        try {
            if (file != null) {
                //生成uuid作为文件名称
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                //获得文件类型(可以判断如果不是图片,禁止上传)
                String contentType = file.getContentType();
                //获得文件后缀名
                String suffixName = contentType.substring(contentType.indexOf("/") + 1);
                //得到 文件名(随机数+uuid+后缀)
                filename = (int)((Math.random())*100000000)+uuid + "." + suffixName;

//            判断是否有这个文件夹,没有就创建
                if (!new File(localPath).exists()) {

                    new File(localPath).mkdirs();
                }
//            复制到当前文件夹
                file.transferTo(new File(localPath + filename));

            }
        } catch (Exception e) {

            map.put("code", 1);
            map.put("msg", "");
            map.put("data", map2);
            map2.put("src", filename);
            return map;

        }

        map.put("code", 0);
        map.put("msg", "");
        map.put("data", map2);
        map2.put("src", filename);
        return map;
    }

    @RequestMapping("/doctorList")
    public String doctorList(HttpSession session)
    {
        List<Depart> departs=departService.getAllDeparts();
        session.setAttribute("departs",departs);
        return "/jsp/user/doctorList";
    }

}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


<display-name>Archetype Created Web Application</display-name>
  <!--配置 Spring 容器-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring_root.xml</param-value>
  </context-param>

  <!--中文乱码处理过滤-->
  <!-- 编码过滤器 -->
  <filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!--配置 Spring mvc 容器-->
  <!--将所有请求,都交给Spring MVC 处理-->
  <servlet>
    <servlet-name>webs</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring_web.xml</param-value>
    </init-param>
  </servlet>
  <!--将 请求 截取 转交给 webs -->
  <servlet-mapping>
    <servlet-name>webs</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>



</web-app>

写在最后

完整源码点击头像查看个人签名

觉得有用,记得一键三连哦!

标签:return,String,管理,预约,hospital,挂号,user,import,public
From: https://blog.51cto.com/u_15625185/5807553

相关文章

  • 云原生之旅 - 5)Kubernetes时代的包管理工具 Helm
    前言上一篇文章[基础设施即代码使用Terraform创建Kubernetes] 教会了你如何在Cloud上面建Kubernetes资源,那么本篇来讲一下如何在Kubernetes上面部署应用。大家都知......
  • 包管理
    1软件包依赖关系Debian系统通过其控制文件字段中的版本化二进制依赖声明机制来提供一致的二进制软件包集合。下面有一些它们的简单定义。“依赖”绝对的依赖,所有在......
  • 删掉Win11 22h2文件管理器中的 “主文件夹”
    Win1122h2升级后,文件管理器左侧多了一个"主文件夹"的链接,没啥用还占位置,之前一直较忙没有管它,今天研究了一下,可以通过注册表干掉它:WindowsRegistryEditorVersion5.......
  • 10.用户资料管理(查询和修改)
    用户资料管理(查询和修改)一、查询/***根据用户id查询UserInfo1.请求路径:/users2.请求参数:请求头的Authorization:token(必须),用户id:userID(非必须)3.响应数据:UserIn......
  • K8S入门篇-权限控制管理
    一、RBAC-基于角色的权限控制  范例1:聚合的权限 Aggregate创建一个clusterrolekind:ClusterRoleapiVersion:rbac.authorization.k8s.io/v1metadata:name:......
  • 分区内存管理分区选择法
    1.分区内存管理:把主存分为一段一段的,每一段的空间要比一页小很多,这种方法在空间利用率上比业式管理高很多,但有另外一个缺点:一个程序片段可能会被分为几十段,这样很多时间就......
  • HCIA-ICT实战基础09-远程接入安全管理
    HCIA-ICT实战基础-远程接入安全管理目录AAA概述AAA配置实现telnet原理与配置Stelnet(华为ssh的另一种称呼)配置1AAA概述1.1基本概念AAA是Authentication(认证)、......
  • VueX状态管理
    目录总览:一、VueX概念1.VueX的概念Vuex是一个专为Vue.js应用程序开发的状态管理模式。它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可......
  • 最新php多商户多仓库带扫描云进销存系统ERP管理系统Saas营销版无限商户源码
    1、电脑端+手机端,手机实时共享,手机端一目了然。2、多商户Saas营销版无限开商户,用户前端自行注册,后台管理员审核开通3、管理员开通商户,可以设置商户到期时间、权限等等,无......
  • 21级期中考试:校园社团活动管理系统
    昨天刚进行了期中考试,考的和19级期中差不多,以下是我的代码和一些体会,顺便写一下思路(没人讲,自己看太难受了)首先,基本思路都一样,就是增删改查,第一步要做的就是建一个网络界面......