package com.gcsc.connection.service.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_api_domain", schema = "common")
public class SnpApiDomain extends BaseEntity {

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

    @Column(name = "domain_name", length = 100, unique = true, nullable = false)
    private String domainName;

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

    @Column(name = "sort_order", nullable = false)
    private Integer sortOrder = 0;

    @Builder
    public SnpApiDomain(String domainName, String iconPath, Integer sortOrder) {
        this.domainName = domainName;
        this.iconPath = iconPath;
        this.sortOrder = sortOrder != null ? sortOrder : 0;
    }

    public void update(String domainName, String iconPath, Integer sortOrder) {
        if (domainName != null) this.domainName = domainName;
        if (iconPath != null) this.iconPath = iconPath;
        if (sortOrder != null) this.sortOrder = sortOrder;
    }
}
