package com.gzzm.lobster.audit;

import net.cyan.thunwind.annotation.ColumnDescription;
import net.cyan.thunwind.annotation.Entity;
import net.cyan.thunwind.annotation.Index;

import java.util.Date;

/**
 * AuditLog —— 实名审计记录 / Real-name audit record.
 *
 * <p>覆盖：读 OA 文件、写 OA 文件、调知识库、调 skill、调工具、
 * 发 OA 邮件、启动流程、保存文档工坊、覆盖原文件。
 * Covers OA reads/writes, KB calls, skill calls, tool calls, mail / flow actions.
 */
@Entity(table = "AI_AUDIT_LOG", keys = "auditId")
public class AuditLog {

    @ColumnDescription(type = "varchar(40)")
    private String auditId;

    @Index
    @ColumnDescription(type = "varchar(40)", nullable = false)
    private String userId;

    @ColumnDescription(type = "varchar(40)")
    private String deptId;

    @ColumnDescription(type = "varchar(40)")
    private String orgId;

    @Index
    @ColumnDescription(type = "varchar(40)")
    private String threadId;

    @ColumnDescription(type = "varchar(40)")
    private String runId;

    /** tool.call / oa.file.read / oa.kb.query / skill.invoke / mail.send / flow.start / ...  */
    @Index
    @ColumnDescription(type = "varchar(240)", nullable = false)
    private String actionType;

    @ColumnDescription(type = "varchar(40)")
    private String targetType;

    @ColumnDescription(type = "varchar(220)")
    private String targetRef;

    /** ok / error / denied / pending / circuit_broken */
    @ColumnDescription(type = "varchar(20)")
    private String result;

    @ColumnDescription(type = "varchar(4000)")
    private String detailJson;

    @ColumnDescription(type = "number(10)")
    private Integer durationMs;

    private Date createTime;

    public AuditLog() {}

    public String getAuditId() { return auditId; }
    public void setAuditId(String auditId) { this.auditId = auditId; }
    public String getUserId() { return userId; }
    public void setUserId(String userId) { this.userId = userId; }
    public String getDeptId() { return deptId; }
    public void setDeptId(String deptId) { this.deptId = deptId; }
    public String getOrgId() { return orgId; }
    public void setOrgId(String orgId) { this.orgId = orgId; }
    public String getThreadId() { return threadId; }
    public void setThreadId(String threadId) { this.threadId = threadId; }
    public String getRunId() { return runId; }
    public void setRunId(String runId) { this.runId = runId; }
    public String getActionType() { return actionType; }
    public void setActionType(String actionType) { this.actionType = actionType; }
    public String getTargetType() { return targetType; }
    public void setTargetType(String targetType) { this.targetType = targetType; }
    public String getTargetRef() { return targetRef; }
    public void setTargetRef(String targetRef) { this.targetRef = targetRef; }
    public String getResult() { return result; }
    public void setResult(String result) { this.result = result; }
    public String getDetailJson() { return detailJson; }
    public void setDetailJson(String detailJson) { this.detailJson = detailJson; }
    public Integer getDurationMs() { return durationMs; }
    public void setDurationMs(Integer durationMs) { this.durationMs = durationMs; }
    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }
}
