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);
|
}
|
}
|