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.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

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

/**
 * 重置指定节点下的所有审批人
 *
 * @author wangli
 * @since 2025-06-24 17:07
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BpmnTaskResetApproversDTO implements Serializable {
    private static final long serialVersionUID = 4570922472032531513L;

    /**
     * 流程实例 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 = "任务提级给谁审批")
    @NotEmpty(message = "任务接收人不能为空")
    private List<BpmnTaskDelegateAssigner> targetAssignerList;

    /**
     * 任务操作人
     */
    @ApiModelProperty(value = "任务原发起人")
    @Valid
    @NotNull(message = "任务发起人不能为空")
    private BpmnTaskDelegateAssigner originAssigner;

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