联调日志采集与查询
This commit is contained in:
@@ -19,8 +19,8 @@ public @interface LogAnno {
|
||||
String operateType();
|
||||
// 记录日志主键
|
||||
String primaryKey() default "id";
|
||||
// 记录日志表
|
||||
String tableName() default "-";
|
||||
// 记录模块
|
||||
String moduleName() default "-";
|
||||
|
||||
boolean isBefore() default false;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.jasig.cas.client.authentication.AttributePrincipal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -15,6 +16,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.module.auth.entity.FtUser;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
@@ -55,6 +57,8 @@ public class OprateLog {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
assert attributes != null;
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
HashMap<String,Object> user=(HashMap<String,Object>)SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
// 1.方法执行前的处理,相当于前置通知
|
||||
// 获取方法签名
|
||||
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
|
||||
@@ -67,17 +71,17 @@ public class OprateLog {
|
||||
result= (ResultVO) pjp.proceed();
|
||||
}
|
||||
|
||||
String operateType = logAnno.operateType();
|
||||
// 获取操作记录的日志表
|
||||
Map<String,Object> log=new HashMap<String,Object>();
|
||||
log.put("CREATE_TIME", new Date());
|
||||
log.put("IP", request.getRemoteAddr());
|
||||
log.put("CURL", request.getRequestURI());
|
||||
log.put("ACTTYPE", request.getMethod());
|
||||
log.put("CLOG", operateType + "参数:" + request.getQueryString());
|
||||
// log.put("USERID", value);
|
||||
log.put("STATUS", (byte) 1);
|
||||
|
||||
log.put("CLOG","参数:" + request.getQueryString());
|
||||
log.put("OPERATETYPE", logAnno.operateType());
|
||||
log.put("MODULENAME", logAnno.moduleName());
|
||||
log.put("USERID", user.get("LOGIN_NAME"));
|
||||
|
||||
tableService.saveWithDate(TABLE_INFO, log);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.hcframe.user.module.userinfo.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.user.module.userinfo.service.LogService;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("log")
|
||||
@Api(tags = "日志查询")
|
||||
public class LogController {
|
||||
|
||||
final LogService logService;
|
||||
|
||||
public LogController(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "日志查询模块")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getLogList(String data, WebPageInfo webPageInfo) {
|
||||
return logService.getLogList(data, webPageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.log.annotation.LogAnno;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
@@ -39,18 +40,21 @@ public class OsController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@LogAnno(operateType="新增系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "新增系统", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addOs(@RequestParam Map<String,Object> os) {
|
||||
return osService.addOs(os);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@LogAnno(operateType="更新系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "更新系统信息")
|
||||
public ResultVO<Integer> updateOs(@RequestParam Map<String,Object> os,@PathVariable Integer version) {
|
||||
return osService.updateOs(os,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@LogAnno(operateType="删除系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "删除系统信息")
|
||||
public ResultVO<Object> deleteOs(@PathVariable String ids) {
|
||||
return osService.deleteOs(ids);
|
||||
|
||||
@@ -39,25 +39,27 @@ public class TitleController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@LogAnno(operateType="新增职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "新增title", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addTitle(@RequestParam Map<String,Object> title) {
|
||||
return titleService.addTitle(title);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@LogAnno(operateType="更新职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "更新title")
|
||||
public ResultVO<Integer> updateTitle(@RequestParam Map<String,Object> title,@PathVariable Integer version) {
|
||||
return titleService.updateTitle(title,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@LogAnno(operateType="删除职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "删除title")
|
||||
public ResultVO<Object> deleteTitle(@PathVariable String ids) {
|
||||
return titleService.deleteTitle(ids);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@LogAnno(operateType="getTitleList",tableName="title")
|
||||
@ApiOperation(value = "获取职称列表")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getTitleList(String data, WebPageInfo webPageInfo) {
|
||||
return titleService.getTitleList(data, webPageInfo);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.hcframe.user.module.userinfo.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
|
||||
public interface LogService {
|
||||
ResultVO<PageInfo<Map<String, Object>>> getLogList(String data, WebPageInfo webPageInfo);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hcframe.user.module.userinfo.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
import com.hcframe.user.module.userinfo.service.LogService;
|
||||
|
||||
|
||||
@Service
|
||||
public class LogServiceImpl implements LogService{
|
||||
|
||||
private static final String LOG_ID = "LOG_ID";
|
||||
private static final String OS_SYS_TITLE = "GB_LOGS";
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_TITLE).tablePk(LOG_ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
public LogServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getLogList(String data, WebPageInfo webPageInfo) {
|
||||
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
return ResultVO.getSuccess(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user