liufan9527
2024-11-27 816022de986f97869923dc8024e4985242a9068e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.se.system.controller;
 
import com.alibaba.fastjson2.JSON;
import com.se.common.core.utils.ServletUtils;
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.common.log.annotation.Log;
import com.se.common.log.enums.BusinessType;
import com.se.common.security.utils.SecurityUtils;
import com.se.system.api.domain.SysOperLog;
import com.se.system.api.model.LoginUser;
import com.se.system.service.inte.ISysOperLogService;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
@RestController
@RequestMapping("/index")
@SuppressWarnings("ALL")
public class IndexController extends BaseController {
    @Resource
    ISysOperLogService operLogService;
 
    @GetMapping("/monitor")
    public Map<String, Object> monitor() {
        Map<String, Object> map = new HashMap<>();
 
        return map;
    }
 
    @GetMapping("/userList")
    public Map<String, Object> userList() {
        Map<String, Object> map = new HashMap<>();
 
        return map;
    }
 
    @GetMapping("/uvCount")
    public Map<String, Object> uvCount() {
        Map<String, Object> map = new HashMap<>();
 
        return map;
    }
 
    @GetMapping("/pvCount")
    public Map<String, Object> pvCount() {
        Map<String, Object> map = new HashMap<>();
 
        return map;
    }
 
    //@Log(title = "角色管理", businessType = BusinessType.INSERT)
    @GetMapping("/addAccessLog")
    public AjaxResult addAccessLog(String title, int status) {
        long start = System.currentTimeMillis();
 
        SysOperLog log = new SysOperLog();
        log.setTitle(title);
        // 0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据
        log.setBusinessType(0);
        // ServletUtils.getRequest().getMethod()
        log.setMethod("com.se.system.controller.IndexController.addAccessLog()");
        log.setRequestMethod("GET");
        log.setOperatorType(1);
 
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (null != loginUser) {
            log.setOperName(loginUser.getUsername());
            log.setDeptName(loginUser.getSysUser().getDept().getDeptName());
        }
        // StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255)
        log.setOperUrl("/index/addAccessLog");
        log.setOperIp(IpUtils.getIpAddr());
        log.setOperParam("{\"title\":\"" + title + "\"}");
 
        log.setJsonResult(String.format("{\"msg\":\"%s\",\"code\":%d}", 0 == status ? "成功" : "失败", 0 == status ? 200 : 400));
        log.setStatus(status);
        log.setOperTime(new Date());
        log.setCostTime(System.currentTimeMillis() - start + 10);
 
        int rows = operLogService.insertOperlog(log);
 
        return toAjax(rows);
    }
}