package com.reading.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 操作日志实体
 */
@Data
@TableName("t_operation_log")
@Schema(description = "操作日志")
public class OperationLog {

    @Schema(description = "日志 ID", accessMode = Schema.AccessMode.READ_ONLY)
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    @Schema(description = "租户 ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String tenantId;

    @Schema(description = "用户 ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String userId;

    @Schema(description = "用户角色 admin/school/teacher/parent", example = "teacher")
    private String userRole;

    @Schema(description = "操作类型", example = "CREATE", requiredMode = Schema.RequiredMode.REQUIRED)
    private String action;

    @Schema(description = "操作模块", example = "lesson", requiredMode = Schema.RequiredMode.REQUIRED)
    private String module;

    @Schema(description = "目标类型", example = "student")
    private String targetType;

    @Schema(description = "目标 ID")
    private String targetId;

    @Schema(description = "操作详情")
    private String details;

    @Schema(description = "IP 地址")
    private String ipAddress;

    @Schema(description = "用户代理")
    private String userAgent;

    @Schema(description = "创建人用户名", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private String createdBy;

    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

}
