package cn.stylefeng.workflow.instance.modular.draft.entity;

import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseBusinessEntity;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
import cn.stylefeng.roses.kernel.sys.api.format.OrgNameFormatProcess;
import cn.stylefeng.roses.kernel.sys.api.format.UserNameFormatProcess;
import cn.stylefeng.workflow.api.pojo.InstanceVariable;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;

@TableName(value = "flow_engine_draft", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
public class FlowEngineDraft extends BaseBusinessEntity {

    @TableId(value = "draft_id", type = IdType.ASSIGN_ID)
    @ChineseDescription("草稿id")
    private Long draftId;

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

    @TableField("definition_id")
    @ChineseDescription("流程定义id")
    private Long definitionId;

    @TableField("draft_title")
    @ChineseDescription("草稿的标题")
    private String draftTitle;

    @TableField("applicant")
    @ChineseDescription("发起人id")
    @SimpleFieldFormat(processClass = UserNameFormatProcess.class)
    private Long applicant;

    @TableField("applicant_org_id")
    @ChineseDescription("发起人的组织机构id，以哪个身份发起")
    @SimpleFieldFormat(processClass = OrgNameFormatProcess.class)
    private Long applicantOrgId;

    @TableField(value = "instance_variable", typeHandler = JacksonTypeHandler.class)
    @ChineseDescription("流程变量（包含表单数据、一些运行时数据）")
    private InstanceVariable instanceVariable;

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

}
