package com.friday.operation.api.keepalive.dto.smartrpa;

import com.friday.operation.api.keepalive.constant.smartrpa.ExecAction;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Author YaoYao
 * @Date Created In 18:57 2022/11/29
 * @Description 指令数据结构
 * @Modified By
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "指令数据结构")
public class ExecActionDto implements Serializable {
    /**
     * {@link ExecAction}
     */
    @ApiModelProperty(value = "指令", required = true)
    private String action;
    @ApiModelProperty(value = "唯一RPA任务id")
    private String jobId;

    boolean actionValid(){
        return ExecAction.Start.getAction().equals(action)
                || ExecAction.Terminate.getAction().equals(action)
                || ExecAction.Pause.getAction().equals(action)
                || ExecAction.Resume.getAction().equals(action)
                || ExecAction.UpdateJobState.getAction().equals(action)
                || ExecAction.SetMachineState.getAction().equals(action)
                || ExecAction.EnableLicense.getAction().equals(action)
                || ExecAction.DisableLicense.getAction().equals(action);
    }

    boolean jobIdValid(){
        try {
            Integer.parseInt(jobId);
        } catch (Exception e){
            return false;
        }
        return true;
    }
}
