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;

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

    @PK(value = PKStrategy.AUTO)
    private Long id;
    @Column("target")
    private String object;
    @Column("action")
    private String action;
    @Column("result")
    private String result;
    @Column("response_ip")
    private String responseIp;
    @Column("request_ip")
    private String requestIp;
    @Column("gmt_create")
    @IgnoreUpdate
    @JsonSerialize(using = DateSerializer.class)
    @JsonDeserialize(using = DateDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtCreate;
    @Column("cost")
    private Long cost;
    @Column("rds_id")
    private Long rdsId;
    @Column("creater_id")
    private Long createrId;

    public RdsLog(String object, String action, String result, String responseIp, String requestIp, Date gmtCreate,
                  Long cost, Long rdsId, Long createrId) {
        super();
        this.object = object;
        this.action = action;
        this.result = result;
        this.responseIp = responseIp;
        this.requestIp = requestIp;
        this.gmtCreate = gmtCreate;
        this.cost = cost;
        this.rdsId = rdsId;
        this.createrId = createrId;
    }
}