package com.bocloud.ims.entity.resource;

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

/**
 * 安全组实体类
 *
 * @author weiwei
 */
@Table("security_group")
@Data
public class SecurityGroup extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("group_uuid")
	private String groupUuid;
	@Column("tenant_uuid")
	private String tenantUuid;
	@Column("create_time")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;
	@Column("request_id")
	private String requestId;
	@Column("vendor_id")
	private Long vendorId;
	@Column("tenant_id")
	private Long tenantId;// 租户ID
	@Column("project_id")
	private Long projectId;// 项目ID
	@Column("user_id")
	private Long userId;
	@Column("zone_id")
	private String zoneId;
	@Column("tenant_ids")
	private String tenantIds;
	@IgnoreAll
	private String vendorName;
	@IgnoreAll
	private String tenantName;// 所属租户
	@IgnoreAll
	private String vendorType;// 平台类型
	@IgnoreAll
	private String projectName;// 所属项目
	@IgnoreAll
	private String projectVisibility;
	@Column("region_id")
	private String regionId;
	@IgnoreAll
	private String regionName;
	@Column("vpc_id")
	private Long vpcId;
	@Column("vpc_uuid")
	private String vpcUuid;
	@Column("resource_group_id")
	private Long resourceGroupId;
	@Column("aws_group_name")
	private String awsGroupName; // aws 组名

	@IgnoreAll
	private String vpcName;
	@IgnoreAll
	private String category;
	@IgnoreAll
	private String securityGroupType;
	@IgnoreAll
	private String resourceGroupUuid;
	@IgnoreAll
	private String osTenantName;
	@IgnoreAll
	private String tenantNames;
	@IgnoreAll
	private String zoneName;
	@IgnoreAll
	private String networkInterfaceNames;
	@IgnoreAll
	private String serverBindCardName;
	@IgnoreAll
	private Long serverBindCardId;
	@Column("tags")
	private String tags;
	@IgnoreAll
	private String resourceGroupName;

	//fc 纳管
	@Column("vdc_id")
	private Long vdcId;
	//fc 纳管


	public SecurityGroup() {
		super();
	}

	public SecurityGroup(String name, String remark) {
		super();
		this.setName(name);
		this.setRemark(remark);
	}

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

}
