package cn.estsh.i3plus.pojo.mdm.bean.master;

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MdmEnumUtil;
import cn.estsh.i3plus.pojo.mdm.bean.base.BaseMdmBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description : 主数据齿轮
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2020-05-12 18:09
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="MDM_SYNC_DATA_THROUGH")
@ApiModel("处理以通过中心同步数据")
public class MdmSyncDataThrough extends BaseMdmBean {

    private static final long serialVersionUID = -1642626000861174060L;

    @ApiParam("同步数据类型")
    @AnnoOutputColumn(refClass = MdmEnumUtil.MDM_SYNC_TYPE.class)
    private Integer syncType;

    public int getSyncTypeVal() {
        return syncType == null ? MdmEnumUtil.MDM_SYNC_TYPE.INSERT.getValue() : syncType;
    }

    public String getSyncTypeTxt() {
        return syncType == null ? "无" : MdmEnumUtil.MDM_SYNC_TYPE.valueOfDescription(syncType);
    }

    @ApiParam("同步模块")
    @AnnoOutputColumn(refClass = MdmEnumUtil.MDM_SYNC_APP_TYPE.class)
    private Integer syncAppType;

    public int getSyncAppTypeVal() {
        return syncAppType == null ? MdmEnumUtil.MDM_SYNC_APP_TYPE.INTERNAL.getValue() : syncAppType;
    }

    public String getSyncAppTypeTxt() {
        return syncAppType == null ? "无" : MdmEnumUtil.MDM_SYNC_APP_TYPE.valueOfDescription(syncAppType);
    }

    @ApiParam("同步模块")
    private Long syncSoftType;

    @ApiParam("同步模块名称")
    private String syncSoftTypeName;

    @ApiParam("是否是主数据")
    @AnnoOutputColumn(refClass = CommonEnumUtil.TRUE_OR_FALSE.class)
    private Integer isMasterData;

    public int getIsMasterDataVal() {
        return isMasterData == null ? CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue() : isMasterData;
    }

    public String getIsMasterDataTxt() {
        return isMasterData == null ? "无" : CommonEnumUtil.TRUE_OR_FALSE.valueOfDescription(isMasterData);
    }

    @ApiParam("同步数据class")
    private String syncDataClass;

    public String getSyncDataClassSimpleName() {
        if (syncDataClass == null) {
            return null;
        }

        return syncDataClass.trim().substring(syncDataClass.trim().lastIndexOf(".") + 1);
    }

    @ApiParam("同步数据id")
    @AnnoOutputColumn(hidden = true)
    private String syncDataId;

    @ApiParam("同步数据用户名")
    private String syncDateUserName;

    @ApiParam("同步时间")
    private String syncDateTime;

    @ApiParam("同步失败键")
    private String syncFailKey;

    @ApiParam("同步失败时间")
    private String syncFailDateTime;

    @ApiParam("同步失败信息")
    private String syncFailMessage;


}
