完善系统日志

This commit is contained in:
2023-07-31 19:40:33 +08:00
parent c3d88a9d29
commit 2c685d933d
14 changed files with 58 additions and 49 deletions

View File

@@ -1,7 +1,10 @@
package cn.lihongjie.coal.annotation;
import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@@ -9,7 +12,11 @@ public @interface SysLog {
String module() default "";
String msg() default "";
String action() default "";
String message() default "";

View File

@@ -172,12 +172,11 @@ public class ControllerAop {
SysLog sysLog = AnnotationUtils.findAnnotation(method, SysLog.class);
SysLogEntity sysLogEntity = null;
String module = "";
if (sysLog != null) {
String module = sysLog.module();
String msg = sysLog.msg();
module = sysLog.module();
if (StringUtils.isEmpty(module)) {
SysLog classLog = AnnotationUtils.findAnnotation(method.getClass(), SysLog.class);
if (classLog != null) {
@@ -188,7 +187,9 @@ public class ControllerAop {
sysLogEntity = new SysLogEntity();
sysLogEntity.setModule(module);
sysLogEntity.setMessage(sysLog.message());
sysLogEntity.setAction(sysLog.action());
sysLogEntity.setIp(RequestUtils.getIp(request));
sysLogEntity.setIpLocation(RequestUtils.getIp(request));
sysLogEntity.setUrl(request.getRequestURI());

View File

@@ -1,11 +1,7 @@
package cn.lihongjie.coal.controller;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.dto.CommonQuery;
import cn.lihongjie.coal.dto.IdRequest;
import cn.lihongjie.coal.dto.CreateCoalParameterDefDto;
import cn.lihongjie.coal.dto.UpdateCoalParameterDefDto;
import cn.lihongjie.coal.dto.CoalParameterDefDto;
import cn.lihongjie.coal.dto.*;
import cn.lihongjie.coal.service.CoalParameterDefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@@ -23,20 +19,20 @@ public class CoalParameterDefController {
CoalParameterDefService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public CoalParameterDefDto create(@RequestBody CreateCoalParameterDefDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public CoalParameterDefDto update(@RequestBody UpdateCoalParameterDefDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class DepartmentController {
DepartmentService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public DepartmentDto create(@RequestBody CreateDepartmentDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public DepartmentDto update(@RequestBody UpdateDepartmentDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -20,20 +20,20 @@ public class DictionaryController {
DictionaryService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public DictionaryDto create(@RequestBody CreateDictionaryDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public DictionaryDto update(@RequestBody UpdateDictionaryDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -25,7 +25,7 @@ public class LoginController {
UserService userService;
@PostMapping("/login")
@SysLog(msg = "登录")
@SysLog(action = "登录")
@Anonymous
public UserDto login(@RequestBody LoginDto dto) {
this.service.login(dto);
@@ -43,7 +43,7 @@ public class LoginController {
}
@PostMapping("/logout")
@SysLog(msg = "退出")
@SysLog(action = "退出")
public Object logout() {
this.service.logout();
return null;

View File

@@ -19,20 +19,20 @@ public class OrganizationController {
OrganizationService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public OrganizationDto create(@RequestBody CreateOrganizationDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public OrganizationDto update(@RequestBody UpdateOrganizationDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class PermissionController {
PermissionService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public PermissionDto create(@RequestBody CreatePermissionDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public PermissionDto update(@RequestBody UpdatePermissionDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class ResourceController {
ResourceService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public ResourceDto create(@RequestBody CreateResourceDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public ResourceDto update(@RequestBody UpdateResourceDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class RoleController {
RoleService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public RoleDto create(@RequestBody CreateRoleDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public RoleDto update(@RequestBody UpdateRoleDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class SupplierController {
SupplierService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public SupplierDto create(@RequestBody CreateSupplierDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public SupplierDto update(@RequestBody UpdateSupplierDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -19,20 +19,20 @@ public class SysConfigController {
SysConfigService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public SysConfigDto create(@RequestBody CreateSysConfigDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public SysConfigDto update(@RequestBody UpdateSysConfigDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -1,12 +1,7 @@
package cn.lihongjie.coal.controller;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.dto.CommonQuery;
import cn.lihongjie.coal.dto.IdRequest;
import cn.lihongjie.coal.dto.ChangeUserPwdDto;
import cn.lihongjie.coal.dto.CreateUserDto;
import cn.lihongjie.coal.dto.UpdateUserDto;
import cn.lihongjie.coal.dto.UserDto;
import cn.lihongjie.coal.dto.*;
import cn.lihongjie.coal.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@@ -24,20 +19,20 @@ public class UserController {
UserService service;
@PostMapping("/create")
@SysLog(msg = "新增")
@SysLog(action = "新增")
public UserDto create(@RequestBody CreateUserDto dto) {
return this.service.create(dto);
}
@PostMapping("/update")
@SysLog(msg = "编辑")
@SysLog(action = "编辑")
public UserDto update(@RequestBody UpdateUserDto dto) {
return this.service.update(dto);
}
@PostMapping("/delete")
@SysLog(msg = "删除")
@SysLog(action = "删除")
public Object delete(@RequestBody IdRequest dto) {
this.service.delete(dto);
return null;

View File

@@ -12,6 +12,16 @@ public class SysLogEntity extends OrgBaseEntity {
@Comment("ip")
private String ip;
@Comment("模块")
private String module;
@Comment("操作")
private String action;
@Comment("详细信息")
private String message;
@Comment("ip定位")
private String ipLocation;