基于javaweb+mysql的springboot社区养老医疗综合服务(java+springboot+html+bootstrap+ztree+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot社区养老医疗综合服务(java+springboot+html+bootstrap+ztree+mysql)
项目介绍
本项目分为管理员、医生、病人三种角色, 管理员的功能包含如下: 个人信息:个人资料、修改密码 系统管理:用户管理、角色管理、部门管理、菜单管理、字典管理 药物信息管理 居民健康信息 居民就诊历史 我的预约信息 居民医保信息
医生的功能包含如下: 个人信息:个人资料、修改密码 药物信息管理 居民健康信息 居民就诊历史 我的预约信息 居民医保信息
病人的功能包含如下: 个人信息:个人资料、修改密码 居民医保信息 居民健康信息 居民就诊历史 我的预约信息
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7或8.0版本;
技术栈
- 后端:SpringBoot+mybatis-plus 2. 前端:HTML+CSS+javascript+jQuery+bootstrap+ztree
使用说明
运行项目,在浏览器中输入http://localhost:8080/ 登录
管理员账号/密码:admin/123456
医生账号/密码:doctor/123456
病人账号/密码:patient/123456
}
/**
* <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.
*/
/**
* 接口控制器提供
*
*/
@RestController
@RequestMapping("/gunsApi")
public class ApiController extends BaseController {
@Autowired
private UserMapper userMapper;
/**
* api登录接口,通过账号密码获取token
*/
@RequestMapping("/auth")
public Object auth(@RequestParam("username") String username,
@RequestParam("password") String password) {
//封装请求账号密码为shiro可验证的token
UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password.toCharArray());
//获取数据库中的账号密码,准备比对
User user = userMapper.getByAccount(username);
String credentials = user.getPassword();
String salt = user.getSalt();
ByteSource credentialsSalt = new Md5Hash(salt);
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
// 判断账号是否重复
User theUser = userService.getByAccount(user.getAccount());
if (theUser != null) {
throw new ServiceException(BizExceptionEnum.USER_ALREADY_REG);
}
// 完善账号信息
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(user.getPassword(), user.getSalt()));
user.setStatus(ManagerStatus.OK.getCode());
user.setCreatetime(new Date());
this.userService.insert(UserFactory.createUser(user));
return SUCCESS_TIP;
}
/**
* 修改管理员
*
* @throws NoPermissionException
*/
@RequestMapping("/edit")
@BussinessLog(value = "修改管理员", key = "account", dict = UserDict.class)
@ResponseBody
public ResponseData edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
User oldUser = userService.selectById(user.getId());
if (ShiroKit.hasRole(Const.ADMIN_NAME)) {
this.userService.updateById(UserFactory.editUser(user, oldUser));
return SUCCESS_TIP;
} else {
assertAuth(user.getId());
ShiroUser shiroUser = ShiroKit.getUser();
if (shiroUser.getId().equals(user.getId())) {
this.userService.updateById(UserFactory.editUser(user, oldUser));
return SUCCESS_TIP;
} else {
throw new ServiceException(BizExceptionEnum.NO_PERMITION);
}
}
}
/**
* 删除管理员(逻辑删除)
*/
@RequestMapping("/delete")
@Permission
@ResponseBody
public ResponseData delete(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//不能删除超级管理员
if (userId.equals(Const.ADMIN_ID)) {
throw new ServiceException(BizExceptionEnum.CANT_DELETE_ADMIN);
}
assertAuth(userId);
this.userService.setStatus(userId, ManagerStatus.DELETED.getCode());
return SUCCESS_TIP;
}
/**
* 查看管理员详情
*/
@RequestMapping("/view/{userId}")
@ResponseBody
public User view(@PathVariable Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
return this.userService.selectById(userId);
}
/**
* 重置管理员的密码
*/
@RequestMapping("/reset")
@BussinessLog(value = "重置管理员密码", key = "userId", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData reset(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
User user = this.userService.selectById(userId);
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(Const.DEFAULT_PWD, user.getSalt()));
this.userService.updateById(user);
return SUCCESS_TIP;
}
/**
* 冻结用户
*/
@RequestMapping("/freeze")
@BussinessLog(value = "冻结用户", key = "userId", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
/**
* 登录控制器
*
*/
@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();
model.addAttribute("tips", "该用户没有角色,无法登陆");
return "/login.html";
}
List<MenuNode> menus = menuService.getMenusByRoleIds(roleList);
List<MenuNode> titles = MenuNode.buildTitle(menus);
titles = ApiMenuFilter.build(titles);
model.addAttribute("titles", titles);
//获取用户头像
Integer id = ShiroKit.getUser().getId();
/**
* 角色控制器
*
*/
@Controller
@RequestMapping("/role")
public class RoleController extends BaseController {
private static String PREFIX = "/system/role";
@Autowired
private IUserService userService;
@Autowired
private IRoleService roleService;
/**
* 跳转到角色列表页面
*/
@RequestMapping("")
public String index() {
return PREFIX + "/role.html";
}
/**
* 跳转到添加角色
*/
@RequestMapping(value = "/role_add")
public String roleAdd() {
return PREFIX + "/role_add.html";
}
/**
* 跳转到修改角色
*/
@Permission
@RequestMapping(value = "/role_edit/{roleId}")
public String roleEdit(@PathVariable Integer roleId, Model model) {
if (ToolUtil.isEmpty(roleId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object update(Integer dictId, String dictCode, String dictName, String dictTips, String dictValues) {
if (ToolUtil.isOneEmpty(dictId, dictCode, dictName, dictValues)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
dictService.editDict(dictId, dictCode, dictName, dictTips, dictValues);
return SUCCESS_TIP;
}
/**
* 删除字典记录
*/
@BussinessLog(value = "删除字典记录", key = "dictId", dict = DictMap.class)
@RequestMapping(value = "/delete")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object delete(@RequestParam Integer dictId) {
//缓存被删除的名称
LogObjectHolder.me().set(ConstantFactory.me().getDictName(dictId));
this.dictService.delteDict(dictId);
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.
*/
/**
* 跳转到首页通知
*/
@RequestMapping("/hello")
public String hello() {
List<Map<String, Object>> notices = noticeService.list(null);
super.setAttr("noticeList", notices);
return "/blackboard.html";
}
/**
* 获取通知列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
List<Map<String, Object>> list = this.noticeService.list(condition);
return super.warpObject(new NoticeWrapper(list));
}
/**
* 新增通知
*/
@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;
if (StringUtils.isEmpty(condition)){
return medicineInfoService.selectList(null);
}else {
Map<String,Object> map = new HashMap<String, Object>();
map.put("medicine_name",condition);
List<MedicineInfo> medicineInfoList = medicineInfoMapper.selectByMap(map);
return medicineInfoList;
}
}
/**
* 新增药物管理
*/
@RequestMapping(value = "/add")
@ResponseBody
public Object add(MedicineInfo medicineInfo) {
medicineInfoService.insert(medicineInfo);
return SUCCESS_TIP;
}
/**
* 删除药物管理
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer medicineInfoId) {
medicineInfoService.deleteById(medicineInfoId);
return SUCCESS_TIP;
}
/**
* 修改药物管理
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(MedicineInfo medicineInfo) {
medicineInfoService.updateById(medicineInfo);
return SUCCESS_TIP;
}
/**
* 药物管理详情
*/
@RequestMapping(value = "/detail/{medicineInfoId}")
@ResponseBody
public Object detail(@PathVariable("medicineInfoId") Integer medicineInfoId) {
return medicineInfoService.selectById(medicineInfoId);
}
}
/**
* 登录控制器
*
*/
@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();
model.addAttribute("tips", "该用户没有角色,无法登陆");
return "/login.html";
}
List<MenuNode> menus = menuService.getMenusByRoleIds(roleList);
List<MenuNode> titles = MenuNode.buildTitle(menus);
titles = ApiMenuFilter.build(titles);
model.addAttribute("titles", titles);
//获取用户头像
Integer id = ShiroKit.getUser().getId();
User user = userService.selectById(id);
String avatar = user.getAvatar();
model.addAttribute("avatar", avatar);
return "/index.html";
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;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
/**
* Filter that allows access to resources if the accessor is a known user, which is defined as
* having a known principal. This means that any user who is authenticated or remembered via a
* 'remember me' feature will be allowed access from this filter.
LogObjectHolder.me().set(ConstantFactory.me().getMenuName(menuId));
this.menuService.delMenuContainSubMenus(menuId);
return SUCCESS_TIP;
}
/**
* 查看菜单
*/
@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 = "/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);
}
}
/**
* 居民健康信息管理控制器
*
*/
*/
@Controller
@RequestMapping("/doctorPoint")
public class DoctorPointController extends BaseController {
private String PREFIX = "/doctor_point/doctorPoint/";
@Resource
private DoctorPointMapper doctorPointMapper;
@Autowired
private IDoctorPointService doctorPointService;
/**
* 跳转到医生预约首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "doctorPoint.html";
}
/**
* 跳转到添加医生预约
*/
@RequestMapping("/doctorPoint_add")
public String doctorPointAdd() {
return PREFIX + "doctorPoint_add.html";
}
/**
* 跳转到修改医生预约
*/
@RequestMapping("/doctorPoint_update/{doctorPointId}")
public String doctorPointUpdate(@PathVariable Integer doctorPointId, Model model) {
DoctorPoint doctorPoint = doctorPointService.selectById(doctorPointId);
model.addAttribute("item",doctorPoint);
LogObjectHolder.me().set(doctorPoint);
return PREFIX + "doctorPoint_edit.html";
}
/**
* 获取医生预约列表
*/
@RequestMapping(value = "/list")
private static String PREFIX = "/system/role";
@Autowired
private IUserService userService;
@Autowired
private IRoleService roleService;
/**
* 跳转到角色列表页面
*/
@RequestMapping("")
public String index() {
return PREFIX + "/role.html";
}
/**
* 跳转到添加角色
*/
@RequestMapping(value = "/role_add")
public String roleAdd() {
return PREFIX + "/role_add.html";
}
/**
* 跳转到修改角色
*/
@Permission
@RequestMapping(value = "/role_edit/{roleId}")
public String roleEdit(@PathVariable Integer roleId, Model model) {
if (ToolUtil.isEmpty(roleId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
Role role = this.roleService.selectById(roleId);
model.addAttribute(role);
model.addAttribute("pName", ConstantFactory.me().getSingleRoleName(role.getPid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(role.getDeptid()));
LogObjectHolder.me().set(role);
return PREFIX + "/role_edit.html";
}
LogManager.me().executeLog(LogTaskFactory.loginLog(username, "账号密码错误", getIp()));
model.addAttribute("tips", "账号密码错误");
return "/login.html";
}
/**
* 验证码错误异常
*/
@ExceptionHandler(InvalidKaptchaException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public String credentials(InvalidKaptchaException e, Model model) {
String username = getRequest().getParameter("username");
LogManager.me().executeLog(LogTaskFactory.loginLog(username, "验证码错误", getIp()));
model.addAttribute("tips", "验证码错误");
return "/login.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
super.getSession().setAttribute("username", shiroUser.getAccount());
LogManager.me().executeLog(LogTaskFactory.loginLog(shiroUser.getId(), getIp()));
ShiroKit.getSession().setAttribute("sessionFlag", true);
return REDIRECT + "/";
}
/**
* 退出登录
*/
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logOut() {
LogManager.me().executeLog(LogTaskFactory.exitLog(ShiroKit.getUser().getId(), getIp()));
ShiroKit.getSubject().logout();
deleteAllCookie();
return REDIRECT + "/login";
}
}
/**
* <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.
*/