新建自定义日志模块
parent
e7742fdfe0
commit
e0b8a57c0d
@ -0,0 +1,26 @@
|
||||
package com.engine.organization.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/4/27
|
||||
* @Version V1.0
|
||||
**/
|
||||
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Log {
|
||||
|
||||
/**
|
||||
* 操作事件
|
||||
*/
|
||||
String value();
|
||||
|
||||
/**
|
||||
* 字段组装描述内容
|
||||
*/
|
||||
String description() default "";
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.engine.organization.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO 日志实体类 hr_log
|
||||
* @Date 2022/4/27
|
||||
* @Version V1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoggerContext implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 15869325700230992L;
|
||||
|
||||
//日志ID
|
||||
private long id;
|
||||
|
||||
//操作人
|
||||
private String operator;
|
||||
|
||||
//操作人姓名
|
||||
private String operatorName;
|
||||
|
||||
// '操作时间(yyyy-MM-dd HH:mm:ss)'
|
||||
@JSONField(format="yyyy-MM-dd HH:mm:ss")
|
||||
private Date operTime;
|
||||
|
||||
private Integer operateType;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.engine.organization.enums;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/4/28
|
||||
* @Version V1.0
|
||||
**/
|
||||
public enum OperateTypeEnum {
|
||||
|
||||
ADD("1", "新增"),
|
||||
UPDATE("2", "更新"),
|
||||
DELETE("4", "删除");
|
||||
|
||||
private String value;
|
||||
|
||||
private String label;
|
||||
|
||||
OperateTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.engine.organization.util;
|
||||
|
||||
import com.engine.organization.annotation.Log;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/4/27
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class LogAspect<T> {
|
||||
|
||||
Class<T> clazz;
|
||||
|
||||
Method method;
|
||||
|
||||
public LogAspect(Class<T> clazz,Method method) {
|
||||
this.clazz = clazz;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
try {
|
||||
boolean f = method.isAnnotationPresent(Log.class);
|
||||
|
||||
if (f) {
|
||||
Log annotation = method.getAnnotation(Log.class);
|
||||
String value = annotation.value();
|
||||
String description = annotation.description();
|
||||
}
|
||||
|
||||
Method[] methods = clazz.getMethods();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue