package com.bocloud.ims.entity.resource;

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 dongkai
 */
@Table("resource")
@Data
public class Resource extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("category")
	private String category; // 类型（大类）
	@Column("catalog")
	private String catalog; // 类型（小类）
	@Column("target")
	private Long target; // 目标机器ID
	@Column("private_ips")
	private String privateIps; // 私有IP
	@Column("vendor_id")
	private Long vendorId;// 云供应商Id
	@Column("username")
	private String username;// 用户名
	@Column("password")
	private String password;// 密码
	@Column("inventory")
	private String inventory;//
	@Column("is_accurated")
	private Boolean accurated;
	@Column("is_authed")
	private Boolean authed;
	@Column("resource_group")
	private String resourceGroup;
	@Column("os_category")
	private String osCategory; // 操作系统类型
	@Column("tenant_id")
	private Long tenantId;// 租户ID
	@Column("group_id")
	private Long groupId; // 资源池分组
	@Column("group_ids")
	private String groupIds;
	@Column("type_id")
	private Long typeId; // 资源类型
	@Column("project_id")
	private Long projectId;
	@Column("uuid")
	private String uuid;
	@IgnoreAll
	private String resourceGroupName;
	@IgnoreAll
	private String vendorName;
	@IgnoreAll
	private String rootVolumeUuid;
	@IgnoreAll
	private String tenantName;
	@IgnoreAll
	private String ownerName; // 根据ownerId查询
	@IgnoreAll
	private String groupName;
	@IgnoreAll
	private String groupsName;
	@Column("region_id")
	private String regionId;

	public Resource() {
		super();
	}

	public Resource(String category, String catalog, Long target, String privateIps, String osCategory, Long vendorId) {
		this.category = category;
		this.catalog = catalog;
		this.target = target;
		this.privateIps = privateIps;
		this.osCategory = osCategory;
		this.vendorId = vendorId;
	}

	public void preSave(String name, String status, Long userId, Long tenantId) {
		this.setName(name);
		this.setStatus(status);
		this.setCreatorId(userId);
		this.setMenderId(userId);
		this.setOwnerId(userId);
		this.setTenantId(tenantId);
	}

	public void preSave(String name, String status, Long userId, Long tenantId, Long projectId) {
		this.setName(name);
		this.setStatus(status);
		this.setCreatorId(userId);
		this.setMenderId(userId);
		this.setOwnerId(userId);
		this.setTenantId(tenantId);
		this.setProjectId(projectId);
	}

}
