package com.bocloud.ims.entity.common;

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
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("recycled")
public class Recycled extends Generic {
    @PK(value = PKStrategy.AUTO)
    private Long id; // ID
    @Column("name")
    private String name;
    @Column("sn")
    private String sn;
    @Column("type")
    private String type;
    @Column("resource_id")
    private Long resourceId;
    @IgnoreUpdate
    @JsonSerialize(using = DateSerializer.class)
    @JsonDeserialize(using = DateDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column("gmt_create")
    private Date gmtCreate;
    @Column("creator_id")
    private Long creatorId;
    @Column("is_deleted")
    private Boolean deleted;
    @IgnoreUpdate
    @JsonSerialize(using = DateSerializer.class)
    @JsonDeserialize(using = DateDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column("gmt_modify")
    private Date gmtModify;
    @Column("mender_id")
    private Long menderId;
    @Column("project_id")
    private Long projectId;
    @Column("catalog")
    private String catalog;
    @Column("tenant_id")
    private Long tenantId;
    @Column("user_id")
    private Long userId;
    @Column("owner_id")
    private Long ownerId;
    @Column("spec")
    private String spec;

    public Recycled(String name, String sn, String type, Long resourceId, Long projectId, String catalog, String spec) {
        this.name = name;
        this.sn = sn;
        this.type = type;
        this.resourceId = resourceId;
        this.projectId = projectId;
        this.catalog = catalog;
        this.spec = spec;
    }
}
