package entities import ( "time" "github.com/google/uuid" ) type Department struct { ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"` Name string `gorm:"not null" json:"name"` Code string `json:"code,omitempty"` Path string `gorm:"not null" json:"path"` ParentDepartmentID *uuid.UUID `gorm:"type:uuid" json:"parent_department_id,omitempty"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` // Relations ParentDepartment *Department `gorm:"foreignKey:ParentDepartmentID" json:"parent_department,omitempty"` ChildDepartments []Department `gorm:"foreignKey:ParentDepartmentID" json:"child_departments,omitempty"` } func (Department) TableName() string { return "departments" }