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

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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.List;

/**
 * @Description : 数据中心同步数据
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2020-06-02 16:14
 * @Modify:
 **/
@Data
@ApiModel("数据中心同步数据")
public class MdmSyncData<T> implements Serializable {

    private static final long serialVersionUID = -1642626000860074060L;

    @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")
    private List<Long> syncDataId;

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

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

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

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

    @ApiParam("同步失败信息")
    private String syncFailMessage;
    
    @ApiParam("同步数据值")
    private List<T> syncData;

}
