package com.bocloud.ims.entity.resource;

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;

/**
 * 路由
 *
 * @author oywl
 */
@Table("router")
@Data
public class Router extends GenericEntity {
    @PK(value = PKStrategy.AUTO)
    private Long id; // ID
    @Column("router_uuid")
    private String routerUuid;// 路由uuid
    @Column("admin_stateup")
    private Boolean adminStateup;// 管理员状态
    @Column("network_uuid")
    private String networkUuid;// 网关端口ID
    @Column("enable_snat")
    private Boolean enableSnat;// snat 有snat true， 默认tr
    @Column("ha")
    private Boolean ha;// 高可用
    @Column("availability_zones")
    private String availabilityZones;// 可用域
    @Column("project_uuid")
    private String projectUuid;
    @Column("tenant_uuid")
    private String tenantUuid;
    @Column("vendor_id")
    private Long vendorId; // 云供应商ID
    @Column("network_id")
    private Long networkId; // 网络ID
    @Column("firewall_id")
    private Long firewallId;// 防火墙ID
    @Column("firewall_uuid")
    private String firewallUuid;// 防火墙UUID
    @Column("tenant_id")
    private Long tenantId;// 租户ID
    @Column("project_id")
    private Long projectId;// 项目ID
    @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
    @JsonSerialize(using = DaySerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expiredTime;// 过期时间
    @Column("guid")
    private String guid;// 全局唯一标识
    @Column("region_id")
    private String regionId;
    @IgnoreAll
    private String regionName;
    @IgnoreAll
    private String osTenantName;
    @Column("vpc_id")
    private Long vpcId;

    @Column("route_table_ids")
    private String routeTableIds;
    @IgnoreAll
    private List<Subnet> subnets;
    @IgnoreAll
    @Column("vendor_type")
    private String vendorType;
    @Column("router_table_id")
    private Long routerTableId;//路由表Id
    @Column("resource_group_Id")
    private Long resourceGroupId;//资源组id
    @Column("next_hop_type")
    private String nextHopType;//下一跳类型
    @Column("next_hop_ip_address")
    private String nextHopIpAddress;//下一跳地址
    @Column("address_prefix")
    private String addressPrefix;//地址前缀

    public Router() {
        super();
    }

    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);
    }

    /**
     * @param routerUuid
     * @param adminStateup
     * @param networkUuid
     * @param enableSnat
     * @param ha
     * @param availabilityZones
     * @param projectUuid
     * @param tenantUuid
     * @param vendorId
     * @param networkId
     * @param firewallId
     * @param firewallUuid
     */
    public Router(String routerUuid, Boolean adminStateup, String networkUuid, Boolean enableSnat, Boolean ha,
                  String availabilityZones, String projectUuid, String tenantUuid, Long vendorId, Long networkId,
                  Long firewallId, String firewallUuid) {
        super();
        this.routerUuid = routerUuid;
        this.adminStateup = adminStateup;
        this.networkUuid = networkUuid;
        this.enableSnat = enableSnat;
        this.ha = ha;
        this.availabilityZones = availabilityZones;
        this.projectUuid = projectUuid;
        this.tenantUuid = tenantUuid;
        this.vendorId = vendorId;
        this.networkId = networkId;
        this.firewallId = firewallId;
        this.firewallUuid = firewallUuid;
    }


}
