package com.alterdekim.game.entity;

import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="postcards")
@JsonRootName(value = "item")
public class Postcard {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JacksonXmlProperty(isAttribute = true, localName = "Id")
    private Long id;

    @JacksonXmlProperty(isAttribute = true, localName = "DateSent")
    @Column(nullable = false)
    private String dateSent;

    @JacksonXmlProperty(isAttribute = true, localName = "SenderId")
    @Column(nullable = false)
    private Integer senderId;

    @Column(nullable = false)
    private Integer receiverId;

    @JacksonXmlProperty(isAttribute = true, localName = "SenderName")
    @Column(nullable = false)
    private String senderName;

    @JacksonXmlProperty(isAttribute = true, localName = "CardId")
    @Column(nullable = false)
    private Integer cardId;

    @JacksonXmlProperty(isAttribute = true, localName = "IsNew")
    @Column(nullable = false)
    @JsonSerialize(using= NumericBooleanSerializer.class)
    private Boolean isNew;
}
