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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;

/**
 * 转交审批任务的入参模型
 *
 * @author wangli
 * @since 2023/7/27 11:50
 */
@ApiModel("转交审批任务的入参模型")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BpmnTaskTransferDTO implements Serializable {

    private static final long serialVersionUID = 8142105892475867826L;

 /**
     * 流程实例 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 = "审批任务原审批人", notes = "可以为空,意义在于可以将没有指派给任何人的任务转交给其他人")
    @Valid
    private BpmnTaskDelegateAssigner originAssigner;

    /**
     * 审批任务转交给谁
     */
    @ApiModelProperty(value = "审批任务转交给谁", notes = "可以为空,意义在于如果分配给某离职的人,可能需要置为空")
    private BpmnTaskDelegateAssigner targetAssigner;

    /**
     * 转交描述
     */
    @ApiModelProperty(value = "转交描述", notes = "正常是'xx转交给xx',该字段值追加在后面")
    private String additionalOpeDesc;

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

}
