基于javaweb+mysql的springboot社区养老医疗综合服务(java+springboot+html+bootstrap+ztree+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot社区养老医疗综合服务(java+springboot+html+bootstrap+ztree+mysql)
项目介绍
本项目分为管理员、医生、病人三种角色, 管理员的功能包含如下: 个人信息:个人资料、修改密码 系统管理:用户管理、角色管理、部门管理、菜单管理、字典管理 药物信息管理 居民健康信息 居民就诊历史 我的预约信息 居民医保信息
医生的功能包含如下: 个人信息:个人资料、修改密码 药物信息管理 居民健康信息 居民就诊历史 我的预约信息 居民医保信息
病人的功能包含如下: 个人信息:个人资料、修改密码 居民医保信息 居民健康信息 居民就诊历史 我的预约信息
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7或8.0版本; 6.是否Maven项目:是;
技术栈
- 后端:SpringBoot+mybatis-plus 2. 前端:HTML+CSS+javascript+jQuery+bootstrap+ztree
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录 管理员账号/密码:admin/111111 医生账号/密码:doctor/111111 病人账号/密码:doctor/111111
/**
* 通知控制器
*
*/
@Controller
@RequestMapping("/notice")
public class NoticeController extends BaseController {
private String PREFIX = "/system/notice/";
@Autowired
private INoticeService noticeService;
/**
* 跳转到通知列表首页
}
User user = this.userService.selectOne(new EntityWrapper<User>().eq("id", userId));
model.addAttribute("userId", userId);
model.addAttribute("userAccount", user.getAccount());
return PREFIX + "user_roleassign.html";
}
/**
* 跳转到编辑管理员页面
*/
@Permission
@RequestMapping("/user_edit/{userId}")
public String userEdit(@PathVariable Integer userId, Model model) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
User user = this.userService.selectById(userId);
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_edit.html";
}
/**
* 跳转到查看用户详情页面
*/
@RequestMapping("/user_info")
public String userInfo(Model model) {
Integer userId = ShiroKit.getUser().getId();
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
User user = this.userService.selectById(userId);
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_view.html";
}
/**
* 跳转到修改密码界面
*/
@RequestMapping("/user_chpwd")
public String chPwd() {
return PREFIX + "user_chpwd.html";
}
/**
* 修改当前用户的密码
*/
@RequestMapping("/changePwd")
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_view.html";
}
/**
* 跳转到修改密码界面
*/
@RequestMapping("/user_chpwd")
public String chPwd() {
return PREFIX + "user_chpwd.html";
}
/**
* 修改当前用户的密码
*/
@RequestMapping("/changePwd")
@ResponseBody
public Object changePwd(@RequestParam String oldPwd, @RequestParam String newPwd, @RequestParam String rePwd) {
if (!newPwd.equals(rePwd)) {
throw new ServiceException(BizExceptionEnum.TWO_PWD_NOT_MATCH);
}
Integer userId = ShiroKit.getUser().getId();
User user = userService.selectById(userId);
String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt());
if (user.getPassword().equals(oldMd5)) {
String newMd5 = ShiroKit.md5(newPwd, user.getSalt());
user.setPassword(newMd5);
user.updateById();
return SUCCESS_TIP;
} else {
throw new ServiceException(BizExceptionEnum.OLD_PWD_NOT_RIGHT);
}
}
/**
* 查询管理员列表
*/
@RequestMapping("/list")
@Permission
@ResponseBody
public Object list(@RequestParam(required = false) String name, @RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) Integer deptid) {
if (ShiroKit.isAdmin()) {
List<Map<String, Object>> users = userService.selectUsers(null, name, beginTime, endTime, deptid);
return new UserWarpper(users).wrap();
} else {
DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope());
List<Map<String, Object>> users = userService.selectUsers(dataScope, name, beginTime, endTime, deptid);
/**
* 日志管理的控制器
*
*/
@Controller
@RequestMapping("/log")
public class LogController extends BaseController {
private static String PREFIX = "/system/log/";
@Autowired
private IOperationLogService operationLogService;
/**
* 跳转到日志管理的首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "log.html";
}
/**
* 查询操作日志列表
*/
@RequestMapping("/list")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName, @RequestParam(required = false) Integer logType) {
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
List<Map<String, Object>> result = operationLogService.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType), page.getOrderByField(), page.isAsc());
page.setRecords(new LogWarpper(result).wrap());
return new PageInfoBT<>(page);
}
/**
* 查询操作日志详情
*/
@RequestMapping("/detail/{id}")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object detail(@PathVariable Integer id) {
OperationLog operationLog = operationLogService.selectById(id);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operationLog);
return super.warpObject(new LogWarpper(stringObjectMap));
}
/**
* 全局的的异常拦截器(拦截所有的控制器)(带有@RequestMapping注解的方法上都会拦截)
*
*/
@ControllerAdvice
@Order(-1)
public class GlobalExceptionHandler {
private Logger log = LoggerFactory.getLogger(this.getClass());
/**
* 拦截业务异常
*/
@ExceptionHandler(ServiceException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public ErrorResponseData bussiness(ServiceException e) {
LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e));
getRequest().setAttribute("tip", e.getMessage());
log.error("业务异常:", e);
return new ErrorResponseData(e.getCode(), e.getMessage());
}
/**
* 用户未登录异常
}
/**
* 新增部门
*/
@BussinessLog(value = "添加部门", key = "simplename", dict = DeptDict.class)
@RequestMapping(value = "/add")
@Permission
@ResponseBody
public Object add(Dept dept) {
if (ToolUtil.isOneEmpty(dept, dept.getSimplename())) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//完善pids,根据pid拿到pid的pids
deptSetPids(dept);
return this.deptService.insert(dept);
}
/**
* 获取所有部门列表
*/
@RequestMapping(value = "/list")
@Permission
@ResponseBody
public Object list(String condition) {
List<Map<String, Object>> list = this.deptService.list(condition);
return super.warpObject(new DeptWarpper(list));
}
/**
* 部门详情
*/
@RequestMapping(value = "/detail/{deptId}")
@Permission
@ResponseBody
public Object detail(@PathVariable("deptId") Integer deptId) {
return deptService.selectById(deptId);
}
/**
* 修改部门
@RequestMapping("")
public String index() {
return PREFIX + "menu.html";
}
/**
* 跳转到菜单列表列表页面
*/
@RequestMapping(value = "/menu_add")
public String menuAdd() {
return PREFIX + "menu_add.html";
}
/**
* 跳转到菜单详情列表页面
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/menu_edit/{menuId}")
public String menuEdit(@PathVariable Long menuId, Model model) {
if (ToolUtil.isEmpty(menuId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
Menu menu = this.menuService.selectById(menuId);
//获取父级菜单的id
Menu temp = new Menu();
temp.setCode(menu.getPcode());
Menu pMenu = this.menuService.selectOne(new EntityWrapper<>(temp));
//如果父级是顶级菜单
if (pMenu == null) {
menu.setPcode("0");
} else {
//设置父级菜单的code为父级菜单的id
menu.setPcode(String.valueOf(pMenu.getId()));
}
Map<String, Object> menuMap = BeanUtil.beanToMap(menu);
menuMap.put("pcodeName", ConstantFactory.me().getMenuNameByCode(temp.getCode()));
model.addAttribute("menu", menuMap);
LogObjectHolder.me().set(menu);
return PREFIX + "menu_edit.html";
}
}
/**
* 无权访问该资源异常
*/
@ExceptionHandler(UndeclaredThrowableException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public ErrorResponseData credentials(UndeclaredThrowableException e) {
getRequest().setAttribute("tip", "权限异常");
log.error("权限异常!", e);
return new ErrorResponseData(BizExceptionEnum.NO_PERMITION.getCode(), BizExceptionEnum.NO_PERMITION.getMessage());
}
/**
* 拦截未知的运行时异常
*/
@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public ErrorResponseData notFount(RuntimeException e) {
LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e));
getRequest().setAttribute("tip", "服务器未知运行时异常");
log.error("运行时异常:", e);
return new ErrorResponseData(BizExceptionEnum.SERVER_ERROR.getCode(), BizExceptionEnum.SERVER_ERROR.getMessage());
}
}
/**
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
}
/**
* 新增通知
*/
@RequestMapping(value = "/add")
@ResponseBody
@BussinessLog(value = "新增通知", key = "title", dict = NoticeMap.class)
public Object add(Notice notice) {
if (ToolUtil.isOneEmpty(notice, notice.getTitle(), notice.getContent())) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
notice.setCreater(ShiroKit.getUser().getId());
notice.setCreatetime(new Date());
notice.insert();
return SUCCESS_TIP;
}
/**
* 删除通知
*/
@RequestMapping(value = "/delete")
@ResponseBody
@BussinessLog(value = "删除通知", key = "noticeId", dict = NoticeMap.class)
public Object delete(@RequestParam Integer noticeId) {
//缓存通知名称
LogObjectHolder.me().set(ConstantFactory.me().getNoticeTitle(noticeId));
this.noticeService.deleteById(noticeId);
return SUCCESS_TIP;
}
/**
* 修改通知
*/
@RequestMapping(value = "/update")
@ResponseBody
@BussinessLog(value = "修改通知", key = "title", dict = NoticeMap.class)
public Object update(Notice notice) {
if (ToolUtil.isOneEmpty(notice, notice.getId(), notice.getTitle(), notice.getContent())) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
Notice old = this.noticeService.selectById(notice.getId());
old.setTitle(notice.getTitle());
old.setContent(notice.getContent());
old.updateById();
return SUCCESS_TIP;
}
/**
* 获取角色列表
*/
@RequestMapping(value = "/roleTreeList")
@ResponseBody
public List<ZTreeNode> roleTreeList() {
List<ZTreeNode> roleTreeList = this.roleService.roleTreeList();
roleTreeList.add(ZTreeNode.createParent());
return roleTreeList;
}
/**
* 获取角色列表
*/
@RequestMapping(value = "/roleTreeListByUserId/{userId}")
@ResponseBody
public List<ZTreeNode> roleTreeListByUserId(@PathVariable Integer userId) {
User theUser = this.userService.selectById(userId);
String roleid = theUser.getRoleid();
if (ToolUtil.isEmpty(roleid)) {
return this.roleService.roleTreeList();
} else {
String[] strArray = roleid.split(",");
return this.roleService.roleTreeListByRoleId(strArray);
}
}
}
/**
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@RequestMapping(value = "/view/{menuId}")
@ResponseBody
public ResponseData view(@PathVariable Long menuId) {
if (ToolUtil.isEmpty(menuId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
this.menuService.selectById(menuId);
return SUCCESS_TIP;
}
/**
* 获取菜单列表(首页用)
*/
@RequestMapping(value = "/menuTreeList")
@ResponseBody
public List<ZTreeNode> menuTreeList() {
return this.menuService.menuTreeList();
}
/**
* 获取菜单列表(选择父级菜单用)
*/
@RequestMapping(value = "/selectMenuTreeList")
@ResponseBody
public List<ZTreeNode> selectMenuTreeList() {
List<ZTreeNode> roleTreeList = this.menuService.menuTreeList();
roleTreeList.add(ZTreeNode.createParent());
return roleTreeList;
}
/**
* 获取角色列表
*/
@RequestMapping(value = "/menuTreeListByRoleId/{roleId}")
@ResponseBody
public List<ZTreeNode> menuTreeListByRoleId(@PathVariable Integer roleId) {
List<Long> menuIds = this.menuService.getMenuIdsByRoleId(roleId);
if (ToolUtil.isEmpty(menuIds)) {
return this.menuService.menuTreeList();
} else {
return this.menuService.menuTreeListByMenuIds(menuIds);
}
}
/**
* 根据请求的父级菜单编号设置pcode和层级
*/
private void menuSetPcode(@Valid Menu menu) {
if (ToolUtil.isEmpty(menu.getPcode()) || menu.getPcode().equals("0")) {
menu.setPcode("0");
/**
* 登录控制器
*
*/
@Controller
public class LoginController extends BaseController {
@Autowired
private IMenuService menuService;
@Autowired
private IUserService userService;
/**
* 跳转到主页
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
//获取菜单列表
List<Integer> roleList = ShiroKit.getUser().getRoleList();
if (roleList == null || roleList.size() == 0) {
ShiroKit.getSubject().logout();
patientHistoryService.insert(patientHistory);
return SUCCESS_TIP;
}
/**
* 删除居民就诊历史管理
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer patientHistoryId) {
patientHistoryService.deleteById(patientHistoryId);
return SUCCESS_TIP;
}
/**
* 修改居民就诊历史管理
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(PatientHistory patientHistory) {
patientHistoryService.updateById(patientHistory);
return SUCCESS_TIP;
}
/**
* 居民就诊历史管理详情
*/
@RequestMapping(value = "/detail/{patientHistoryId}")
@ResponseBody
public Object detail(@PathVariable("patientHistoryId") Integer patientHistoryId) {
return patientHistoryService.selectById(patientHistoryId);
}
}
model.addAttribute("roleName", ConstantFactory.me().getSingleRoleName(roleId));
return PREFIX + "/role_assign.html";
}
/**
* 获取角色列表
*/
@Permission
@RequestMapping(value = "/list")
@ResponseBody
public Object list(@RequestParam(required = false) String roleName) {
List<Map<String, Object>> roles = this.roleService.selectRoles(super.getPara("roleName"));
return super.warpObject(new RoleWarpper(roles));
}
/**
* 角色新增
*/
@RequestMapping(value = "/add")
@BussinessLog(value = "添加角色", key = "name", dict = RoleDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData add(@Valid Role role, BindingResult result) {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
role.setId(null);
this.roleService.insert(role);
return SUCCESS_TIP;
}
/**
* 角色修改
*/
@RequestMapping(value = "/edit")
@BussinessLog(value = "修改角色", key = "name", dict = RoleDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData edit(@Valid Role role, BindingResult result) {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
this.roleService.updateById(role);
* 如果是ajax请求则不进行跳转
*/
if (httpServletRequest.getHeader("x-requested-with") != null
&& httpServletRequest.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {
httpServletResponse.setHeader("sessionstatus", "timeout");
return false;
} else {
/**
* 第一次点击页面
*/
String referer = httpServletRequest.getHeader("Referer");
if (referer == null) {
saveRequestAndRedirectToLogin(request, response);
return false;
} else {
/**
* 从别的页面跳转过来的
*/
if (ShiroKit.getSession().getAttribute("sessionFlag") == null) {
httpServletRequest.setAttribute("tips", "session超时");
httpServletRequest.getRequestDispatcher("/login").forward(request, response);
return false;
} else {
saveRequestAndRedirectToLogin(request, response);
return false;
}
}
}
}
}
/**
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 查询操作日志详情
*/
@RequestMapping("/detail/{id}")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object detail(@PathVariable Integer id) {
OperationLog operationLog = operationLogService.selectById(id);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operationLog);
return super.warpObject(new LogWarpper(stringObjectMap));
}
/**
* 清空日志
*/
@BussinessLog(value = "清空业务日志")
@RequestMapping("/delLog")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object delLog() {
SqlRunner.db().delete("delete from sys_operation_log");
return SUCCESS_TIP;
}
}
/**
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public Object list(String condition) {
if (StringUtils.isEmpty(condition)){
return doctorPointService.selectList(null);
}else {
Map<String,Object> map = new HashMap<String, Object>();
map.put("patient_name",condition);
List<DoctorPoint> doctorPointList = doctorPointMapper.selectByMap(map);
return doctorPointList;
}
}
/**
* 新增医生预约
*/
@RequestMapping(value = "/add")
@ResponseBody
public Object add(DoctorPoint doctorPoint) {
doctorPointService.insert(doctorPoint);
return SUCCESS_TIP;
}
/**
* 删除医生预约
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer doctorPointId) {
doctorPointService.deleteById(doctorPointId);
return SUCCESS_TIP;
}
/**
* 修改医生预约
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(DoctorPoint doctorPoint) {
doctorPointService.updateById(doctorPoint);
return SUCCESS_TIP;
}
/**
* 医生预约详情
*/
@RequestMapping(value = "/detail/{doctorPointId}")
@ResponseBody
public Object detail(@PathVariable("doctorPointId") Integer doctorPointId) {
return doctorPointService.selectById(doctorPointId);
}
public Object add(PatientHistory patientHistory) {
patientHistoryService.insert(patientHistory);
return SUCCESS_TIP;
}
/**
* 删除居民就诊历史管理
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer patientHistoryId) {
patientHistoryService.deleteById(patientHistoryId);
return SUCCESS_TIP;
}
/**
* 修改居民就诊历史管理
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(PatientHistory patientHistory) {
patientHistoryService.updateById(patientHistory);
return SUCCESS_TIP;
}
/**
* 居民就诊历史管理详情
*/
@RequestMapping(value = "/detail/{patientHistoryId}")
@ResponseBody
public Object detail(@PathVariable("patientHistoryId") Integer patientHistoryId) {
return patientHistoryService.selectById(patientHistoryId);
}
}