package cn.estsh.i3plus.pojo.platform.bean;


import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Map;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 20-4-20 上午9:46
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_POJO_VERSION",indexes = {
    @Index(name="index_sys_pojo_version_ref_id",columnList = "REF_ID"),
    @Index(name="index_sys_pojo_version_ref_class",columnList = "REF_CLASS"),
})
@Api(value="对象历史")
public class SysPojoVersion extends BaseBean {

    private static final long serialVersionUID = -2265406135818649545L;
    @Column(name="SOFT_TYPE")
    @ApiParam(value ="产品类型")
    private Integer softType;

    public String getSoftTypeTxt() {
        return softType == null ? null : CommonEnumUtil.SOFT_TYPE.valueOfDescription(softType);
    }

    @Column(name="PLAN_ID")
    @ApiParam(value ="对象计划id" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long planId;

    @Column(name="REF_ID")
    @ApiParam(value ="对象id" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long refId;

    @Column(name="REF_CLASS")
    @ApiParam(value ="记录对象")
    private String refClass;

    @Column(name="VERSION_NO")
    @ApiParam(value ="记录对象版本号")
    private Integer versionNo = 0;

    @Column(name="operateType")
    @ApiParam(value ="操作类型")
    private Integer operateType;
    public String getOperateTypeTxt() {
        return operateType == null ? null : CommonEnumUtil.DAO_OPERATE_TYPE.valueOf(operateType);
    }

    @Column(name="VERSION_METHOD_NAME")
    @ApiParam(value ="操作方法名称")
    private String versionMethodName;

    @Column(name="POJO_DETAIL_ID")
    @ApiParam(value ="对象明细id" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pojoDetailId;

    @Lob
    @Column(name="POJO_COMPARE")
    @ApiParam(value ="记录对象对比差异")
    private String pojoCompare;

    @Lob
    @Column(name="POJO_COMPARE_TXT")
    @ApiParam(value ="记录对象对比差异")
    private String pojoCompareTxt;

    @Transient
    @ApiParam(value ="用户部门信息")
    private SysPojoVersionDetail versionDetail;

    @Transient
    @ApiParam(value ="操作对象本身")
    private String bean;

    @Transient
    @ApiParam(value ="操作对象属性描述")
    private Map<String, String> pojoPropDesc;
}
