| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | IndexService indexService; |
| | | |
| | | @Resource |
| | | SysMenuServiceImpl menuService; |
| | | |
| | | @Resource |
| | | ISysOperLogService operLogService; |
| | | |
| | | @Resource |
| | | ISysLogininforService logininforService; |
| | | |
| | | private SysMenu sysMenu = new SysMenu(); |
| | | |
| | | public IndexController() { |
| | | sysMenu.setMark("index"); |
| | | } |
| | | |
| | | // ①PV统计:PV(Page View):页面浏览量或点击量,即网站所有页面被访问的总次数。 |
| | | // 每打开或刷新一个页面,PV就会增加一次,多次打开或刷新同一页面则浏览量累计。 |
| | |
| | | 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; |
| | | } |
| | | |
| | | // ④用户登录信息:以一定形式展示新登录或退出登录的用户账户及时间。 |
| | | @Log(title = "用户登录信息", businessType = BusinessType.OTHER) |
| | | @GetMapping("/lastLogin") |
| | |
| | | |
| | | // ⑥常用系统展示/各系统访问信息:基于用户访问次数排名,展示前五个系统的排名 |
| | | // 并展示各个系统一天内、三天内、一周内的访问次数。【可考虑按其他指标进行排名展示】 |
| | | @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) |
| | |
| | | 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=生成代码,9=清空数据 |
| | | // 0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据,14=未授权 |
| | | log.setBusinessType(0); |
| | | // ServletUtils.getRequest().getMethod() |
| | | log.setMethod("com.se.system.controller.IndexController.addAccessLog()"); |