package cn.axzo.workflow.common.model.request.bpmn.process;

import cn.axzo.workflow.common.constraint.AttachmentTypeValidator;
import cn.axzo.workflow.common.constraint.AttachmentValidator;
import cn.axzo.workflow.common.enums.AttachmentTypeEnum;
import cn.axzo.workflow.common.model.request.bpmn.task.AttachmentDTO;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 中止流程实例的入参模型
 *
 * @author wangli
 * @since 2024/1/2 17:49
 */
@ApiModel("中止流程实例的入参模型")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BpmnProcessInstanceAbortDTO {

    /**
     * 流程实例 ID
     */
    @ApiModelProperty(value = "流程实例 ID")
    @NotBlank(message = "流程实例 ID 不能为空")
    private String processInstanceId;

    /**
     * 租户 ID
     */
    @ApiModelProperty(value = "租户 ID")
    //    @NotBlank(message = "租户 ID 不能为空")
    private String tenantId;

    /**
     * 中止原因
     */
    @ApiModelProperty(value = "中止原因")
    @NotBlank(message = "中止原因不能为空")
    @Length(max = 100, message = "中止原因长度不能超过 100 个字符")
    private String reason;

    /**
     * 评论信息
     * advice 统一均为审批节点的审批意见，一般为用户在同意、驳回时填写的内容
     * 有值时，在日志中一般出现在 operationDesc 的下方
     */
    @ApiModelProperty(value = "中止意见")
    private String advice;

    /**
     * 附件列表
     */
    @ApiModelProperty(value = "附件列表")
    @Size(max = 11, message = "附件数量超过限制")
    @AttachmentValidator(types = {
            @AttachmentTypeValidator(type = AttachmentTypeEnum.image, max = 5),
            @AttachmentTypeValidator(type = AttachmentTypeEnum.file, max = 5),
            @AttachmentTypeValidator(type = AttachmentTypeEnum.signature, max = 1)}
    )
    private List<AttachmentDTO> attachmentList;

    /**
     * 中止节点的名称
     * 为空时，则默认展示为“系统中止”
     */
    @ApiModelProperty(value = "中止节点名称")
    private String nodeName;

    /**
     * 指定中止的操作人信息
     * <p>
     * 只能是 axzo 平台存在的人
     */
    @ApiModelProperty(value = "指定该动作的操作人")
    private BpmnTaskDelegateAssigner assigner;

    /**
     * 暂不生效
     * 手写签名图片地址
     */
    @ApiModelProperty(value = "手写签名url")
    @Deprecated
    private String signatureUrl;
    /**
     * 是否异步执行
     */
    @ApiModelProperty(value = "是否异步", notes = "异步时,只接收请求便返回数据")
    @Builder.Default
    private Boolean async = true;
}
