package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;
import static javax.persistence.GenerationType.SEQUENCE;

@Getter
@Setter
@Entity
@Table(name = "JenisKartuDetail_M")
public class JenisKartuDetail extends BaseMaster {

	@Column(name = "nameOnCard", length = 100)
	@Caption(value = "Name On Card")
	private String nameOnCard;

	@Column(name = "cardNumber", length = 100)
	@Caption(value = "Card Number")
	private String cardNumber;

	@ManyToOne
	@JoinColumn(name = "ObjectJenisKartuFk")
	@Caption(value = "Object Jenis Kartu")
	private JenisKartu jenisKartu;

	@Column(name = "ObjectJenisKartuFk", insertable = false, updatable = false)
	private Integer jenisKartuId;

	@Column(name = "cardExpired")
	@Caption(value = "Card Expired")
	private Date cardExpired;

	@Column(name = "securityCode", length = 100)
	@Caption(value = "Security Code")
	private String securityCode;

	@Column(name = "billingAddressAlamat", length = 100)
	@Caption(value = "Billing Address Alamat")
	private String billingAddressAlamat;

	@Column(name = "kodePost", length = 100)
	@Caption(value = "Kode Pos")
	private String kodePost;

	@Column(name = "kecamatan", length = 100)
	@Caption(value = "Kecamatan")
	private String kecamatan;

	@Column(name = "kotaKabupaten", length = 100)
	@Caption(value = "Kecamatan")
	private String kotaKabupaten;

	@Column(name = "propinsi", length = 100)
	@Caption(value = "Kecamatan")
	private String propinsi;

	@ManyToOne
	@JoinColumn(name = "ObjectNegaraFk")
	@Caption(value = "Object Negara")
	private Negara negara;

	@Column(name = "ObjectNegaraFk", insertable = false, updatable = false)
	private Integer negaraiId;

	@Column(name = "emailAddress", length = 100)
	@Caption(value = "Email Address")
	private String emailAddress;

	@Column(name = "phoneNumber", length = 100)
	@Caption(value = "Phone Number")
	private String phoneNumber;

	@JsonManagedReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "jenisKartuDetail")
	private Set<AntrianPasienRegistrasiDetail> antrianPasienRegistrasiDetails = new HashSet<>();

	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "public.jeniskartudetail_m_id_seq")
	@SequenceGenerator(name = "public.jeniskartudetail_m_id_seq", sequenceName = "public.jeniskartudetail_m_id_seq", allocationSize = 1)
	@Column(name = "id")
	protected Integer id;

}