From edc9a6674eb9b40e33a74c5f022d279712ed3b7c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 30 十二月 2024 17:01:13 +0800 Subject: [PATCH] 添加许可工具 --- se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java | 80 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 72 insertions(+), 8 deletions(-) diff --git a/se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java b/se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java index 10ffcf1..cbb4fa7 100644 --- a/se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java +++ b/se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java @@ -1,5 +1,6 @@ package com.se.system.controller; +import com.se.common.core.utils.StringUtils; import com.se.common.core.utils.ip.IpUtils; import com.se.common.core.web.controller.BaseController; import com.se.common.core.web.domain.AjaxResult; @@ -10,9 +11,12 @@ import com.se.system.api.domain.SysLogininfor; import com.se.system.api.domain.SysOperLog; import com.se.system.api.model.LoginUser; +import com.se.system.domain.SysMenu; import com.se.system.service.IndexService; +import com.se.system.service.impl.SysMenuServiceImpl; import com.se.system.service.inte.ISysLogininforService; import com.se.system.service.inte.ISysOperLogService; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -31,18 +35,31 @@ IndexService indexService; @Resource + SysMenuServiceImpl menuService; + + @Resource ISysOperLogService operLogService; @Resource ISysLogininforService logininforService; + + private SysMenu sysMenu = new SysMenu(); + + public IndexController() { + sysMenu.setMark("index"); + } // 鈶燩V缁熻锛歅V锛圥age View锛夛細椤甸潰娴忚閲忔垨鐐瑰嚮閲忥紝鍗崇綉绔欐墍鏈夐〉闈㈣璁块棶鐨勬�绘鏁般�� // 姣忔墦寮�鎴栧埛鏂颁竴涓〉闈紝PV灏变細澧炲姞涓�娆★紝澶氭鎵撳紑鎴栧埛鏂板悓涓�椤甸潰鍒欐祻瑙堥噺绱銆� // PV鍙嶆槧浜嗙綉绔欑敤鎴疯闂殑缃戦〉鏁伴噺锛屾槸琛¢噺缃戠珯娴侀噺鐨勯噸瑕佹寚鏍囦箣涓� @Log(title = "PV缁熻", businessType = BusinessType.OTHER) @GetMapping("/pvCount") - public Map<String, Object> pvCount() { + public Map<String, Object> pvCount(Integer day) { + if (null == day || day < 1) day = 15; + if (day > 365) day = 365; + Map<String, Object> map = new HashMap<>(); + map.put("pvCount", indexService.pvCount(day)); return map; } @@ -52,8 +69,12 @@ // 濡傛灉鏇存崲浜咺P鍚庝絾涓嶆竻闄ookies锛屽啀璁块棶鐩稿悓缃戠珯锛岃缃戠珯鐨勭粺璁′腑UV鏁版槸涓嶅彉鐨勩�� @Log(title = "UV缁熻", businessType = BusinessType.OTHER) @GetMapping("/uvCount") - public Map<String, Object> uvCount() { + public Map<String, Object> uvCount(Integer day) { + if (null == day || day < 1) day = 15; + if (day > 365) day = 365; + Map<String, Object> map = new HashMap<>(); + map.put("uvCount", indexService.uvCount(day)); return map; } @@ -66,6 +87,20 @@ if (day > 365) day = 365; Map<String, Object> map = new HashMap<>(); + map.put("newUserCount", indexService.newUserCount(day)); + + return map; + } + + @Log(title = "鏁版嵁缁熻", businessType = BusinessType.OTHER) + @GetMapping("/dataCount") + public Map<String, Object> dataCount(Integer day) { + if (null == day || day < 1) day = 15; + if (day > 365) day = 365; + + Map<String, Object> map = new HashMap<>(); + map.put("pvCount", indexService.pvCount(day)); + map.put("uvCount", indexService.uvCount(day)); map.put("newUserCount", indexService.newUserCount(day)); return map; @@ -95,12 +130,15 @@ // 鈶ュ父鐢ㄧ郴缁熷睍绀�/鍚勭郴缁熻闂俊鎭細鍩轰簬鐢ㄦ埛璁块棶娆℃暟鎺掑悕锛屽睍绀哄墠浜斾釜绯荤粺鐨勬帓鍚� // 骞跺睍绀哄悇涓郴缁熶竴澶╁唴銆佷笁澶╁唴銆佷竴鍛ㄥ唴鐨勮闂鏁般�傘�愬彲鑰冭檻鎸夊叾浠栨寚鏍囪繘琛屾帓鍚嶅睍绀恒�� - @Log(title = "鐢ㄦ埛缁熻鎺掕", businessType = BusinessType.OTHER) + @Log(title = "甯哥敤绯荤粺灞曠ず", businessType = BusinessType.OTHER) @GetMapping("/sysVisitList") - public Map<String, Object> sysVisitList() { - Map<String, Object> map = new HashMap<>(); + public List<Map<String, Object>> sysVisitList(Integer day, Integer amount) { + if (null == day || day < 1) day = 15; + if (day > 365) day = 365; + if (null == amount) amount = 5; + if (amount > 100) amount = 100; - return map; + return indexService.sysVisitList(day, amount); } @Log(title = "杩愮淮鐩戞帶", businessType = BusinessType.OTHER) @@ -114,13 +152,39 @@ return map; } + @GetMapping("/getAllPerms") + public AjaxResult getAllPerms() { + try { + List<SysMenu> menus = menuService.selectMenuList(sysMenu, 1L); + + return success(menuService.buildMenus(menus)); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return error(ex.getMessage()); + } + } + + @GetMapping("/getMyPerms") + public AjaxResult getMyPerms() { + try { + Long userId = SecurityUtils.getUserId(); + List<SysMenu> menus = menuService.selectMenuList(sysMenu, userId); + + return success(menuService.buildMenus(menus)); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return error(ex.getMessage()); + } + } + @GetMapping("/addAccessLog") - public AjaxResult addAccessLog(String title, int status) { + public AjaxResult addAccessLog(String title, Integer status) { long start = System.currentTimeMillis(); + if (null == status || status < 0) status = 0; SysOperLog log = new SysOperLog(); log.setTitle(title); - // 0=鍏跺畠,1=鏂板,2=淇敼,3=鍒犻櫎,4=鎺堟潈,5=瀵煎嚭,6=瀵煎叆,7=寮洪��,8=鐢熸垚浠g爜,9=娓呯┖鏁版嵁 + // 0=鍏跺畠,1=鏂板,2=淇敼,3=鍒犻櫎,4=鎺堟潈,5=瀵煎嚭,6=瀵煎叆,7=寮洪��,8=鐢熸垚浠g爜,9=娓呯┖鏁版嵁,14=鏈巿鏉� log.setBusinessType(0); // ServletUtils.getRequest().getMethod() log.setMethod("com.se.system.controller.IndexController.addAccessLog()"); -- Gitblit v1.9.3