package com.example.demo.directions.model;

import java.util.Objects;

import com.example.demo.core.model.BaseEntity;
import com.example.demo.department.model.DepartmentEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "directions")
public class DirectionsEntity extends BaseEntity {
    @Column(nullable = false, unique = true, length = 9)
    private String code;
    @Column(nullable = false, unique = false, length = 80)
    private String name;
    @ManyToOne
    @JoinColumn(name = "departmentId", nullable = false)
    private DepartmentEntity department;
    @Column(nullable = true, unique = false, length = 80)
    private String things;

    public DirectionsEntity() {
    }

    public DirectionsEntity(String code, String name, DepartmentEntity department, String things) {
        this.code = code;
        this.name = name;
        this.department = department;
        this.things = things;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public DepartmentEntity getDepartment() {
        return department;
    }

    public void setDepartment(DepartmentEntity department) {
        this.department = department;
    }

    public String getThings() {
        return things;
    }

    public void setThings(String things) {
        this.things = things;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, code);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null || getClass() != obj.getClass())
            return false;
        final DirectionsEntity other = (DirectionsEntity) obj;
        return Objects.equals(other.getId(), id)
                && Objects.equals(other.getCode(), code)
                && Objects.equals(other.getName(), name)
                && Objects.equals(other.getDepartment(), department)
                && Objects.equals(other.getThings(), things);
    }
}
