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

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.enums.BpmnFlowNodeType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 审批任务节点的入参模型
 *
 * @author wangli
 */
@ApiModel("审批任务节点的入参模型")
@Data
@Validated
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BpmnTaskAuditDTO {
    /**
     * 流程实例 ID
     * <p>
     * 与审批任务 ID 二选一
     */
    @ApiModelProperty(value = "流程实例编号", required = true, example = "1024")
    private String processInstanceId;

    /**
     * 审批任务 ID
     * <p>
     * 与流程实例 ID 二选一，如果两属性都传，则优先使用 taskId
     */
    @ApiModelProperty(value = "任务编号", required = true, example = "1024")
    private String taskId;

    /**
     * 评论信息
     */
    @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 = "手写签名url")
    private String signatureUrl;

    /**
     * 当前审核人信息
     */
    @ApiModelProperty(value = "当前审核人信息", notes = "可为空,则该任务不验证用户归属")
    @Valid
    @NotNull(message = "审批人不能为空")
    private BpmnTaskDelegateAssigner approver;

    /**
     * 下级审批人
     */
    @ApiModelProperty(value = "下级审批人信息", notes = "可为空,定义选择审批人,如果不为空,则覆盖下一级任务的审核人")
    //    @Valid
    private BpmnTaskDelegateAssigner nextApprover;

    /**
     * 是否异步执行
     */
    @ApiModelProperty(value = "是否异步", notes = "异步时,只接收请求便返回数据")
    @Builder.Default
    private Boolean async = true;

    /**
     * 指定节点类型
     */
    @ApiModelProperty(value = "指定节点类型", notes = "指定节点类型，类型不匹配抛出异常")
    @Deprecated
    private List<BpmnFlowNodeType> nodeTypes;

    /**
     * 操作描述，该属性为流程服务内部使用
     */
    @Deprecated
    private String operationDesc;
}
