计算机Java项目|基于Springboot实现患者管理系统

news2024/9/30 3:18:55

 作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

文末获取源码 

项目编号:KS-032

一,项目简介

医院病患管理,Springboot+Thymeleaf+BootStrap+Mybatis,页面好看,功能完全.有登录权限拦截、忘记密码、发送邮件等功能。主要包含病患管理、信息统计、用户注册、用户登陆、病患联系等功能

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

三,系统展示

登陆

注册

首页

病患管理

个人信息管理

发邮件

四,核心代码展示

package com.liefox.config;

import org.springframework.web.servlet.HandlerInterceptor;

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

/**
 * @Author znz
 * @Date 2021/4/19 下午 12:41
 **/
public class LoginHandlerInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        //登录成功之后,应该有用户的session
        Object loginUser = request.getSession().getAttribute("loginUser");


        if (loginUser == null) {
            System.err.println("loginUserSession=>"+loginUser);
            request.setAttribute("msg", "没有权限,请登录");
            /*转发到登录页*/
            request.getRequestDispatcher("/tosign-in").forward(request, response);
            return false;
        } else {
            return true;
        }
    }
}
package com.liefox.config;

import org.springframework.web.servlet.LocaleResolver;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * @Author znz
 * @Date 2021/4/19 上午 9:44
 * 国际化
 **/
public class MyLocaleResolver implements LocaleResolver {
    //解析请求
    @Override
    public Locale resolveLocale(HttpServletRequest httpServletRequest) {
        //获取请求中的语言参数
        String language = httpServletRequest.getParameter("l");
        Locale locale = Locale.getDefault();//如果没有就使用默认值
        //如果请求的链接携带了国际化的参数
        if (!StringUtils.isEmpty(language)) {
            //zh_CN
            String[] split = language.split("_");
            //国家地区
            locale = new Locale(split[0], split[1]);
        }
        return locale;
    }

    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {

    }
}

package com.liefox.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author znz
 * @Date 2021/4/18 下午 2:40
 **/
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        /**
         * 医生页
         * */
        /*欢迎页*/
        registry.addViewController("/").setViewName("doctor/sign-in");
        /*首页*/
        registry.addViewController("/index").setViewName("doctor/index");
        /*去登录*/
        registry.addViewController("/tosign-in").setViewName("doctor/sign-in");
        /*去注册*/
        registry.addViewController("/tosign-up").setViewName("doctor/sign-up");
        /*去忘记密码*/
        registry.addViewController("/torecoverpw").setViewName("doctor/pages-recoverpw");
        /*去修改个人信息*/
        registry.addViewController("/topro-edit").setViewName("doctor/main/profile-edit");
        /*去邮箱*/
        registry.addViewController("/toemail").setViewName("doctor/app/email-compose");
        /*去编辑病患表格*/
        registry.addViewController("/totable").setViewName("doctor/app/table-editable");
        /*去修改病患信息*/
        registry.addViewController("/toRePatientInfo").setViewName("doctor/app/rePatientInfo");
        /*去增加病患信息*/
        registry.addViewController("/toAddPatientInfo").setViewName("doctor/app/addPatientInfo");
        /*去群聊天*/
        registry.addViewController("/toChat").setViewName("doctor/main/chat");


        /**
         * 医生页
         * */
    }

    //自定义的国际化就生效了
    @Bean
    public LocaleResolver localeResolver() {
        return new MyLocaleResolver();
    }


    //配置登录拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                /*拦截*/
                .addPathPatterns("/**")
                /*放行*/
                .excludePathPatterns(
                        "/tosign-in"
                        , "/tosign-up"
                        , "/sign-in"
                        , "/sign-up"
                        , "/torecoverpw"
                        , "/recPwEmail"
                        , "/recPw"
                        , "/"
                        , "/css/**"
                        , "/js/**"
                        , "/images/**"
                        , "/app/**"
                        , "/fonts/**"
                        , "/fullcalendar/**"
                );
    }


}
package com.liefox.controller;

import com.liefox.pojo.Patient;
import com.liefox.pojo.User;
import com.liefox.service.PatientService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.UUID;

/**
 * @Author znz
 * @Date 2021/4/21 下午 1:35
 **/
@Controller
public class PatientController {

    @Autowired
    private PatientService patientService;
    @Autowired
    JavaMailSenderImpl mailSender;

    /*获取全部病者信息*/
    @RequestMapping("/getPatientInfo")
    public String getPatientInfo(Model model) {
        List<Patient> patientInfo = patientService.getPatientInfo();

        model.addAttribute("patientInfos", patientInfo);
        return "doctor/app/table-editable";
    }

    /*删除病人信息根据UUID*/
    @RequestMapping("/delPatientInfoByUUID/{UUID}")
    public String delPatientInfoByUUID(@PathVariable("UUID") String UUID) {
        patientService.delPatientInfoByUUID(UUID);
        return "redirect:/getPatientInfo";
    }

    /*获取病人信息根据UUID*/
    @RequestMapping("/getPatientInfoByUUID/{UUID}")
    public String getPatientInfoByUUID(@PathVariable("UUID") String UUID, Model model) {
        Patient patientInfoByUUID = patientService.getPatientInfoByUUID(UUID);
        System.out.println(patientInfoByUUID);
        model.addAttribute("patientInfoByUUID", patientInfoByUUID);
        return "doctor/app/rePatientInfo";
    }

    /*更新病人信息根据UUID*/
    @RequestMapping("/upPatientInfoByUUID")
    public String upPatientInfoByEmail(Patient patient) {
        patientService.upPatientInfoByUUID(patient);
        return "redirect:/getPatientInfo";
    }

    /*去新增病患页*/
    @RequestMapping("/toAddPatientInfo")
    public String toAddPatientInfo(Model model) {
        String uuid = UUID.randomUUID().toString();
        model.addAttribute("uuid", uuid);
        return "doctor/app/addPatientInfo";
    }


    /*新增病患*/
    @RequestMapping("/addPatientInfo")
    public String addPatientInfo(Patient patient, Model model) {
        int i = patientService.addPatientInfo(patient);
        model.addAttribute("msg", "添加成功!");
        return "redirect:/getPatientInfo";
    }

    /*去发邮件页面*/
    @RequestMapping("/toEmail/{Email}")
    public String toEmail(@PathVariable("Email") String Email, Model model) {
        model.addAttribute("PatientEmail", Email);
        return "doctor/app/email-compose";
    }

    /*发邮件给病者*/
    @RequestMapping("/sentEmail")
    public String recPwEmail(String ToEmail, String CcEmail, String subject, String Message,
                             HttpSession session, Model model) {
        try {
            //邮件设置
            SimpleMailMessage message = new SimpleMailMessage();
            //主题
            message.setSubject(subject);
            //内容
            message.setText(Message);
            //收件人
            message.setTo(ToEmail);
            //发件人
            message.setFrom(CcEmail);
            //发送
            mailSender.send(message);
            model.addAttribute("info", "邮件发送成功!");
            return "doctor/app/email-compose";
        } catch (Exception e) {
            model.addAttribute("info", "邮箱地址不正确!");
            return "doctor/app/email-compose";
        }


    }

}
package com.liefox.controller;

import com.liefox.pojo.Patient;
import com.liefox.pojo.User;
import com.liefox.service.PatientService;
import com.liefox.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author znz
 * @Date 2021/4/18 下午 5:30
 **/
@Controller
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    JavaMailSenderImpl mailSender;
    @Autowired
    private PatientService patientService;

    /**
     * 生成6位随机数验证码
     */
    public static int randomCode() {
        return (int) ((Math.random() * 9 + 1) * 100000);
    }

    /**
     * i:验证码
     */
    static int i = randomCode();

    /*注册*/
    @PostMapping("/sign-up")
    public String signup(User user, Model model) {
        try {
            int i = userService.Signup(user);
            if (i != 0) {
                System.out.println(user + "=》注册成功");
                model.addAttribute("msg", "注册成功!");
                return "/doctor/sign-in";
            }
        } catch (Exception e) {
            System.err.println(user + "=>注册失败");
            model.addAttribute("msg", "该邮箱已注册!");
            return "/doctor/sign-up";
        }
        return null;
    }

    /*登录*/
    @RequestMapping("/sign-in")
    public String signin(User user, Model model, HttpSession session, String Email) {
        User signin = userService.Signin(user);
        User userInfo = userService.getUserInfo(Email);
        System.out.println(userInfo + "用户信息");
        String userName = userService.getUserName(user.getEmail(), user.getPassword());
        if (signin != null) {
            /*用户信息*/
            session.setAttribute("UserInfo", userInfo);
            /*登录拦截*/
            session.setAttribute("loginUser", userName);
            /*获取病人病情信息*/
            List<Patient> patientInfo = patientService.getPatientInfo();
            long count = patientInfo.stream().count();
            model.addAttribute("patientInfos",patientInfo);
            model.addAttribute("count",count);
            /*获取医生信息*/
            List<User> userinfo = userService.getUser();
            model.addAttribute("userInfos",userinfo);
            /**/
            session.setAttribute("Email", Email);
            System.out.println(user + "=》登录成功");
            return "/doctor/index";
        } else {
            System.err.println(user + "=》登录失败");
            model.addAttribute("msg", "邮箱地址或密码错误!");
            return "/doctor/sign-in";
        }

    }
    /*去首页*/
    @RequestMapping("/toindex")
    public String toindex(Model model){
        /*获取病人病情信息*/
        List<Patient> patientInfo = patientService.getPatientInfo();
        model.addAttribute("patientInfos", patientInfo);
        long count = patientInfo.stream().count();
        model.addAttribute("count",count);
        /*获取医生信息*/
        List<User> user = userService.getUser();
        model.addAttribute("userInfos",user);
        return "/doctor/index";
    }

    /*注销*/
    @RequestMapping("/logout")
    public String logout(HttpSession session) {
        session.removeAttribute("loginUser");
        return "redirect:/sign-in.html";
    }

    /*忘记密码发邮件*/
    @RequestMapping("/recPwEmail")
    public String recPwEmail(String Email, HttpSession session, Model model) {
        System.out.println(Email + "发送了验证码");
        System.err.println(i);

        session.setAttribute("Email", Email);
        try {
            //邮件设置
            SimpleMailMessage message = new SimpleMailMessage();
            //主题
            message.setSubject("Shiqi-验证码");
            //内容-验证码
            message.setText(String.valueOf(i));
            //收件人
            message.setTo(Email);
            //发件人
            message.setFrom("2606097218@qq.com");
            //发送
            mailSender.send(message);
            model.addAttribute("info", "验证码发送成功!");
            return "/doctor/pages-recoverpw";
        } catch (Exception e) {
            System.err.println("cs");
            model.addAttribute("info", "邮箱地址不正确!");
            return "/doctor/pages-recoverpw";
        }


    }

    /*判断验证码正确,并重置密码*/
    @RequestMapping("/recPw")
    public String recPw(String Email, int token, String Password, Model model) {
        System.out.println(Email + "    重置密码为=》" + Password + "     输入的验证码为     " + i);

        if (token == i) {
            userService.recPw(Email, Password);
            model.addAttribute("info", "修改成功!");
            return "/doctor/sign-in";
        } else {
            model.addAttribute("error", "验证码错误!");
            return "/doctor/pages-recoverpw";
        }

    }

    /*查看个人信息页面*/
    @RequestMapping("/getUserInfo")
    public String getUserInfo() {
        return "/doctor/main/profile-edit";
    }

    /*修改个人信息*/
    @RequestMapping("/updateUserInfo")
    public String updateUserInfo(User user, Model model) {
        int i = userService.updateUserInfo(user);
        if (i != 0) {
            model.addAttribute("msg","下次登录生效!");
            return "/doctor/main/profile-edit";
        }else {
            System.err.println("111111111");
            model.addAttribute("msg","不修改就别乱点!");
            return "/doctor/main/profile-edit";
        }

    }

    /*修改密码*/
    @RequestMapping("/upPw")
    public String upPw(String Email,String Password,Model model){
            userService.upPw(Email, Password);
            model.addAttribute("info","修改成功!");
            return "doctor/sign-in";


    }


}

五,项目总结

整个系统功能模块不是很多,但是系统选题立意新颖,功能简洁明了,个性功能鲜明突出,像邮件发送、图片报表展示和统计等,可以做毕业设计或课程设计使用。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1363227.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Hello 2024

Hello 2024 A. Wallet Exchange 题意&#xff1a;Alice和Bob各有a和b枚硬币&#xff0c;每次他们可以选择交换硬币或者保留&#xff0c;然后扣除当前一枚手中的硬币&#xff0c;当一方没得扣另一方就赢了。 思路&#xff1a;Alice先手&#xff0c;所以当硬币和为奇数时Alice…

Java面试之并发篇(一)

1、前言 本篇主要总结JAVA面试中关于并发相关的高频面试题。本篇的面试题基于网络整理&#xff0c;和自己编辑。在不断的完善补充哦。 2、简述程序、进程、线程、的基本概念&#xff1f; 2.1、程序 程序&#xff0c;是含有指令和数据的文件&#xff0c;被存储在磁盘或其他的…

基于神经网络的手写汉字提取与书写评分系统研究

相关源码和文档获取请私聊QQ:3106089953 论文目录结构 目 录 摘 要 I Abstract II 目 录 IV 第1章 绪论 1 1.1. 研究背景与意义 1 1.2. 国内外研究现状 2 1.2.1. 文本定位技术研究现状 2 1.2.2. 手写汉字识别研究现状 3 1.2.3. 汉字书写质量评价方法研究现状 4 1.3. 本文所做工…

OS_lab——bochs源码的编译与安装

1. 实验环境VMware station 15 Ubuntu 14.04.6 32位。2. 实验步骤2.1 安装虚拟机&#xff0c;并在虚拟机根目录下编译并安装bochs环境。 2.2 使用bochs自带工具bximage创建虚拟软驱。 2.3 编写引导程序boot.asm并用nasm编译得到引导文件boot.bin和boot.com。 2.4 修改bochs…

Hadoop分布式文件系统(二)

目录 一、Hadoop 1、文件系统 1.1、文件系统定义 1.2、传统常见的文件系统 1.3、文件系统中的重要概念 1.4、海量数据存储遇到的问题 1.5、分布式存储系统的核心属性及功能含义 2、HDFS 2.1、HDFS简介 2.2、HDFS设计目标 2.3、HDFS应用场景 2.4、HDFS重要特性 2.4…

性能分析与调优: Linux 安装基于BPF的bcc-tools系统性能工具库

目录 一、实验 1.环境 2.agent服务器安装使用ELRepo安装依赖包 3.agent服务器安装基于BPF的bcc-tools系统性能工具库 二、问题 1.安装bcc-tools后执行命令报错 一、实验 1.环境 &#xff08;1&#xff09;主机 表1-1 主机 主机架构组件IP备注prometheus 监测 系统 pro…

【C++】- 类和对象(!!C++类基本概念!this指针详解)

类和对象 引入类类的定义类的访问限定操作符类的作用域类的实例化类对象模型this指针 引入类 在 C中&#xff0c;引入了一个新的定义----------类。类是一种用户自定义的数据类型&#xff0c;用于封装数据和行为。类可以看作是一个模板或蓝图&#xff0c;描述了一组相关的数据和…

JVM虚拟机的垃圾回收器(面试题)

1.什么是垃圾回收 垃圾回收主要说的是java会自动把程序在运行过程中产生的一些没有用的对象给回收掉&#xff0c;这样可以避免内存的浪费。 java主要是通过一个叫“根可达”的算法来识别这个对象是否可以被回收的&#xff0c;然后回收的算法也主要有三种&#xff1a;标记清除&a…

QT c++和qml交互实例

文章目录 一、demo效果图二、c和qml交互的基本方式1、qml访问C类对象 三、关键代码1、工程结构图2、c代码MainWindow.cppMainQuickView.cppStudentInfoView.cppStudentInfoModel.cpp 3、qml代码main.qmlMainQuickTopRect.qmlMainQuickMiddleRect.qmlMainQuickMiddleTableRect.q…

服务器cpu占用很高如何排查问题

前段时间&#xff0c;运维监控发现有个项目cpu占用很高&#xff0c;并且还在持续不断增长&#xff0c;服务不能正常响应&#xff0c;如下图&#xff1a; 在服务器上面安装了arthas&#xff0c;下载地址&#xff1a; https://alibaba.github.io/arthas/arthas-boot.jar 我使用了…

Linux stm32串口下载程序

一、工具 使用stm32flash进行串口下载 二、stm32flash安装 sudo apt-get install stm32flash 三、查看串口设备名称 先拔掉串口运行下面指令&#xff0c;获得所有设备名称,插上串口再运行一次&#xff0c;新增的就是串口设备名称&#xff0c;记住串口设备名称&#xff0c;以…

【信息论与编码】习题-判断题-第一部分

目录 判断题1. 对于N个对立并联信道&#xff0c;其信道容量CN2. 汉明码是一种线性分组码。3. 某一信源&#xff0c;不管它是否输出符号&#xff0c;只要这些符号具有某些概率特性&#xff0c;就有信息量。4. 若检错码的最小距离为dmin&#xff0c;则可以检测出任意小于等于dmin…

集团企业OA办公协同平台建设方案

一、企业对协同应用的需求分析 实现OA最核心、最基础的应用 业务流转&#xff1a;收/发文、汇报、合同等各种审批事项的业务协作与办理 信息共享&#xff1a;规章制度、业务资料、共享信息资源集中存储、统一管理 沟通管理&#xff1a;电子邮件、手机短信、通讯录、会议协作等…

期货日数据维护与使用_日数据维护_日数据更新

目录 写在前面&#xff1a; 下载日数据 下载“新增合约”日数据 下载“待更新合约”日数据 日数据文件 “选择日数据所在目录”按钮点击 “执行”按钮点击 sqlite3代码 按钮点击后执行的代码 子线程代码 写在前面&#xff1a; 本文默认已经创建了项目&#xff0c;如…

Archlinux下自启动rclone mount

路径&#xff1a; /etc/systemd/system/rclonemount.service [Unit] Descriptionrclonemount Requiresnetwork-online.target.wants Afteralist.service[Service] Typesimple ExecStartPre/bin/mkdir -p /media ExecStart/usr/bin/rclone mount \aliyun: /media \--config /ro…

Docker学习与应用(五)-DockerFile

1、DockerFile 1&#xff09;DockerFile介绍 dockerfile是用来构建docker镜像的文件&#xff01;命令参数脚本&#xff01; 构建步骤&#xff1a; 1. 编写一个dockerfile文件 2. docker build 构建称为一个镜像 3. docker run运行镜像 4. docker push发布镜像&#xff08;D…

2024最新前端源码分享(附效果图及在线演示)

分享10款非常有趣的前端特效源码 其中包含css动画特效、js原生特效、svg特效以及小游戏等 下面我会给出特效样式图或演示效果图 但你也可以点击在线预览查看源码的最终展示效果及下载源码资源 粒子文字动画特效 基于canvas实现的粒子文字动画特效 会来回切换设定的文字特效 图…

Docker学习与应用(四)-容器数据卷

1、容器数据卷 1&#xff09;什么是容器数据卷 docker的理念回顾 将应用和环境打包成一个镜像&#xff01; 数据&#xff1f;如果数据都在容器中&#xff0c;那么我们容器删除&#xff0c;数据就会丢失&#xff01;需求&#xff1a;数据可以持久化 MySQL&#xff0c;容器删…

java推荐系统:好友推荐思路

1.表的设计 表里面就两个字段&#xff0c;一个字段是用户id&#xff0c;另外一个字段是好友id&#xff0c;假如A跟B互为好友&#xff0c;那在数据库里面就会有两条数据 2.推荐好友思路 上面的图的意思是&#xff1a;h跟a的互为好友&#xff0c;a跟b&#xff0c;c&am…

webgl调试之排查内存泄漏

内存泄漏自然而然是要看内存是不是涨了 然后我们如何确认泄露了呢&#xff0c;我们需要把代码梳理清楚&#xff0c;知道哪个时机&#xff0c;在delete&#xff0c;在create&#xff0c;那么这个时候&#xff0c;按道理&#xff0c;delete了n个对象&#xff0c;create了N个对象&…