package com.gcsc.connection.tenant.entity;

import com.gcsc.connection.common.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@Entity
@Table(name = "snp_tenant", schema = "common")
public class SnpTenant extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "tenant_id")
    private Long tenantId;

    @Column(name = "tenant_code", length = 50, nullable = false, unique = true)
    private String tenantCode;

    @Column(name = "tenant_name", length = 200, nullable = false)
    private String tenantName;

    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    @Builder
    public SnpTenant(String tenantCode, String tenantName, String description, Boolean isActive) {
        this.tenantCode = tenantCode;
        this.tenantName = tenantName;
        this.description = description;
        this.isActive = isActive != null ? isActive : true;
    }

    public void update(String tenantName, String description, Boolean isActive) {
        this.tenantName = tenantName;
        this.description = description;
        if (isActive != null) this.isActive = isActive;
    }
}
