package com.alterdekim.game.entity;

import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
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="phone_messages")
@JsonRootName(value = "item")
public class PhoneMessage {
    @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;

    @JsonIgnore
    @Column(nullable = false)
    private Integer receiverId;

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

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

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