package com.qmth.distributed.print.business.bean.flow;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.distributed.print.business.entity.TFCustomFlow;
import com.qmth.teachcloud.common.enums.TFCustomModelTypeEnum;
import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;

/**
 * @Description: 自定义流程save dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/1/21
 */
public class CustomFlowPropDto implements Serializable {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "自定义流程id")
    Long customFlowId;

    @ApiModelProperty(value = "id")
    @NotBlank(message = "流程名称")
    String name;

    @ApiModelProperty(value = "流程模式")
    @NotNull(message = "流程模式不能为空")
    TFCustomModelTypeEnum modelType;

    @ApiModelProperty(value = "流程类型")
    @NotNull(message = "流程类型不能为空")
    TFCustomTypeEnum type;

    @ApiModelProperty(value = "是否发布，0：否，1：是")
    Boolean publish;

    @ApiModelProperty(value = "学校id")
    @JsonSerialize(using = ToStringSerializer.class)
    Long schoolId;

    @ApiModelProperty(value = "机构id")
    @JsonSerialize(using = ToStringSerializer.class)
    Long orgId;

    public CustomFlowPropDto(){

    }

    public CustomFlowPropDto(TFCustomFlow tfCustomFlow){
        this.customFlowId = tfCustomFlow.getId();
        this.name = tfCustomFlow.getName();
        this.modelType = tfCustomFlow.getModelType();
        this.type = tfCustomFlow.getType();
        this.publish = tfCustomFlow.getPublish();
        this.schoolId = tfCustomFlow.getSchoolId();
        this.orgId = tfCustomFlow.getOrgId();
    }

    public void setSchoolAndOrgInfo(Long schoolId, Long orgId) {
        this.schoolId = schoolId;
        this.orgId = orgId;
    }


    public TFCustomModelTypeEnum getModelType() {
        return modelType;
    }

    public void setModelType(TFCustomModelTypeEnum modelType) {
        this.modelType = modelType;
    }

    public Long getCustomFlowId() {
        return customFlowId;
    }

    public void setCustomFlowId(Long customFlowId) {
        this.customFlowId = customFlowId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TFCustomTypeEnum getType() {
        return type;
    }

    public void setType(TFCustomTypeEnum type) {
        this.type = type;
    }

    public Boolean getPublish() {
        return publish;
    }

    public void setPublish(Boolean publish) {
        this.publish = publish;
    }

    public Long getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(Long schoolId) {
        this.schoolId = schoolId;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CustomFlowPropDto that = (CustomFlowPropDto) o;
        return type == that.type && schoolId.equals(that.schoolId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, schoolId);
    }

    @Override
    public String toString() {
        return "CustomFlowSaveDto{" +
                "type=" + type +
                ", schoolId=" + schoolId +
                '}';
    }
}
