package com.bocloud.ims.entity.resource;

import com.bocloud.common.model.RequestContext.Catalog;
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.Generic;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 资源监听事件
 * 
 * @author wangyu
 * @version 1.0
 * @since 2020年6月4日
 *
 */
@NoArgsConstructor
@Table("resource_event")
public class ResourceEvent extends Generic {

	@Setter
	@Getter
	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Setter
	@Getter
	@Column("resource_id")
	private Long resourceId; // 资源ID
	@Setter
	@Getter
	@Column("resource_name")
	private String resourceName;
	@Setter
	@Getter
	@Column("content")
	private String content; // 操作内容
	@Setter
	@Getter
	@Column("result")
	private String result;// 操作结果
	@Setter
	@Getter
	@Column("operator_id")
	private Long operatorId; // 操作者ID
	@Setter
	@Getter
	@Column("gmt_operate")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtOperate;
	@Setter
	@Getter
	@Column("target")
	private String target; // 操作对象
	@Setter
	@Getter
	@Column("operation")
	private String operation; // 操作对象
	@Setter
	@Getter
	@Column("vendor_id")
	private Long vendorId;// 云平台id
	@Setter
	@Getter
	@Column("catalog")
	private Catalog catalog;// 账号类别
	@Setter
	@Getter
	@IgnoreAll
	private String operator; // 操作者

	public ResourceEvent(Long resourceId, String content, String result, Long operatorId, Date gmtOperate,
			String target, Long vendorId, Catalog catalog) {
		super();
		this.resourceId = resourceId;
		this.content = content;
		this.result = result;
		this.operatorId = operatorId;
		this.gmtOperate = gmtOperate;
		this.target = target;
		this.vendorId = vendorId;
		this.catalog = catalog;
	}
}
