package com.bocloud.ims.entity.resource;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.common.model.RequestContext.Catalog;
import com.bocloud.common.utils.DateSerializer;
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;

/**
 * 负载均衡器实体类
 *
 * @author wangyu
 * @version 1.0
 * @since 2017年8月29日
 */
@Table("load_balancer")
@Data
public class LoadBalancer extends GenericEntity {

    @PK(value = PKStrategy.AUTO)
    private Long id;// ID
    @Column("lb_uuid")
    private String lbUuid;// 负载均衡器ID
    @Column("fee_type")
    private Integer feeType;// 资费类别
    @Column("subnet_id")
    private Long subnetId;// 子网ID
    @Column("subnet_uuid")
    private String subnetUuid;// 子网UUID
    @Column("tenant_uuid")
    private String tenantUuid;// 租户
    @Column("vip_address")
    private String vipAddress;// vip地址
    @Column("vip_port_uuid")
    private String vipPortUuid;// vip端口ID
    @Column("admin_stateup")
    private Boolean adminStateUp;// 管理状态
    @Column("provisioning_status")
    private String provisioningStatus;// 准备状态
    @Column("operating_status")
    private String operatingStatus;// 操作状态
    @Column("provider")
    private String provider;// 供应者
    @Column("vendor_id")
    private Long vendorId;// 云平台ID
    @Column("port_id")
    private Long portId;// 端口ID
    @Column("tenant_id")
    private Long tenantId;// 租户ID
    @Column("project_id")
    private Long projectId;// 项目ID
    @Column("vpc_id")
    private Long vpcId;
    @Column("vpc_uuid")
    private String vpcUuid;
    @Column("region")
    private String region;
    @Column("scheme")
    private String scheme;
    @Column("ip_address_type")
    private String ipAddressType;
    @Column("load_balancer_type")
    private String loadBalancerType;
    @Column("availability_zones")
    private Object availabilityZones;
    @Column("security_groups")
    private Object securityGroups;
    @Column("labels")
    private String labels;
    @Column("business_id")
    private Long businessId;
    @IgnoreAll
    private int listenerNum;// 监听器总数
    @IgnoreAll
    private String floatingIpAddress;// 浮动IP
    @IgnoreAll
    private Long fipId;
    @IgnoreAll
    private String vendorName;
    @IgnoreAll
    private String tenantName;
    @IgnoreAll
    private String osTenantName;
    @IgnoreAll
    private String regionName;
    @IgnoreAll
    private String userName;// 用户名称
    @IgnoreAll
    private String businessName;// 业务
    @IgnoreAll
    private String creatorName;// 创建者名称
    @IgnoreAll
    private String ownerName;// 所属人名称
    @IgnoreAll
    private String menderName;// 维护人名称
    @IgnoreAll
    private String projectName;// 所属项目

    @Column("expired_time")
    @JsonSerialize(using = DaySerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expiredTime;// 过期时间
    @Column("uuid")
    private String uuid;// uuid，对应子订单号
    @Column("catalog")
    private Catalog catalog;// 账号类别

    @Column("spec")
    private String spec;
    @Column("resource_group_id")
    private Long resourceGroupId;
    @Column("resource_group_uuid")
    private String resourceGroupUuid;// 资源组id
    @Column("network_type")
    private String networkType;
    @Column("delete_protection")
    private String deleteProtection;
    @Column("internet_charge_type")
    private String internetChargeType; // 公网计费方式
    @Column("broadband_value")
    private Long broadbandValue;// 公网宽带值
    @Column("modification_protection")
    private String modificationProtection;
    @Column("modification_protection_reason")
    private String modificationProtectionReason;// 配置修改保护描述
    @IgnoreAll
    private String resourceGroupName;
    @IgnoreAll
    private String vipSubnetUuid;// vipV4子网ID
    @IgnoreAll
    private String action;
    //火山云
    @IgnoreAll
    private String vpcName;// 私有网络名称
    @IgnoreAll
    private String eipType;// 浮动ip线路类型
    @Column("elastic_ip_address")
    private String elasticIpAddress;// 浮动IP
    @Column("eip_id")
    private Long eipId;

    @Column("elastic_ip_id")
	private Long elasticIpId;
    @Column("after_subnet_uuid")
	private String afterSubnetUuid;
	@Column("create_time")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;
    
    public LoadBalancer() {
        super();
    }

    public void preSave(Long creatorId, Long menderId, Long vendorId, Long subnetId, Long portId, Long tenantId,
                        Long projectId) {
        this.setCreatorId(creatorId);
        this.setMenderId(menderId);
        this.setVendorId(vendorId);
        this.setSubnetId(subnetId);
        this.setPortId(portId);
        this.setTenantId(tenantId);
        this.setProjectId(projectId);
    }

    /**
     * @param lbUuid
     * @param feeType
     * @param subnetUuid
     * @param tenantUuid
     * @param vipAddress
     * @param vipPortUuid
     * @param adminStateUp
     * @param provisioningStatus
     * @param operatingStatus
     * @param provider
     */
    public LoadBalancer(String lbUuid, Integer feeType, String subnetUuid, String tenantUuid, String vipAddress,
                        String vipPortUuid, Boolean adminStateUp, String provisioningStatus, String operatingStatus,
                        String provider) {
        super();
        this.lbUuid = lbUuid;
        this.feeType = feeType;
        this.subnetUuid = subnetUuid;
        this.tenantUuid = tenantUuid;
        this.vipAddress = vipAddress;
        this.vipPortUuid = vipPortUuid;
        this.adminStateUp = adminStateUp;
        this.provisioningStatus = provisioningStatus;
        this.operatingStatus = operatingStatus;
        this.provider = provider;
    }

}
