基于 SpringBoot + Vue 的前后端分离医院管理系统

医院管理系统

简介

基于 SpringBoot + Vue 的前后端分离医院管理系统,使用 SpringSecurity 结合 jwt 作为权限管理,使用 guava-cache 存储生成的 token,使用SpringDataJpa 方便数据库操作,使用 mysql 作为数据库,使用 druid 作为数据库连接池,使用 easy-captcha 作为验证码生成工具;前端使用 axios 进行后端的请求,使用 element-ui 作为组件库,使用 vuex 存储状态信息,使用 vue-router 进行路由跳转。

功能
  • 系统管理
  • 用户管理
  • 划价收费
  • 药库管理
  • 药房管理
  • 门诊管理
  • 挂号管理
  • 体检管理
代码

使用 guava-cache 存储生成的 token

package com.hospital.system.components;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

/**
 *  缓存管理token
 */
public class TokenCache {

    private static final String TOKEN_KEY = "token_";
    private static Cache<String, String> cache = CacheBuilder.newBuilder().build();

    /**
     * 保存
     * @param token
     */
    public static void setToken(String username, String token) {

        cache.put(TOKEN_KEY+username,token);
    }

    public static void deleteToken(){
        cache.invalidateAll();
    }

    /**
     * 取
     * @return
     */
    public static String getTokenFromCache(String username){
        return cache.getIfPresent(TOKEN_KEY+username);
    }

    /**
     * 保存
     * @param val
     */
    public static void setRem(String key, String val) {

        cache.put(key,val);
    }

    /**
     * 取
     * @return
     */
    public static String getRem(String key){
        return cache.getIfPresent(key);
    }

}

查询数据库进行鉴权

package com.hospital.system.components;

import com.hospital.system.exception.MyaccessDeniedException;
import com.hospital.system.entity.SysBackendApiTable;
import com.hospital.system.service.SysBackendApiTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;

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

@Component
public class DynamicPermission {

    @Autowired
    SysBackendApiTableService service;


    /**
     * 判断有访问API的权限
     * @param request
     * @param authentication
     * @return
     * @throws MyaccessDeniedException
     */
    public boolean checkPermisstion(HttpServletRequest request,
                                    Authentication authentication) throws MyaccessDeniedException  {

        Object principal = authentication.getPrincipal();
        System.out.println("DynamicPermission principal = " + principal);

        if(principal instanceof UserDetails) {

            UserDetails userDetails = (UserDetails) principal;
            //得到当前的账号
            String username = userDetails.getUsername();
            //Collection<? extends GrantedAuthority> roles = userDetails.getAuthorities();

            // System.out.println("DynamicPermission  username = " + username);
            //通过账号获取资源鉴权
            List<SysBackendApiTable> apiUrls = service.getApiUrlByUserName(username);

            AntPathMatcher antPathMatcher = new AntPathMatcher();
            //当前访问路径
            String requestURI = request.getRequestURI();
            //提交类型
            String urlMethod = request.getMethod();

            // System.out.println("DynamicPermission requestURI = " + requestURI);

            //判断当前路径中是否在资源鉴权中
            boolean rs = apiUrls.stream().anyMatch(item->{
                //判断URL是否匹配
                boolean hashAntPath = antPathMatcher.match(item.getBackendApiUrl(),requestURI);

                //判断请求方式是否和数据库中匹配(数据库存储:GET,POST,PUT,DELETE)
                String dbMethod = item.getBackendApiMethod();

                //处理null,万一数据库存值
                dbMethod = (dbMethod == null )? "": dbMethod;
                int hasMethod   = dbMethod.indexOf(urlMethod);

                System.out.println("hashAntPath = " + hashAntPath);
                System.out.println("hasMethod = " + hasMethod);
                System.out.println("hashAntPath && hasMethod = " + (hashAntPath && hasMethod !=-1));
                //两者都成立,返回真,否则返回假
                return hashAntPath && (hasMethod !=-1);
            });
            //返回
            if (rs) {
                return rs;
            }else {
                throw  new MyaccessDeniedException("您没有访问该API的权限!");
            }

        }else{
            throw  new MyaccessDeniedException("不是UserDetails类型!");
        }
    }
}
示例

登录

在这里插入图片描述

注册

在这里插入图片描述

首页

在这里插入图片描述

菜单管理

在这里插入图片描述

API 管理

在这里插入图片描述

角色分配

在这里插入图片描述

菜单分配

在这里插入图片描述

api 分配

在这里插入图片描述

角色管理

在这里插入图片描述

用户信息管理

在这里插入图片描述

门诊收费

在这里插入图片描述

体检收费

在这里插入图片描述

出入库管理

在这里插入图片描述

药品管理

在这里插入图片描述

药房取药

在这里插入图片描述

普通门诊

在这里插入图片描述

挂号记录

在这里插入图片描述

挂号记录

在这里插入图片描述

进行挂号

在这里插入图片描述

普通体检

在这里插入图片描述

  • 1
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值