日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

基于 SpringBoot + Vue 的学生公寓管理系统

發布時間:2023/12/20 vue 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 基于 SpringBoot + Vue 的学生公寓管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

學生公寓管理系統

簡介

基于 SpringBoot + Vue 的學生公寓管理系統,自定義了權限攔截器進行權限認證與授權,使用 aop+log4j 進行日志記錄,使用 reids 作為緩存,使用 mysql 作為數據庫,使用 druid 作為數據庫連接池,使用 jwt 作為前后端狀態交互信息,使用 websocket 進行通知的實時推送。

功能

  • 登錄注銷,修改密碼個人信息

  • 宿舍管理

  • 學生管理

  • 班級管理

  • 宿舍樓管理

  • 維修記錄

  • 用戶管理

  • 菜單管理

  • 角色管理

  • 日志

  • 通知管理

  • 退宿審核

代碼

自定義權限攔截

@Component public class SecurityInterceptor implements HandlerInterceptor {private final RedisUtil redisUtil;private final SystemFunctionService systemFunctionService;private final SystemRoleService systemRoleService;private static final Map<Match, Validate> VALIDATE_MAP = new HashMap<>();static {VALIDATE_MAP.put(Match.HAS_ANY, (userPermission, methodPermission) -> {for (String up : userPermission) {for (String mp : methodPermission) {if (up.equalsIgnoreCase(mp)) {return true;}}}return false;});VALIDATE_MAP.put(Match.HAS_ALL, (userPermission, methodPermission) -> {int vote = 0;for (String up : userPermission) {for (String mp : methodPermission) {if (up.equalsIgnoreCase(mp)) {vote++;}}}return vote == methodPermission.length;});}public SecurityInterceptor(RedisUtil redisUtil, SystemFunctionService systemFunctionService, SystemRoleService systemRoleService) {this.redisUtil = redisUtil;this.systemFunctionService = systemFunctionService;this.systemRoleService = systemRoleService;}@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {//獲取請求的方法HandlerMethod handlerMethod;if (handler instanceof HandlerMethod) {handlerMethod = (HandlerMethod) handler;} else {//404return true;}Method method = handlerMethod.getMethod();//獲取請求方法所需的權限String[] requiredPermissions;Match match;if (method.isAnnotationPresent(RequirePermission.class)) {RequirePermission hasPermission = method.getAnnotation(RequirePermission.class);requiredPermissions = hasPermission.permissions();match = hasPermission.matchType();} else {//方法不需要權限(無 RequirePermission 注解)return true;}String token = request.getHeader(Constant.HEADER_TOKEN);Long id = redisUtil.get(token);//獲取該用戶的權限List<SystemRole> roleList = systemRoleService.listByUserId(id);Set<String> permissions;if (roleList.size() == 0) {permissions = new HashSet<>();} else {permissions = systemFunctionService.getPermission(roleList);}//驗證權限if (VALIDATE_MAP.get(match).validate(permissions, requiredPermissions)) {return true;}//權限驗證失敗throw new HttpException(HttpCode.HAS_NO_PERMISSIONS, "沒有權限,請聯系管理員");}private interface Validate {/*** 驗證權限* @param userPermission 用戶擁有的權限* @param methodPermission 方法需要的權限* @return 是否通過*/Boolean validate(Set<String> userPermission, String[] methodPermission);} }

實現通知消息的推送

@Component @ServerEndpoint("/ws/{name}") public class WebSocket {private Session session;private String name;public final static Map<String,WebSocket> WEB_SOCKET_SET = new ConcurrentHashMap<>();@OnOpenpublic void onOpen(Session session,@PathParam(value = "name") String name){this.session = session;this.name = name;WEB_SOCKET_SET.put(name,this);}@OnClosepublic void onClose(){WEB_SOCKET_SET.remove(name);}@OnMessagepublic void onMessage(String message) throws JsonProcessingException {Message m = new ObjectMapper().readValue(message, Message.class);System.out.println(m);}/*** 發送消息* @param userId 目標用戶id* @param message 消息內容* @param systemUserService 。*/public static boolean sendMessage(Long userId, Message message, SystemUserService systemUserService) {SystemUser systemUser = systemUserService.get(userId).orElseThrow(() -> new HttpException(HttpCode.FAILED, "用戶不存在"));if (WEB_SOCKET_SET.containsKey(systemUser.getLoginName())) {ObjectMapper objectMapper = new ObjectMapper();try {WEB_SOCKET_SET.get(systemUser.getLoginName()).session.getBasicRemote().sendText(objectMapper.writeValueAsString(message));return true;} catch (IOException e) {e.printStackTrace();}}return false;} }

示例

登錄

管理員主頁

宿舍管理

學生管理

班級管理

宿舍樓管理

維修記錄

用戶管理

角色管理

菜單管理

日志記錄

消息

審核

總結

以上是生活随笔為你收集整理的基于 SpringBoot + Vue 的学生公寓管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。