package cn.stylefeng.workflow.api.entity.log;

import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.annotation.EnumFieldFormat;
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.workflow.api.format.DefinitionFormatProcess;
import cn.stylefeng.workflow.api.format.NodeFormatProcess;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@TableName("flow_engine_log")
@Data
@EqualsAndHashCode(callSuper = true)
public class FlowEngineLog extends BaseEntity {

    @TableId(value = "log_id", type = IdType.ASSIGN_ID)
    @ChineseDescription("主键")
    private Long logId;

    @TableField("model_id")
    @ChineseDescription("流程模型id")
    private Long modelId;

    @TableField("definition_id")
    @ChineseDescription("流程定义id")
    @SimpleFieldFormat(processClass = DefinitionFormatProcess.class)
    private Long definitionId;

    @TableField("instance_id")
    @ChineseDescription("流程实例id")
    private Long instanceId;

    @TableField("re_node_id")
    @ChineseDescription("流程节点id")
    @SimpleFieldFormat(processClass = NodeFormatProcess.class)
    private Long reNodeId;

    @TableField("message")
    @ChineseDescription("流程日志概要")
    private String message;

    @TableField("success_flag")
    @ChineseDescription("是否执行成功：Y-成功，N-失败")
    @EnumFieldFormat(processEnum = YesOrNotEnum.class)
    private String successFlag;

    @TableField("variable_json_value")
    @ChineseDescription("当前流程变量池")
    private String variableJsonValue;

    @TableField("log_level")
    @ChineseDescription("日志等级：info-信息，warn-警告，error-错误，fatal-致命")
    private String logLevel;

    @TableField("begin_time")
    @ChineseDescription("开始时间")
    private Date beginTime;

    @TableField("end_time")
    @ChineseDescription("结束时间")
    private Date endTime;

    @TableField(value = "tenant_id", fill = FieldFill.INSERT)
    @ChineseDescription("租户号")
    private Long tenantId;

}
