package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseActive;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import javax.validation.constraints.Size;

import java.io.Serializable;

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

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 12/06/2024
 */
@Getter
@Setter
@Entity
@Table(name = "berkasoperasi_m", schema = "public")
public class BerkasOperasi extends BaseActive implements Serializable {

	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "sg_berkasoperasi")
	@SequenceGenerator(name = "sg_berkasoperasi", schema = "public", sequenceName = "public.berkasoperasi_m_seq", allocationSize = 1)
	@Column(name = "id", columnDefinition = "bigint default nextval('public.berkasoperasi_m_seq'::regclass)")
	protected Long id;

	@Column(name = "berkasoperasi", length = 150, unique = true, nullable = false)
	@Size(max = 150, message = "Berkas operasi maksimal {max} karakter")
	@NotBlank(message = "Berkas operasi tidak boleh kosong")
	@Caption("Berkas Operasi")
	private String berkasOperasi;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "kelompokuserfk")
	@Caption(value = "Kelompok User")
	private KelompokUser kelompokUser;

	@Column(name = "kelompokuserfk", insertable = false, updatable = false)
	private Integer kelompokUserId;
}
