社区医疗系统平台的设计与实现
项目编号:BS-YL-019
一,项目简介
现在互联网是日新月异发展越来越快,已经在各行各业中不断受到大家的重视,也得到在不同的行业中进行使用。不管在那个行业都面临着现代化信息时代的挑战。同样医院行业也是如此,一个完善的社区医疗平台,要具有一般医院所具备的基本功能条件还有信息的管理功能,但是现在的一些社区卫生医疗基本上是通过原来的街道办诊所改建而来的,虽然可以满足日常患者看病的需求,但是在对于现在的人们来说已经越来越满足不了大家的需求了,同时对患者一些信息的管理也存在着严重的不中,还是纯手工的进行记录,如果要查询患者的一些信息是极为不方便的。现在我国的医疗行业的改革正在稳步前进,要实现居民看病不再难,不再排队,对患者信息有一种更有效的手段管理机制。
综以上所述,所以本次毕业项目我将开发一个社区医疗系统平台,来服务本社区的所有的居民。实现让居民看病不再困难,不再排队的问题,让居民感受到社区的服务很到位!本社区医疗系统平台将采用最流行的B/S结构和SSM框架做为项目的架构,使用IDEA工具进行编码,采用主流的MySql数据库存储数据。社区医疗系统主要有超级管理员、社区医生和患者三个角色。超级管理员可以对本系统中所有的数据进行操作。医生角色对患者进行接诊、添加病历等操作。患者可以在线预约和浏览社区医院的相关信息。此系统有效的减少了大量的人力投入和工作效率以及社区患者的看病效率极大的提供了方便和效率!
关键词: SSM;MySQL;MVC;LayUi;社区医疗
1.1.1业务流程
本系统一共有三个角色管理员、医生、患者。管理员和医生是通过后台登录进入到管理页面。而患者则是不同,患者先进入到社区医疗系统首页,在首页中可以登录也可以注册。登录成功后点击【个人中心】进入到后台管理,进行对患者的信息做操作。
社区医疗系统平台的超级管理员功能主要有以下几个:管理患者和医生信息、本社区医院有那些科室等功能。超级管理员业务流程图如图3.1所示。
编辑
图1.1 系统管理员业务流程图
社区医疗系统平台的医生功能主要包括以下几个:修改个人信息及密码,以及在线诊断和病历管理功能。
医生业务流程图如图1.2所示。
编辑
图1.2医生业务流程图
社区医疗系统平台患者功能主要包括以下几个:修改个人资料、浏览本社区医院的医生的一些基本信息,在线预约和取消预约,查看自己的以往的就诊历史。
患者业务流程图如图1.3所示。
编辑
图1.3 患者业务流程图
1.1.2数据流图
使用数据流图对系统进行分析,关注系统中的数据,主要展示系统的数据之间的处理过程。它采取分层描绘的方法,在顶层图中能展现系统与外部实体之间的信息关联,可以察看是否有输入信息、需要处理的信息和输出信息的疏漏,能尽早发现系统中的逻辑错误,并对其纠正。就这样逐层分解下去,系统的框架就可以被展现出来。系统顶层数据流图如图3.4所示。
编辑
图1.4系统顶层数据流图
系统1层数据流图如图1.5所示
编辑
图1.5系统1层数据流图
1.1.4功能需求
经过前期在社区的走访调研和网上查阅资料再根据目前所掌握的技术,具体的功能需求分析如下:
社区医疗系统平台主要有超级管理员、医生、患者三大角色和个人信息管理、医生管理、患者管理等14个功能。在这里管理员权限的级别是最高的同样它的功能也是最多的。接下来我们将根据不同的角色简单说明一下各个角色的功能需求:
1)管理员角色:管理员可以对医生信息的管理、患者信息的管理、医院公告、科室的管理、药品的管理等进行操作。
(1)医生管理模块中可以对医生实现添加医生,在添加医生界面中可以选择该医生所对应的的科室。修改操作只能对医生的用户名、真实姓名、科室、以及该医生所对应的级别进行修改。删除操作必须要通过主键id进行删除。查询是可以根据多条件进行查询并分页展示。条件查询可以根据用户输入的用户名、医生的真实姓名、性别、科室、级别、注册时间进行全方位的查询。
(2)对患者管理管理员没有添加功能,如果患者没有账户是需要通过患者在主页中点击注册进行注册用户之后,才可以进行预约。所以管理员只能对患者进行修改、删除和多条件分页查询。管理员可以修改患者的用户名、真实姓名、邮箱、级别(普通/VIP)、性别、手机号这些信息,在提交数据时是通过患者的唯一主键id进行修改用户信息。删除操作必须要通过主键id进行删除。条件查询可以根据管理员的任意组合方式进行全方位的查询。
(3)对公告管理功能管理员只有添加和删除功能。可以添加公告一些基本内容,添加完成之后立即发布公告。删除公告则通过主键id进行唯一删除。
(4)对科室管理功能管理员可以对科室进行添加、修改、删除功能。添加科室时要注意科室的名称不能重复的。修改科室通过id修改对应的科室的名称。删除科室功能要先查询该科室下是否有其他医生,如果有其他医生则不是直接删除,需要管理员回到医生管理中删除该分类下的医生,才可以删除科室,反之则可以直接删除科室。
(5)对药品管理功能管理员可以做药品添加、药品修改、药品删除和多条件查询操作。药品添加可以将药品的一些常见信息的录入。药品修改可以对药品的信息进行修改其他的生产日期和有效期是不能修改的,因为这是药品出厂已经规定好的。药品删除只能根据id删除,点击按钮把id传递到后台,在数据库删除记录即可。药品查询可以多条件查询条件可以输入药品的编号、药品的名称、药品的类别、主治功能、生产日期、药品价格进行模糊查询并分页展示在页面!
2)医生角色: 医生可对预约管理、患者病历、药品信息、医生信息、社保信息等进操作。
(1)预约管理功能分为两个操作一个是查看预约患者列表另外一个是已接诊的患者功能。在预约患者列表中查看预约信息,医生只能看到自己的患者预约信息。医生可以通过点击按钮进行接诊处理。接完诊就可以在已接诊的预约列表中查看,在这里医生就可以进行看病诊断添加病历信息了。
(2)患者病历功能医生可查看以往患者的病历信息,同时对病历可编辑,编辑的内容有患者的姓名、性别、病历的创建日期、诊断结论和诊断详情进行修改。删除只能通过id进行删除。
(3)药品信息功能,医生只有查看的权限没有添加、删除、修改的权限这些权限只有管理员才有。这个功能只是帮助医生在开药的时候方便查看药品的一些详情信息进行录入诊断记录。
(4)医生信息功能主要是修改个人资料及密码。
(5)社保信息功能主要是让医生看看当前的患者有没有社保信息,如果有社保可以在开药的时候进行开一些可以报销的药品。医生对社保这块的功能只有查询。其他操作只有患者本人才有。查询社保信息时也可以多条件的查询并分页。
3)患者角色:系统启动后自动进入门户系统,在门户系统中患者可以浏览本社区医疗系统的一些其他信息,比如门诊科室、社区医院的医疗特色、医院简介、医室团队、新闻动态等内容。在门诊科室和医师团队页面中可以在线预约就诊。在点击【预约】时如果患者没有登录则会提示患者登录。点击【个人中心】进入到患者的后台管理进行查看患者的预约信息以及个人资料和以往的病历信息。
(1)我的预约功能可以取消预约操作。
(2)个人资料是修改个人的基本信息。
(3)病历信息功能查看患者以往的就诊信息,这个功能只能查询没有删除、修改、添加功能。在查询时还可以根据病例的标题、病历诊断内容等多条件查询并分页展示。
二,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台技术:SSM+MAVEN
前台技术:layui+jquery+ajax
三,系统展示
5.1 门户前台模块实现
前台页面主要集成了首页、门诊科室、医疗特色、医院简介、医师团队、新闻动态、联系我们等信息的展示。方便患者可以从前台就能了解社区医院的基本信息,也能让患者找到相应的科室,进行预约自己喜欢的医生。患者在浏览时是不需要登录系统的,如果要预约的话是需要进行登录才能预约医生进行就诊。门户前台页面如图5.1所示。
编辑
图5.1门户前台界面
5.2 登录功能模块实现
登录功能有两套界面一个是患者从门户登录预约医生另外一个是管理员和医生登录的界面。居民登录成功后页面跳转到门户系统的首页,根据患者想浏览的信息进行选择相应的模块。管理员和医生在登录时要进行选择相应的角色,再填入登录所需的信息,最后提交正确无误后才能完成登录。后台会在以上填写的信息正确的基础至上,会查询该角色所拥有的菜单,不同的权限有不同的菜单选项的,最后就会在后台首页展示相应的菜单列表进行操作。
登录流程如图5.2所示:
编辑
图5.2登录流程图
患者登录界面如图5.3所示:
编辑
图5.3患者登录界面
患者登录界面如图5.4所示:
编辑
图5.4管理员/医生登录界面
5.3 注册功能模块实现
注册功能也是分为两套,患者和医生注册。当患者第一次在本院就诊时如果没有用户必须要注册才能在线预约就诊。如果医生想在本社区平台进行坐诊,也是要进行注册的注册成功后管理员进行分配科室即可。
注册流程如图5.5所示:
编辑
图5.5 注册功能流程
注册界面如图5.6所示:
编辑
图5.6 医生注册界面
居民注册界面如图5.7所示:
编辑
图5.7 居民注册界面
5.4 科室功能模块实现
科室管理功能对本社区医院所有的科室进行管理操作。如果科室类别中已分配医生,那么该科室不能被删除。
科室信息添加页面如图5.7所示:
编辑
图5.7 科室添加界面
编辑
5.5 医生功能模块实现
在这个模块中管理员可以通过修改功能给医生分配科室及修改信息,通过医生的唯一标识id删除医生信息。也能通过多条件查询进行详细查询想要的信息并分页展示。
医生功能管理界面如图5.9所示:
编辑
图5.9 医生功能管理界面
5.6 药品功能模块实现
药品功能模块主要实现的功能有药品的多条件查询并分页展示、药品信息的管理。修改药品只能修改其名称、药品的类别、药品功效、药品价格、药品说明等内容。
药品功能管理界面如图5.10所示:
编辑
图5.10 药品功能管理界面
5.7 患者功能模块实现
主要实现了对患者进行多条件查询并分页展示、修改患者信息,当然患者也可以对自己的信息进行修改、删除患者。在这里管理员不能添加患者的信息内容。只有患者自己注册才能添加患者的基本信息。因为患者不可能是联系到管理员,让管理员手动添加患者的信息的。
患者功能管理界面如图5.11所示:
编辑
图5.11 患者功能管理界面
四,核心代码展示
package com.zhang.hospital.web;
import com.zhang.hospital.entity.*;
import com.zhang.hospital.service.*;
import com.zhang.hospital.util.EncryptUtil;
import com.zhang.hospital.util.GsonUtil;
import com.zhang.hospital.util.ResultUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
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("/admin")
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
private UserService userService;
@Autowired
private DoctorService doctorService;
@Autowired
private DepartService departService;
@Autowired
private YaopinService yaopinService;
@RequestMapping("/login")
@ResponseBody
public ResultUtil login(String username, String password, HttpServletRequest request, HttpSession session)
throws ParseException {
Admin admin = adminService.login(username, EncryptUtil.encrypt(password));
if (admin != null) {
session.setAttribute("user", admin); //在拦截器中使用
session.setAttribute("admin", admin); //在main.jsp中需要admin
session.setAttribute("usertype", "1");//代表是管理员登录
// 还有修改密码.jsp等都可以直接取出admin
String loginIp = request.getHeader("x-forwarded-for");
if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
loginIp = request.getHeader("Proxy-Client-IP");//获取代理的IP
}
if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
loginIp = request.getHeader("WL-Proxy-Client-IP");//获取代理的IP
}
if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
loginIp = request.getRemoteAddr();
}
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = simpleDateFormat.format(date);
Date loginTime = simpleDateFormat.parse(nowTime);
Date logoutTime = loginTime;
Integer isSafeExit = 0;
adminService.insAdminLog(username, loginIp, loginTime, logoutTime, isSafeExit);
session.setAttribute("adminloginTime", loginTime); //点击退出的时候用的到
return ResultUtil.ok(admin.getId());
} else
return ResultUtil.error();
}
//获取所有的登录日志
@RequestMapping("/getAdminLogList")
@ResponseBody
public ResultUtil getAdminLogList(Integer page, Integer limit, HttpSession session)
throws ParseException {
return adminService.getAdminLogList(page, limit);
}
@RequestMapping("/userList")
public String userList() {
return "/jsp/admin/userList";
}
@RequestMapping("/yaopinList")
public String yaopinList() {
return "/jsp/admin/yaopinList";
}
@RequestMapping("/doctorYaopinList")
public String doctorYaopinList() {
return "/jsp/yaopin/yaopinList";
}
@RequestMapping("/shebaoList")
public String shebaoList() {
return "/jsp/shebao/shebaoList";
}
@RequestMapping("/allshebaoList")
@ResponseBody
public ResultUtil allSheBaoList(Integer page, Integer limit,ShebaoSearch shebaoSearch) {
// System.out.println("yaopinSearch:" + yaopinSearch);
return doctorService.allSheBaoList(page, limit,shebaoSearch);
}
@RequestMapping("/getAllUserList")
@ResponseBody
public ResultUtil getAllUserList(Integer page, Integer limit, UserSearch search) {
return userService.getAllUserList(page, limit, search);
}
@RequestMapping("/bingliList")
public String bingliList() {
return "/jsp/user/bingliList";
}
@RequestMapping("/mybingliList")
@ResponseBody
public ResultUtil getMyBingliList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10")Integer limit,
HttpSession session,BingliSearch bingliSearch){
return userService.getMyBingliList(page, limit,session,bingliSearch);
}
@RequestMapping("/allYaopinList")
@ResponseBody
public ResultUtil allYaopinList(Integer page, Integer limit,YaopinSearch yaopinSearch) {
System.out.println("yaopinSearch:" + yaopinSearch);
return yaopinService.allYaopinList(page, limit,yaopinSearch);
}
@RequestMapping("/doctorList")
public String doctorList(HttpSession session) {
List<Depart> departs = departService.getAllDeparts();
session.setAttribute("departs", departs);
return "/jsp/admin/doctorList";
}
@RequestMapping("/getAllDoctorList")
@ResponseBody
public ResultUtil getAllDoctorList(Integer page, Integer limit, DoctorSearch search) {
return doctorService.getAllDoctorList(page, limit, search);
}
@RequestMapping("/deleteDoctorById")
@ResponseBody
public ResultUtil deleteDoctorById(int doctor_id) {
return doctorService.deleteDoctorById(doctor_id);
}
@RequestMapping("/deleteYaoPinById")
@ResponseBody
public ResultUtil deleteYaoPinById(Integer id) {
return yaopinService.deleteYaoPinById(id);
}
@RequestMapping("/deleteUserById")
@ResponseBody
public ResultUtil deleteUserById(int user_id) {
return userService.deleteUserById(user_id);
}
@RequestMapping("/editUser/{user_id}")
public String editStudent(@PathVariable("user_id") int user_id, HttpSession session) {
User user = userService.getUserById(user_id);
session.setAttribute("hospital_user", user);
return "/jsp/user/editUser";
}
@RequestMapping("/editYaoPin/{id}")
public String editYaoPin(@PathVariable("id") Integer id, HttpSession session) {
YaoPin yaoPin = yaopinService.getYaoPinById(id);
session.setAttribute("yaopin", yaoPin);
return "/jsp/admin/editYaoPin";
}
@RequestMapping("/editDoctor/{doctor_id}")
public String editDoctor(@PathVariable("doctor_id") int doctor_id, HttpSession session) {
Doctor doctor = doctorService.getDoctorById(doctor_id);
session.setAttribute("hospital_user", doctor);
return "/jsp/admin/editDoctor";
}
/********Role相关*******/
//获取角色列表 带分页
@RequestMapping("/getRoleList")
@ResponseBody
public ResultUtil getRoleList(Integer page, Integer limit) {
return adminService.getRoles(page, limit);
}
//删除一个角色
@RequestMapping("/delRole/{roleId}")
@ResponseBody
public ResultUtil delRole(@PathVariable("roleId") Long roleId) {
adminService.delRole(roleId);
return ResultUtil.ok();
}
//得到指定角色权限树
// 注解RequestMapping中produces属性可以设置返回数据的类型以及编码,可以是json
@RequestMapping(value = "/xtreedata", produces = {"text/json;charset=UTF-8"})
@ResponseBody
public String xtreeData(@RequestParam(value = "roleId", defaultValue = "-1") Long roleId) {
return GsonUtil.entityToJson(adminService.getXtreeData(roleId));
}
// 检查角色是否唯一
@RequestMapping("/checkRoleName/{roleName}/{roleId}")
@ResponseBody
public ResultUtil checkRoleName(@PathVariable("roleName") String roleName,
@PathVariable("roleId") Long roleId) {
Role role = adminService.getRoleByRoleName(roleName);
if (role == null)
{
return new ResultUtil(0);
} else if (role.getRoleId() == roleId) //已经有这个角色名 并且就是这个id 也可以
{
return new ResultUtil(0);
} else //此角色名已存在 别的roleId
{
return new ResultUtil(500, "已经存在此角色名");
}
}
// 检查角色是否唯一 添加新角色的时候用这个函数
@RequestMapping("/checkAddRoleName/{roleName}")
@ResponseBody
public ResultUtil checkRoleName(@PathVariable("roleName") String roleName) {
Role role = adminService.getRoleByRoleName(roleName);
if (role == null)//没有这个角色名 可以
{
return new ResultUtil(0);
} else //此角色名已存在
{
return new ResultUtil(500, "已经存在此角色名");
}
}
//更新角色
@RequestMapping("/updateRole")
@ResponseBody
public void updateRole(Role role, String m) {
// System.out.println(role);
// System.out.println(m);
adminService.updRole(role, m);
}
//添加角色
@RequestMapping("/insRole")
@ResponseBody
public ResultUtil insertRole(Role role, String m) {
adminService.insRole(role, m);
return ResultUtil.ok();
}
/*******管理员相关******/
//查看管理员的个人信息
@RequestMapping("/personalDate")
public String personalDate(HttpSession session) {
Admin admin = (Admin) session.getAttribute("admin");
Admin admin1 = adminService.getAdminById(admin.getId());
session.setAttribute("admin1", admin1);
return "/jsp/admin/personalInfo";
}
@RequestMapping("/getAdminList")
@ResponseBody
//获取所有管理员列表 带分页
public ResultUtil getAdminList(Integer page, Integer limit) {
// Tomcat Localhost Log 会输出错误信息 如果下面的sql语句有问题
ResultUtil admins = adminService.getAdminList(page, limit);
return admins;
}
//获取管理员对应的菜单 用于加载后台首页
@RequestMapping("/getMenus")
@ResponseBody
public List<Menu> getMenus(HttpSession session) {
List<Menu> menus = null;
Admin admin = (Admin) session.getAttribute("admin");
Admin admin1 = adminService.getAdminById(admin.getId());
if (admin1 != null) {
menus = adminService.getMenus(admin1);
}
return menus;
}
//编辑管理员
@RequestMapping("/editAdmin/{id}")
public String editAdmin(HttpServletRequest request, @PathVariable("id") int id) {
Admin admin = adminService.getAdminById(id);
List<Role> roles = adminService.getRoles();
request.setAttribute("admin", admin);
request.setAttribute("roles", roles);
return "/jsp/admin/editAdmin";
}
//更新管理员
@RequestMapping("/updateAdmin")
@ResponseBody
public ResultUtil updateAdmin(Admin admin) {
try {
adminService.updAdmin(admin);
return ResultUtil.ok();
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error();
}
}
//更新管理员
@RequestMapping("/updAdmin")
@ResponseBody
public ResultUtil updAdmin(Admin admin)
{
if (admin != null && admin.getId() == 1) {
return ResultUtil.error("不允许修改");
}
try
{
//如果sql执行失败 会有捕获异常输出
adminService.updAdmin(admin);
return ResultUtil.ok();
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error();
}
}
//修改密码
@RequestMapping("/changeAdminPassword")
@ResponseBody
public ResultUtil changeAdminPassword(String oldPassword, String newPassword1, String username) {
Admin admin = adminService.getAdminByUsername(username);
if (admin != null) {
if (admin.getPassword().equals(EncryptUtil.encrypt(oldPassword))) {
admin.setPassword(EncryptUtil.encrypt(newPassword1));
adminService.updAdmin(admin);
return ResultUtil.ok();
} else {
return ResultUtil.error("旧密码错误,请重新填写");
}
}
return ResultUtil.error("请求出错!!");
}
//删除一个管理员
@RequestMapping("/delAdminById/{id}")
@ResponseBody
public ResultUtil delAdminById(@PathVariable("id") Long id) {
if (id == 1) {
return ResultUtil.error();
}
try {
adminService.delAdminById(id);
return ResultUtil.ok();
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error();
}
}
//检查是否已经存在此用户名
@RequestMapping("/checkAdminName/{username}")
@ResponseBody
public ResultUtil checkAdminName(@PathVariable("username") String username) {
Admin admin = adminService.getAdminByUsername(username);
if (admin != null) {
return new ResultUtil(500, "管理员已存在!");
}
return new ResultUtil(0);
}
//添加新管理员
@RequestMapping("/insAdmin")
@ResponseBody
public ResultUtil insAdmin(Admin admin) {
adminService.insAdmin(admin);
return ResultUtil.ok();
}
/****菜单相关******/
//获取所有菜单
@RequestMapping("/menuData")
@ResponseBody
public ResultUtil menuData() {
List<Menu> list = adminService.getAllMenus();
ResultUtil resultUtil = new ResultUtil();
resultUtil.setCode(0);
resultUtil.setCount(list.size() + 0L);
resultUtil.setData(list);
return resultUtil;
}
@RequestMapping("/updMenuSortingById")
@ResponseBody
public ResultUtil updMenuSortingById(Long menuId, String sorting) {
Menu menu = new Menu();
menu.setMenuId(menuId);
Long sortingL;
try {
sortingL = Long.parseLong(sorting); //将字符串变成Long
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error("修改失败,只允许输入整数");
}
menu.setSorting(sortingL);
adminService.updMenuSortingById(menu);
return ResultUtil.ok();
}
@RequestMapping("/toSaveMenu/{menuId}/{menuLevel}")
public String toSaveMenu(@PathVariable("menuId") Long menuId,
@PathVariable("menuLevel") Long menuLevel, Model model) {
if (menuId != null && menuId != 1) {
Menu menus = new Menu();
menus.setMenuId(menuId);
model.addAttribute("menuLevel", menuLevel);
model.addAttribute("menu", menus);
model.addAttribute("flag", "1");
return "/jsp/menu/menuForm";
} else {
model.addAttribute("msg", "不允许操作!");
return "/jsp/active";
}
}
@RequestMapping("/toEditMenu/{menuId}")
public String toEditMenu(@PathVariable("menuId") Long menuId, Model model) {
if (menuId != null && menuId != 1) {
Menu menus = adminService.getMenuById(menuId);
model.addAttribute("menu", menus);
return "/jsp/menu/menuForm";
} else {
model.addAttribute("msg", "不允许操作");
return "/jsp/active";
}
}
@RequestMapping("/menuForm")
@ResponseBody
public ResultUtil menuForm(Menu menus, String flag) {
if (StringUtils.isBlank(flag))
{
menus.setSpread("false");
adminService.updMenu(menus);
return ResultUtil.ok("修改成功");
} else if (menus.getMenuId() != 1)
{
menus.setParentId(menus.getMenuId()); //menuId parentId设成一样 情况1: 0,0 情况2: 2,2 情况3:111,111
Menu m = adminService.getMenuById(menus.getMenuId());// 情况1 m为空 情况2 读出菜单 我的面板 情况3读出菜单 测试菜单
if (m != null && m.getParentId() != 0)//这就是 选中第三级菜单复选框或者选中第二级菜单复选框的情况
{
Menu m1 = adminService.getMenuById(m.getParentId()); //获取第二级菜单或者第三级菜单的上级菜单
if (m1 != null && m1.getParentId() != 0)//说明是情况3
{
return ResultUtil.error("此菜单不允许添加子菜单"); //固定最多三级菜单
}
}
List<Menu> data = adminService.checkNameSameLevel(menus); // sql为select * from menu parentId = #{parentId} and name = #{name}
//就是判断*菜单 二级菜单下有没有重名的菜单
if (data.size() > 0) {
return ResultUtil.error("同级菜单名称不能相同");
}
menus.setMenuId(null);
menus.setSpread("false"); //默认不展开
adminService.insMenu(menus);
return ResultUtil.ok("添加成功");
} else {
return ResultUtil.error("此菜单不允许操作");
}
}
@RequestMapping("/delMenuById/{menuId}")
@ResponseBody
public ResultUtil delMenuById(@PathVariable("menuId") Long menuId) {
try {
if (menuId == 1) {
return ResultUtil.error("此菜单不允许删除!");
}
List<Menu> data = adminService.getMenusByParentId(menuId);
if (data != null && data.size() > 0) {
return ResultUtil.error("包含子菜单,不允许删除!");
}
List<RoleMenu> roleMenus = adminService.getRoleMenuByMenuId(menuId);
if (roleMenus != null && roleMenus.size() > 1) {
return ResultUtil.error("此菜单已经分配给此登录角色,请先解除绑定,再尝试删除");
}
adminService.delMenuById(menuId);
return ResultUtil.ok("删除成功");
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error("数据库sql有误查看Log输出");
}
}
/********页面跳转*******/
@RequestMapping("/logOut")
public ModelAndView loginout(ModelAndView modelAndView, HttpSession session)
throws ParseException {
Date loginTime = (Date) session.getAttribute("adminloginTime");
AdminLog adminLog = adminService.getAdminLogByLoginTime(loginTime);
adminLog.setIsSafeExit(1);
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = simpleDateFormat.format(date);
Date logoutTime = simpleDateFormat.parse(nowTime);
adminLog.setLogoutTime(logoutTime);
adminService.updateAdminLog(adminLog);
session.invalidate();
modelAndView.setViewName("redirect:/adminindex.jsp");
return modelAndView;
}
@RequestMapping("/allmain")
public String index() {
return "redirect:/admin/toallmain";
}
@RequestMapping("/toallmain")
public String toallmain(ModelAndView modelAndView) {
return "/jsp/allmain";
}
@RequestMapping("/main")
public String getMain() {
return "/jsp/main";
}
@RequestMapping("/adminList")
public String adminList() {
return "/jsp/admin/adminList";
}
@RequestMapping("/addAdmin")
public String addAdmin(HttpSession session) {
List<Role> roles = adminService.getRoles();
session.setAttribute("roles", roles);
return "/jsp/admin/addAdmin";
}
@RequestMapping("/roleList")
public String roleList() {
return "/jsp/role/roleList";
}
@RequestMapping("/editRole")
public String editRole(Role role, Model model) {
role = adminService.getRoleById(role.getRoleId());
model.addAttribute("role", role);
return "/jsp/role/editRole";
}
@RequestMapping("/addRole")
public String addRole() {
return "/jsp/role/addRole";
}
@RequestMapping("/menuList")
public String menuList() {
return "/jsp/menu/menuList";
}
@RequestMapping("/changePassword")
public String changePassword() {
return "/jsp/admin/changePassword";
}
@RequestMapping("/adminLoginLog")
public String adminLoginLog() {
return "/jsp/admin/adminLogList";
}
@RequestMapping("/register")
public String register() {
return "/jsp/register/register";
}
}
package com.zhang.hospital.web;
import com.zhang.hospital.entity.Depart;
import com.zhang.hospital.entity.Doctor;
import com.zhang.hospital.service.DepartService;
import com.zhang.hospital.service.DoctorService;
import com.zhang.hospital.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/depart")
public class DepartController {
@Autowired
private DepartService departService;
@Autowired
private DoctorService doctorService;
@RequestMapping("/departList")
public String departList(){
return "/jsp/depart/departList";
}
@RequestMapping("/getDepartList")
@ResponseBody
public ResultUtil getDepartList(Integer page, Integer limit)
{
return departService.getDepartList(page,limit);
}
@RequestMapping("/addDepart")
public String addDepart()
{
return "/jsp/depart/addDepart";
}
// 检查角色是否唯一 添加新角色的时候用这个函数
@RequestMapping("/checkDepartName/{depart}")
@ResponseBody
public ResultUtil checkDepartName(@PathVariable("depart") String depart)
{
Depart depart1=departService.getDepartByDepartName(depart);
if(depart1==null)
{
return new ResultUtil(0);
}
else //此角色名已存在
{
return new ResultUtil(500,"已经存在此科室名称");
}
}
@RequestMapping("/insDepart")
@ResponseBody
public ResultUtil insDepart(Depart depart)
{
departService.addDepart(depart);
return ResultUtil.ok();
}
@RequestMapping("/editDepart/{depart_id}")
public String editDepart(@PathVariable("depart_id") Integer depart_id, Model model)
{
Depart depart=departService.getDepartById(depart_id);
model.addAttribute("depart",depart);
return "/jsp/depart/editDepart";
}
@RequestMapping("/updateDepart")
@ResponseBody
public void updateDepart(Depart depart)
{
departService.updateDepart(depart);
}
@RequestMapping("/delDepartById/{depart_id}")
@ResponseBody
public ResultUtil delDepartById(@PathVariable("depart_id")Integer depart_id)
{
//先检查此科室下有没有医生
List<Doctor> doctors=doctorService.getDoctorByDepartId(depart_id);
if(doctors.size()==0)//此科室下没有医生可以删除
{
departService.delDepartById(depart_id);
return ResultUtil.ok("此科室删除成功");
}
// departService.delDepartById(depart_id);
推荐阅读
-
基于 SpringBoot+Vue+uniapp 微信小程序的婚纱摄影小程序的详细设计与实现(源代码+lw+部署文档+说明等)
-
校园美食探索与分享平台的设计与实现(论文+源代码)_kaic-3.2 系统架构设计
-
基于 SpringBoot+Vue+uniapp 的在线招聘平台的详细设计与实施
-
信息技术在线教学平台设计与实施的 JAVA 项目(源代码 + 文档)
-
基于 SpringBoot+Vue+uniapp 的诗歌学习系统的详细设计与实现
-
个人健康系统|个人健康数据管理系统|基于applet+java的个人健康数据管理系统设计与实现(源代码+数据库+文档)
-
基于SpringBoot+Vue+uniapp的高校教务管理小程序系统的设计与实现
-
原创] java+swing+mysql小说管理系统的设计与实现
-
计算机毕业设计 基于 Flask + vue 的博客系统设计与实现 Python 毕业设计 Python 毕业设计题目 Flask 框架 Vue [含源代码 + 安装与调试]。
-
基于 SpringBoot + Uniapp 的家庭记账本微信小程序系统设计与实现