feat(module): 添加操作日志模块
- 新增操作日志相关实体类、DTO、Mapper、Repository和服务接口 - 实现基本的操作日志记录功能 - 为后续的 SpEL 表达式解析和动态日志内容生成做准备
This commit is contained in:
parent
c125eb15b9
commit
7624d94145
@ -0,0 +1,36 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.dto;
|
||||
|
||||
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OperationLogDto {
|
||||
/**
|
||||
* 模块类型
|
||||
*/
|
||||
private OperationLog.ModelType modelType;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private OperationLog.OperationType operationType;
|
||||
|
||||
/**
|
||||
* 操作内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private LocalDateTime makeTime;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.entity;
|
||||
|
||||
public class ExpressionRootObject {
|
||||
private final Object object;
|
||||
private final Object[] args;
|
||||
|
||||
public ExpressionRootObject(Object object, Object[] args) {
|
||||
this.object = object;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zsc.edu.gateway.common.enums.IState;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("operation_log")
|
||||
public class OperationLog {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模块类型
|
||||
*/
|
||||
private ModelType modelType;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private OperationType operationType;
|
||||
|
||||
/**
|
||||
* 操作内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private LocalDateTime makeTime;
|
||||
|
||||
public enum ModelType implements IEnum<Integer>, IState<ModelType> {
|
||||
ATTACHMENT(1, "附件模块"),
|
||||
IOT(2, "物模型模块"),
|
||||
MESSAGE(3, "公告消息模块"),
|
||||
SYSTEM(4, "系统模块");
|
||||
|
||||
private final Integer value;
|
||||
private final String name;
|
||||
|
||||
ModelType(int value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
public enum OperationType implements IEnum<Integer>, IState<OperationType> {
|
||||
CREATE(1, "添加"),
|
||||
UPDATE(2, "更新"),
|
||||
DELETE(3, "删除");
|
||||
|
||||
private final Integer value;
|
||||
private final String name;
|
||||
|
||||
OperationType(int value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.entity;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface OperationLogAnnotation {
|
||||
/**
|
||||
* 日志内容,支持SpEL表达式
|
||||
*/
|
||||
String content() default "";
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.mapper;
|
||||
|
||||
import com.zsc.edu.gateway.common.mapstruct.BaseMapper;
|
||||
import com.zsc.edu.gateway.modules.operationLog.dto.OperationLogDto;
|
||||
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface OperationLogMapper extends BaseMapper<OperationLog, OperationLogDto> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.repo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
|
||||
|
||||
public interface OperationLogRepository extends BaseMapper<OperationLog> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
|
||||
|
||||
public interface OperationLogService extends IService<OperationLog> {
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.zsc.edu.gateway.modules.operationLog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
|
||||
import com.zsc.edu.gateway.modules.operationLog.repo.OperationLogRepository;
|
||||
import com.zsc.edu.gateway.modules.operationLog.service.OperationLogService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class OperationLogServiceImpl extends ServiceImpl<OperationLogRepository, OperationLog> implements OperationLogService {
|
||||
}
|
Loading…
Reference in New Issue
Block a user