package com.qmth.distributed.print.business.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
import com.qmth.teachcloud.common.base.BaseEntity;
import com.qmth.teachcloud.common.enums.TFCustomModelTypeEnum;
import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
import com.qmth.teachcloud.common.util.JacksonUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * <p>
 * 自定义流程表
 * </p>
 *
 * @author wangliang
 * @since 2022-01-21
 */
@ApiModel(value = "TFCustomFlow对象", description = "自定义流程表")
public class TFCustomFlow extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty(value = "机构id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(value = "org_id", updateStrategy = FieldStrategy.IGNORED)
    private Long orgId;

    @ApiModelProperty(value = "流程名称")
    private String name;

    @ApiModelProperty(value = "模式类型，USER_FIXED：指定人员,APPROVE_SET：发起人指定")
    private TFCustomModelTypeEnum modelType;

    @ApiModelProperty(value = "流程类型，ELECTRON_FLOW：电子交卷审核，QUESTION_ELECTRON_FLOW：题库试题提交审核，PAPER_ELECTRON_FLOW：题库试卷审核")
    private TFCustomTypeEnum type;

    @ApiModelProperty(value = "是否启用，0：停用，1：启用")
    @TableField(value = "enable", updateStrategy = FieldStrategy.IGNORED)
    private Boolean enable;

    @ApiModelProperty(value = "是否发布，0：否，1：是")
    @TableField(value = "publish", updateStrategy = FieldStrategy.IGNORED)
    private Boolean publish;

    @ApiModelProperty(value = "自定义流程源数据")
    private String objectData;

    @ApiModelProperty(value = "版本号")
    private Integer version;

    @ApiModelProperty(value = "流程key")
    private String flowKey;

    @ApiModelProperty(value = "流程版本id")
    @TableField(value = "act_flow_id", updateStrategy = FieldStrategy.IGNORED)
    private String actFlowId;

    @ApiModelProperty(value = "流程过程变量数据")
    private String flowProcessVar;

    public Long getSchoolId() {
        return schoolId;
    }

    public TFCustomFlow() {

    }

    public TFCustomFlow(Long schoolId, Long orgId, String name, TFCustomTypeEnum type, Boolean publish, String objectData, Long userId, String flowKey, TFCustomModelTypeEnum modelType) {
        this.schoolId = schoolId;
        this.orgId = orgId;
        this.name = name;
        this.type = type;
        this.publish = publish;
        this.objectData = objectData;
        this.flowKey = flowKey;
        this.modelType = modelType;
        insertInfo(userId);
    }

    public void setInfo(CustomFlowSaveDto customFlowSaveDto) {
        this.setModelType(customFlowSaveDto.getModelType());
        this.setObjectData(JacksonUtil.parseJson(customFlowSaveDto.getCustomFlowLists()));
    }

    public TFCustomModelTypeEnum getModelType() {
        return modelType;
    }

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

    public String getFlowProcessVar() {
        return flowProcessVar;
    }

    public void setFlowProcessVar(String flowProcessVar) {
        this.flowProcessVar = flowProcessVar;
    }

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

    public Long getOrgId() {
        return orgId;
    }

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

    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 getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Boolean getPublish() {
        return publish;
    }

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

    public String getObjectData() {
        return objectData;
    }

    public void setObjectData(String objectData) {
        this.objectData = objectData;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getFlowKey() {
        return flowKey;
    }

    public void setFlowKey(String flowKey) {
        this.flowKey = flowKey;
    }

    public String getActFlowId() {
        return actFlowId;
    }

    public void setActFlowId(String actFlowId) {
        this.actFlowId = actFlowId;
    }
}
