package com.bocloud.ims.entity.resource;

import com.bocloud.common.utils.DateDeserializer;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreUpdate;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.Generic;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Table("tag")
public class Tag extends Generic {
	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("tag_key")
	private String key;
	@Column("resource_id")
	private String resourceId;
	@Column("resource_type")
	private String resourceType;
	@Column("tag_value")
	private String value;
	@Column("vendor_id")
	private Long vendorId;
	@IgnoreUpdate
	@Column(value = "gmt_create", nullable = false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtCreate;
	@Column("gmt_modify")
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtModify;
	@Column("region_id")
	private String regionId;// 所属域

	public Tag(String key, String value, String resourceId) {
		super();
		this.key = key;
		this.value = value;
		this.resourceId = resourceId;
	}

	public Tag(String key, String value, String resourceId, String resourceType) {
		super();
		this.key = key;
		this.value = value;
		this.resourceId = resourceId;
		this.resourceType = resourceType;
	}
}