package com.foxedu.basecms.domain;

import java.io.Serializable;
import java.util.Objects;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

/**
 * 롤 계층구조 복합키
 */
@Embeddable
public class RoleHierarchyId implements Serializable {

    @Column(name = "PARENT_ROLE", nullable = false)
    private Integer parentRole;

    @Column(name = "CHILD_ROLE", nullable = false)
    private Integer childRole;

    public RoleHierarchyId() {
    }

    public RoleHierarchyId(Integer parentRole, Integer childRole) {
        this.parentRole = parentRole;
        this.childRole = childRole;
    }

    public Integer getParentRole() {
        return parentRole;
    }

    public void setParentRole(Integer parentRole) {
        this.parentRole = parentRole;
    }

    public Integer getChildRole() {
        return childRole;
    }

    public void setChildRole(Integer childRole) {
        this.childRole = childRole;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RoleHierarchyId)) {
            return false;
        }
        RoleHierarchyId that = (RoleHierarchyId) o;
        return Objects.equals(parentRole, that.parentRole) && Objects.equals(childRole, that.childRole);
    }

    @Override
    public int hashCode() {
        return Objects.hash(parentRole, childRole);
    }
}
