package com.bocloud.ims.entity.middleware;

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;

/**
 * kvs操作日志信息类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("kvs_param_log")
public class KvsParamLog extends Generic {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("name")
	private String name;
	@Column("old_value")
	private String oldValue;
	@Column("new_value")
	private String newValue;
	@Column("gmt_create")
	@IgnoreUpdate
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtCreate;
	@Column("kvs_id")
	private Long kvsId;
	@Column("creater_id")
	private Long createrId;
	@Column("effective")
	private Boolean effective;

	public KvsParamLog(String name, String oldValue, String newValue, Date gmtCreate, Long kvsId, Long createrId,
			Boolean effective) {
		super();
		this.name = name;
		this.oldValue = oldValue;
		this.newValue = newValue;
		this.gmtCreate = gmtCreate;
		this.kvsId = kvsId;
		this.createrId = createrId;
		this.effective = effective;
	}
}