package com.bocloud.ims.entity.resource;

import com.bocloud.common.model.RequestContext.Catalog;
import com.bocloud.common.utils.DaySerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * openstack浮动IP类
 *
 * @author wangyu
 * @version 1.0
 * @since 2017年8月28日
 */
@Table("floating_ip")
@Data
public class FloatingIp extends GenericEntity {

    @PK(value = PKStrategy.AUTO)
    private Long id;
    @Column("floating_ip_uuid")
    private String floatingIpUuid;
    @Column("router_uuid")
    private String routerUuid;
    @Column("tenant_uuid")
    private String tenantUuid;
    @Column("floating_network_uuid")
    private String floatingNetworkUuid;
    @Column("floating_ip_address")
    private String floatingIpAddress;
    @Column("fixed_ip_address")
    private String fixedIpAddress;
    @Column("port_uuid")
    private String portUuid;
    @Column("uuid")
    private String uuid;
    @Column("router_id")
    private Long routerId;
    @Column("port_id")
    private Long portId;
    @Column("network_id")
    private Long networkId;
    @Column("vendor_id")
    private Long vendorId;
    @Column("tenant_id")
    private Long tenantId;// 租户ID
    @Column("project_id")
    private Long projectId;// 项目ID
    @Column("instance_id")
    private String instanceId;
    @Column("networkcard_uuid")
    private String networkCardUuid;
    @Column("resource_label")
    private String resourceLabel; //标签
    @IgnoreAll
    private String vendorName;
    @IgnoreAll
    private String networkName;
    @IgnoreAll
    private String tenantName;// 租户名称
    @IgnoreAll
    private String projectName;// 项目名称
    @IgnoreAll
    private String projectVisibility;
    @IgnoreAll
    private String targetName;// 租户用户

    @IgnoreAll
    private String userName;// 用户名称
    @IgnoreAll
    private String businessName;// 业务
    @IgnoreAll
    private String creatorName;// 创建者名称
    @IgnoreAll
    private String ownerName;// 所属人名称
    @IgnoreAll
    private String menderName;// 维护人名称

    @IgnoreAll
    private List<Port> ports;
    @Column("region_id")
    private String regionId;
    @IgnoreAll
    private String regionName;
    @IgnoreAll
    private Integer count;
    @IgnoreAll
    private String serverName;
    @IgnoreAll
    private String osTenantName;// openstack底层租户
    @IgnoreAll
    private String resourceGroupUuid;
    @IgnoreAll
    private String vendorType;

    @Column("business_id")
    private Long businessId;
    @Column("catalog")
    private Catalog Catalog;// 账号类别
    @Column("expired_time")
    @JsonSerialize(using = DaySerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expiredTime;// 过期时间

    public void preSave(Long creatorId, Long menderId, Long vendorId, Long networkId, Long tenantId, Long projectId) {
        this.setCreatorId(creatorId);
        this.setMenderId(menderId);
        this.setVendorId(vendorId);
        this.setNetworkId(networkId);
        this.setTenantId(tenantId);
        this.setProjectId(projectId);
    }

}
