package cn.axzo.workflow.core.repository.entity;

import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
import cn.axzo.workflow.common.model.dto.OrgStructureSnapshotInfo;
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonConf;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.request.form.FormPermissionMetaInfo;
import cn.axzo.workflow.core.conf.handler.ButtonConfTypeHandler;
import cn.axzo.workflow.core.conf.handler.ListAssigneeTypeHandler;
import cn.axzo.workflow.core.conf.handler.ListFormFieldPermissionTypeHandler;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Date;
import java.util.List;

/**
 * 审批日志
 *
 * @author wangli
 * @since 2024-08-30 15:29
 */
@EqualsAndHashCode(callSuper = true)
@TableName(value = "ext_ax_process_log", autoResultMap = true)
@Data
@ToString(callSuper = true)
public class ExtAxProcessLog extends BaseEntity<ExtAxProcessLog> {

    private static final long serialVersionUID = 461756492937079852L;
    
    /**
     * 流程实例 ID
     */
    private String processInstanceId;
    /**
     * 实例归属租户
     */
    private String tenantId;
    /**
     * 活动节点 ID
     */
    private String activityId;
    /**
     * 活动节点名称
     */
    private String activityName;
    /**
     * 审批方式:配置审批人/业务指定/业务触发(不含人)
     */
    private String approvalMethod;
    /**
     * 节点类型:审批节点/业务节点/评论节点/抄送节点
     */
    private String nodeType;
    /**
     * 节点模式:会签/或签
     */
    private String nodeMode;
    /**
     * 任务 ID
     */
    private String taskId;
    /**
     * 操作建议
     */
    private String advice;
    /**
     * 操作描述
     */
    private String operationDesc;
    /**
     * 审批人对象信息
     */
    @TableField(value = "assignee_full", typeHandler = ListAssigneeTypeHandler.class)
    private List<BpmnTaskDelegateAssigner> assigneeFull;
    /**
     * 审批人标识
     */
    private Long assigneeId;
    /**
     * 审批人归属租户
     */
    private String assigneeTenantId;
    /**
     * 审批人姓名
     */
    private String assigneeName;
    /**
     * 审批人归属单位
     */
    private String assigneeOuId;
    /**
     * 任务开始时间
     */
    private Date startTime;
    /**
     * 任务结束时间
     */
    private Date endTime;
    /**
     * 节点按钮的全量配置
     */
    @TableField(typeHandler = ButtonConfTypeHandler.class)
    private BpmnButtonConf buttonConf;
    /**
     * 表单字段权限配置
     */
    @TableField(typeHandler = ListFormFieldPermissionTypeHandler.class)
    private List<FormPermissionMetaInfo> formFieldPermissionConf;
    /**
     * 任务状态:审批中/通过/驳回/转交/加签/回退
     */
    private String status;

    /**
     * 电子签名状态, true: 为开启
     */
    private Boolean signature;
    /**
     * 扩展字段
     */
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private OrgStructureSnapshotInfo extra;
}
