package com.galaxis.manatee.entity.ding;

import com.dingtalk.api.response.OapiProcessinstanceGetResponse;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
 * @author zcj
 * @version 0.1
 * @date 2020/1/9 11:28 上午
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class DingTalkProcessInstance extends DingTalkResponse {

    /**
     * 审批流程实例Id
     */
    @Id
    @Column(length = 40)
    private String id;

    /**
     * 审批流程Id
     */
    @Column(length = 40)
    private String processInstanceId;

    /**
     * 是否和氚云同步
     */
    @Column
    private Boolean updatedInChuanyun = false;

    public DingTalkProcessInstance() {
        super();
    }

    public DingTalkProcessInstance(String id, String processInstanceId) {
        super();
        this.id = id;
        this.processInstanceId = processInstanceId;
    }

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @JsonProperty(value = "process_instance")
    private OapiProcessinstanceGetResponse.ProcessInstanceTopVo processInstance;
}
