基于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
@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
public ResponseData freeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//不能冻结超级管理员
if (userId.equals(Const.ADMIN_ID)) {
throw new ServiceException(BizExceptionEnum.CANT_FREEZE_ADMIN);
}
assertAuth(userId);
this.userService.setStatus(userId, ManagerStatus.FREEZED.getCode());
return SUCCESS_TIP;
}
/**
* 解除冻结用户
*/
@RequestMapping("/unfreeze")
@BussinessLog(value = "解除冻结用户", key = "userId", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData unfreeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
this.userService.setStatus(userId, ManagerStatus.OK.getCode());
/**
* 部门控制器
*
*/
@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController {
private String PREFIX = "/system/dept/";
@Autowired
private IDeptService deptService;
/**
* 跳转到部门管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "dept.html";
}
/**
* 跳转到添加部门
*/
@RequestMapping("/dept_add")
dept.setPids(pids + "[" + pid + "],");
}
}
}
/**
* <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 = "/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);
//删除缓存
CacheUtil.removeAll(Cache.CONSTANT);
return SUCCESS_TIP;
}
/**
* 删除角色
*/
@RequestMapping(value = "/remove")
@BussinessLog(value = "删除角色", key = "roleId", dict = RoleDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData remove(@RequestParam Integer roleId) {
if (ToolUtil.isEmpty(roleId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//不能删除超级管理员角色
if (roleId.equals(Const.ADMIN_ROLE_ID)) {
throw new ServiceException(BizExceptionEnum.CANT_DELETE_ADMIN);
}
//缓存被删除的角色名称
LogObjectHolder.me().set(ConstantFactory.me().getSingleRoleName(roleId));
this.roleService.delRoleById(roleId);
//删除缓存
CacheUtil.removeAll(Cache.CONSTANT);
return SUCCESS_TIP;
}
/**
* 查看角色
*/
@RequestMapping(value = "/view/{roleId}")
@ResponseBody
public ResponseData view(@PathVariable Integer roleId) {
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);
/**
* 验证码生成
*
*/
@Controller
@RequestMapping("/kaptcha")
public class KaptchaController {
@Autowired
private GunsProperties gunsProperties;
@Autowired
private Producer producer;
/**
* 生成验证码
*/
@RequestMapping("")
public void index(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
response.setDateHeader("Expires", 0);
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
// return a jpeg
response.setContentType("image/jpeg");
*/
@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController {
private String PREFIX = "/system/dept/";
@Autowired
private IDeptService deptService;
/**
* 跳转到部门管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "dept.html";
}
/**
* 跳转到添加部门
*/
@RequestMapping("/dept_add")
public String deptAdd() {
return PREFIX + "dept_add.html";
}
/**
* 跳转到修改部门
*/
@Permission
@RequestMapping("/dept_update/{deptId}")
public String deptUpdate(@PathVariable Integer deptId, Model model) {
Dept dept = deptService.selectById(deptId);
model.addAttribute(dept);
model.addAttribute("pName", ConstantFactory.me().getDeptName(dept.getPid()));
LogObjectHolder.me().set(dept);
return PREFIX + "dept_edit.html";
}
/**
* 获取部门的tree列表
*/
@RequestMapping(value = "/tree")
model.addAttribute("item",patientHealth);
LogObjectHolder.me().set(patientHealth);
return PREFIX + "patientHealth_edit.html";
}
/**
* 获取居民健康信息管理列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
if (StringUtils.isEmpty(condition)){
return patientHealthService.selectList(null);
}else {
Map<String,Object> map = new HashMap<String, Object>();
map.put("patient_name",condition);
List<PatientHealth> patientHealthList = patientHealthMapper.selectByMap(map);
return patientHealthList;
}
}
/**
* 新增居民健康信息管理
*/
@RequestMapping(value = "/add")
@ResponseBody
public Object add(PatientHealth patientHealth) {
patientHealthService.insert(patientHealth);
return SUCCESS_TIP;
}
/**
* 删除居民健康信息管理
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer patientHealthId) {
patientHealthService.deleteById(patientHealthId);
return SUCCESS_TIP;
}
/**
* 修改居民健康信息管理
*/
@RequestMapping(value = "/update")
@BussinessLog(value = "修改字典", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/update")
@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("/patientHealth")
public class PatientHealthController extends BaseController {
private String PREFIX = "/pateint_health_manager/patientHealth/";
@Autowired
private IPatientHealthService patientHealthService;
@Resource
private PatientHealthMapper patientHealthMapper;
/**
* 跳转到居民健康信息管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "patientHealth.html";
}
/**
* 跳转到添加居民健康信息管理
*/
@RequestMapping("/patientHealth_add")
public String patientHealthAdd() {
return PREFIX + "patientHealth_add.html";
}
/**
* 跳转到修改居民健康信息管理
*/
@RequestMapping("/patientHealth_update/{patientHealthId}")
public String patientHealthUpdate(@PathVariable Integer patientHealthId, Model model) {
PatientHealth patientHealth = patientHealthService.selectById(patientHealthId);
model.addAttribute("item",patientHealth);
LogObjectHolder.me().set(patientHealth);
return PREFIX + "patientHealth_edit.html";
}
/**
* 获取居民健康信息管理列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
if (StringUtils.isEmpty(condition)){
return patientHealthService.selectList(null);
}else {
Map<String,Object> map = new HashMap<String, Object>();
map.put("patient_name",condition);
List<PatientHealth> patientHealthList = patientHealthMapper.selectByMap(map);
return patientHealthList;
}
@ResponseBody
public ResponseData freeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//不能冻结超级管理员
if (userId.equals(Const.ADMIN_ID)) {
throw new ServiceException(BizExceptionEnum.CANT_FREEZE_ADMIN);
}
assertAuth(userId);
this.userService.setStatus(userId, ManagerStatus.FREEZED.getCode());
return SUCCESS_TIP;
}
/**
* 解除冻结用户
*/
@RequestMapping("/unfreeze")
@BussinessLog(value = "解除冻结用户", key = "userId", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData unfreeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
this.userService.setStatus(userId, ManagerStatus.OK.getCode());
return SUCCESS_TIP;
}
/**
* 分配角色
*/
@RequestMapping("/setRole")
@BussinessLog(value = "分配角色", key = "userId,roleIds", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData setRole(@RequestParam("userId") Integer userId, @RequestParam("roleIds") String roleIds) {
if (ToolUtil.isOneEmpty(userId, roleIds)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//不能修改超级管理员
if (userId.equals(Const.ADMIN_ID)) {
throw new ServiceException(BizExceptionEnum.CANT_CHANGE_ADMIN);
}
assertAuth(userId);
this.userService.setRoles(userId, roleIds);
return SUCCESS_TIP;
}
/**
* 上传图片
*/
@RequestMapping(method = RequestMethod.POST, path = "/upload")
/**
* 通知控制器
*
*/
@Controller
@RequestMapping("/notice")
public class NoticeController extends BaseController {
private String PREFIX = "/system/notice/";
@Autowired
private INoticeService noticeService;
/**
* 跳转到通知列表首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "notice.html";
}
/**
* 跳转到添加通知
*/
@RequestMapping("/notice_add")
public String noticeAdd() {
return PREFIX + "notice_add.html";
}
/**
* 跳转到修改通知
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.
*/
Dict dict = dictService.selectById(dictId);
model.addAttribute("dict", dict);
List<Dict> subDicts = dictService.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
model.addAttribute("subDicts", subDicts);
LogObjectHolder.me().set(dict);
return PREFIX + "dict_edit.html";
}
/**
* 新增字典
*
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结"
*/
@BussinessLog(value = "添加字典记录", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object add(String dictCode, String dictTips, String dictName, String dictValues) {
if (ToolUtil.isOneEmpty(dictCode, dictName, dictValues)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
this.dictService.addDict(dictCode, dictName, dictTips, dictValues);
return SUCCESS_TIP;
}
/**
* 获取所有字典列表
*/
@RequestMapping(value = "/list")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object list(String condition) {
List<Map<String, Object>> list = this.dictService.list(condition);
return super.warpObject(new DictWarpper(list));
}
/**
* 字典详情
*/
@RequestMapping(value = "/detail/{dictId}")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object detail(@PathVariable("dictId") Integer dictId) {
return dictService.selectById(dictId);
}
/**
}
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";
}
/**
* 修该菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/edit")
@BussinessLog(value = "修改菜单", key = "name", dict = MenuDict.class)
@ResponseBody
public ResponseData edit(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//设置父级菜单编号
menuSetPcode(menu);
this.menuService.updateById(menu);
return SUCCESS_TIP;
}
/**
* 获取菜单列表
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/list")
@ResponseBody
public Object list(@RequestParam(required = false) String menuName, @RequestParam(required = false) String level) {
List<Map<String, Object>> menus = this.menuService.selectMenus(menuName, level);
return super.warpObject(new MenuWarpper(menus));
}
/**
* 新增菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/add")
@BussinessLog(value = "菜单新增", key = "name", dict = MenuDict.class)
@ResponseBody
public ResponseData add(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
this.menuService.updateById(menu);
return SUCCESS_TIP;
}
/**
* 获取菜单列表
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/list")
@ResponseBody
public Object list(@RequestParam(required = false) String menuName, @RequestParam(required = false) String level) {
List<Map<String, Object>> menus = this.menuService.selectMenus(menuName, level);
return super.warpObject(new MenuWarpper(menus));
}
/**
* 新增菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/add")
@BussinessLog(value = "菜单新增", key = "name", dict = MenuDict.class)
@ResponseBody
public ResponseData add(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
//判断是否存在该编号
String existedMenuName = ConstantFactory.me().getMenuNameByCode(menu.getCode());
if (ToolUtil.isNotEmpty(existedMenuName)) {
throw new ServiceException(BizExceptionEnum.EXISTED_THE_MENU);
}
//设置父级菜单编号
menuSetPcode(menu);
menu.setStatus(MenuStatus.ENABLE.getCode());
this.menuService.insert(menu);
return SUCCESS_TIP;
}
/**
* 删除菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/remove")
@BussinessLog(value = "删除菜单", key = "menuId", dict = MenuDict.class)
@ResponseBody
public ResponseData remove(@RequestParam Long menuId) {
if (ToolUtil.isEmpty(menuId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
* 新增字典
*
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结"
*/
@BussinessLog(value = "添加字典记录", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object add(String dictCode, String dictTips, String dictName, String dictValues) {
if (ToolUtil.isOneEmpty(dictCode, dictName, dictValues)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
this.dictService.addDict(dictCode, dictName, dictTips, dictValues);
return SUCCESS_TIP;
}
/**
* 获取所有字典列表
*/
@RequestMapping(value = "/list")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object list(String condition) {
List<Map<String, Object>> list = this.dictService.list(condition);
return super.warpObject(new DictWarpper(list));
}
/**
* 字典详情
*/
@RequestMapping(value = "/detail/{dictId}")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object detail(@PathVariable("dictId") Integer dictId) {
return dictService.selectById(dictId);
}
/**
* 修改字典
*/
@BussinessLog(value = "修改字典", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/update")
@Permission(Const.ADMIN_NAME)
@ResponseBody
/**
* 跳转到字典管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "dict.html";
}
/**
* 跳转到添加字典
*/
@RequestMapping("/dict_add")
public String deptAdd() {
return PREFIX + "dict_add.html";
}
/**
* 跳转到修改字典
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping("/dict_edit/{dictId}")
public String deptUpdate(@PathVariable Integer dictId, Model model) {
Dict dict = dictService.selectById(dictId);
model.addAttribute("dict", dict);
List<Dict> subDicts = dictService.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
model.addAttribute("subDicts", subDicts);
LogObjectHolder.me().set(dict);
return PREFIX + "dict_edit.html";
}
/**
* 新增字典
*
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结"
*/
@BussinessLog(value = "添加字典记录", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object add(String dictCode, String dictTips, String dictName, String dictValues) {