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 cn.axzo.workflow.common.valid.group.ValidGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

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

/**
 * 取消流程实例的入参模型
 *
 * @author wangli
 * @since 2023/7/17 09:34
 */
@ApiModel("取消流程实例的入参模型")
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class BpmnProcessInstanceCancelDTO {

    /**
     * 流程实例的编号
     */
    @ApiModelProperty(value = "流程实例编号", example = "11")
    @NotBlank(message = "流程实例编号不能为空", groups = {ValidGroup.Insert.class, ValidGroup.Update.class})
    private String processInstanceId;

    /**
     * 工作台 ID
     */
    @ApiModelProperty(value = "工作台 ID")
    @NotBlank(message = "工作台不能为空", groups = ValidGroup.Insert.class)
    private String tenantId;

    /**
     * 取消原因
     */
    @ApiModelProperty(value = "撤回的原因", example = "主动撤回")
    private String reason;

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

    /**
     * 撤回节点的名称
     * 为空时，则默认展示为“发起人撤回”
     */
    @ApiModelProperty(value = "撤回节点名称")
    private String nodeName;

    /**
     * 发起人的信息
     */
    @ApiModelProperty(value = "审批流程发起人信息")
    @Valid
    @NotNull(message = "审批流程的发起人不能为空", groups = {ValidGroup.Insert.class, ValidGroup.Update.class})
    private BpmnTaskDelegateAssigner initiator;


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

}
