refactor: 资源池添加日志示例
This commit is contained in:
parent
4f0efcd411
commit
ec284cac6f
|
@ -265,8 +265,7 @@ public class OperationLogAspect {
|
|||
OperationLog operationLog = new OperationLog();
|
||||
//保存获取的操作
|
||||
operationLog.setId(UUID.randomUUID().toString());
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
operationLog.setMethod(StringUtils.join(className, ".", method.getName()));
|
||||
operationLog.setMethod(method.getName());
|
||||
operationLog.setCreateTime(System.currentTimeMillis());
|
||||
operationLog.setCreateUser(SessionUtils.getUserId());
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
|
|
@ -28,15 +28,16 @@ public class TestResourcePoolController {
|
|||
|
||||
@PostMapping("/add")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_ADD)
|
||||
@RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
||||
sourceId = "#testResourcePoolDTO.id", projectId = "#testResourcePoolDTO.projectId", details = "#testResourcePoolDTO.name")
|
||||
public TestResourcePoolDTO addTestResourcePool(@RequestBody TestResourcePoolDTO testResourcePoolDTO) {
|
||||
return testResourcePoolService.addTestResourcePool(testResourcePoolDTO);
|
||||
@RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#poolDTO.name")
|
||||
public TestResourcePoolDTO addTestResourcePool(@RequestBody TestResourcePoolDTO poolDTO) {
|
||||
return testResourcePoolService.addTestResourcePool(poolDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{poolId}")
|
||||
@CacheNode // 把监控节点缓存起来
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_DELETE)
|
||||
@RequestLog(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
||||
details = "#msClass.getLogDetails(#testResourcePoolId)", msClass = TestResourcePoolService.class)
|
||||
public void deleteTestResourcePool(@PathVariable(value = "poolId") String testResourcePoolId) {
|
||||
testResourcePoolService.deleteTestResourcePool(testResourcePoolId);
|
||||
}
|
||||
|
@ -45,18 +46,17 @@ public class TestResourcePoolController {
|
|||
@CacheNode // 把监控节点缓存起来
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_UPDATE)
|
||||
@RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
||||
sourceId = "#testResourcePoolDTO.id", projectId = "#testResourcePoolDTO.projectId", details = "#testResourcePoolDTO.name")
|
||||
sourceId = "#testResourcePoolDTO.id", details = "#testResourcePoolDTO.name")
|
||||
public void updateTestResourcePool(@RequestBody TestResourcePoolDTO testResourcePoolDTO) {
|
||||
testResourcePoolService.updateTestResourcePool(testResourcePoolDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ)
|
||||
public Pager<List<TestResourcePoolDTO>> listResourcePools( @RequestBody QueryResourcePoolRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(),request.getPageSize(), true);
|
||||
public Pager<List<TestResourcePoolDTO>> listResourcePools(@RequestBody QueryResourcePoolRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true);
|
||||
return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -128,4 +128,12 @@ public class TestResourcePoolService {
|
|||
return resourcePoolService.validate(testResourcePool);
|
||||
}
|
||||
|
||||
public String getLogDetails(String id) {
|
||||
TestResourcePool pool = testResourcePoolMapper.selectByPrimaryKey(id);
|
||||
if (pool != null) {
|
||||
return pool.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue