package com.bocloud.ims.entity.resource;

import com.alibaba.fastjson.JSONArray;
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 lombok.Data;

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

	@PK(value = PKStrategy.AUTO)
	private Long id;// ID
	@Column("member_uuid")
	private String memberUuid;// 成员 ID
	@Column("tenant_uuid")
	private String tenantUuid;// 租户ID
	@Column("subnet_uuid")
	private String subnetUuid;// 子网UUID
	@Column("address")
	private String address;// 地址
	@Column("admin_stateup")
	private Boolean adminStateUp;// 管理员状态
	@Column("port")
	private Integer port;// 协议端口
	@Column("weight")
	private Integer weight;// 权重
	@Column("pool_uuid")
	private String poolUuid;// 成员池ID
	@Column("listener_id")
	private Long listenerId;// 监听器ID
	@Column("vendor_id")
	private Long vendorId;
	@Column("pool_id")
	private Long poolId;
	@Column("subnet_id")
	private Long subnetId;// 子网ID
	@Column("tenant_id")
	private Long tenantId;// 租户ID
	@Column("project_id")
	private Long projectId;// 项目ID
	@Column("region_id")
	private String regionId;
	
	@Column("lb_id")
	private Long lbId;// 负载均衡ID
	
	// 云主机id
	@Column("instance_id")
	private String instanceId;
	@IgnoreAll
	private String subnetName;// 字网名称
	@IgnoreAll
	private String tenantName;// 所属租户
	@IgnoreAll
	private String publicNetwork;
	@IgnoreAll
	private String privateNetwork;
	@IgnoreAll
	private String vpcName;
	@IgnoreAll
	private String regionName;
	@IgnoreAll
	private Long serverId;
	// 云主机信息
	@IgnoreAll
	private String zoneName;
	@IgnoreAll
	private String privateIps;
	@IgnoreAll
	private String vpcUuid;

	@IgnoreAll
	private JSONArray delObject;
	@IgnoreAll
	private JSONArray addObject;

	public LbMember() {
		super();
	}

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

	/**
	 * @param memberUuid
	 * @param tenantUuid
	 * @param subnetId
	 * @param subnetUuid
	 * @param address
	 * @param adminStateUp
	 * @param port
	 * @param weight
	 * @param poolUuid
	 * @param listenerId
	 * @param listenerUuid
	 * @param vendorId
	 */
	public LbMember(String memberUuid, String tenantUuid, Long subnetId, String subnetUuid, String address,
			Boolean adminStateUp, Integer port, Integer weight, String poolUuid, Long listenerId, Long vendorId) {
		super();
		this.memberUuid = memberUuid;
		this.tenantUuid = tenantUuid;
		this.subnetId = subnetId;
		this.subnetUuid = subnetUuid;
		this.address = address;
		this.adminStateUp = adminStateUp;
		this.port = port;
		this.weight = weight;
		this.poolUuid = poolUuid;
		this.listenerId = listenerId;
		this.vendorId = vendorId;
	}

}
