package com.alterdekim.game.entity;


import com.alterdekim.game.controller.result.api.ApiResult;
import com.alterdekim.game.controller.result.api.PromotionBannerResult;
import com.alterdekim.game.controller.result.api.PromotionResult;
import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
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="promotion_banners")
@JsonRootName(value = "i")
public class PromotionBanner implements ApiResult {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonIgnore
    private Long id;

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

    @JsonIgnore
    @Column(nullable = false)
    private Boolean isSelected;

    public PromotionBanner(Integer mrId, Boolean isSelected) {
        this.mrId = mrId;
        this.isSelected = isSelected;
    }

    @Override
    public PromotionBannerResult toAPIResult() {
        return new PromotionBannerResult(this.id, this.mrId, this.isSelected);
    }
}
