| | |
| | | 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 { |
| | | public class IndexController extends BaseController { |
| | | @Resource |
| | | ISysOperLogService operLogService; |
| | | |
| | | @GetMapping("/monitor") |
| | | public Map<String, Object> monitor() { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | //@Log(title = "è§è²ç®¡ç", businessType = BusinessType.INSERT) |
| | | @GetMapping("/addAccessLog") |
| | | public AjaxResult addAccessLog(String title) { |
| | | 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("{\"msg\":\"æä½æå\",\"code\":200}"); |
| | | log.setStatus(0); |
| | | log.setOperTime(new Date()); |
| | | log.setCostTime(System.currentTimeMillis() - start); |
| | | |
| | | int rows = operLogService.insertOperlog(log); |
| | | |
| | | return toAjax(rows); |
| | | } |
| | | } |
| | | |
| | | |