ApiController.java
2.08 KB
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
package com.uccc.log.controller;
import com.alibaba.fastjson.JSONObject;
import com.uccc.log.service.LogService;
import com.uccc.pretty.common.Result;
import com.uccc.pretty.common.SystemLogEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.uccc.pretty.constants.ResultEnum.RESULT_OK;
/**
* Created by bert on 2021-09-28 10:05
*/
@RestController
@RequestMapping("/sys_log/")
public class ApiController {
private Logger logger = LoggerFactory.getLogger(ApiController.class);
@Autowired
private LogService logService;
@RequestMapping(value = "log_list",method = RequestMethod.GET)
public Result sysLogList (@RequestParam(name = "limit") Integer limit,
@RequestParam(name = "page") Integer page,
@RequestParam(name = "operator", required = false) Long operator,
@RequestParam(name = "action", required = false) String action,
@RequestParam(name = "ip", required = false) String ip,
@RequestParam(name = "time", required = false) String[] time
) throws NullPointerException{
Result result = new Result();
List<SystemLogEntity> systemLogs = logService.getSysLogByCondition(limit,page,operator,action,ip,time);
int count = 0;
if (systemLogs.size() > 0) {
count = logService.getSysLogCountByCondition(operator,action,ip,time);
result.setCode(RESULT_OK.getCode());
result.setMessage(RESULT_OK.getMessage());
}
JSONObject json = new JSONObject();
json.put("count", count);
json.put("rows", systemLogs);
result.setData(json);
return result;
}
}