53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
type BaseModel struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
DeletedAt sql.NullTime `json:"deletedAt,omitempty" gorm:"index"`
|
|
}
|
|
|
|
type Company struct {
|
|
BaseModel
|
|
Name string `json:"name"`
|
|
Address string `json:"address"`
|
|
Email string `json:"email"`
|
|
Phone string `json:"phone"`
|
|
Users []User `json:"users"`
|
|
Devices []Device `json:"devices"`
|
|
}
|
|
|
|
type School struct {
|
|
BaseModel
|
|
Name string `json:"name"`
|
|
Address string `json:"address"`
|
|
Students []Student `json:"students" gorm:"foreignKey:SchoolID"`
|
|
}
|
|
|
|
type Student struct {
|
|
BaseModel
|
|
Name string `json:"name"`
|
|
Age int `json:"age"`
|
|
SchoolID uint `json:"schoolId" gorm:"index"`
|
|
}
|
|
|
|
type CompanyShortResponse struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (Company) Update() (bool, error) {
|
|
return false, nil
|
|
}
|
|
func (Company) Create() (bool, error) {
|
|
return false, nil
|
|
}
|
|
func (Company) Delete() (bool, error) {
|
|
return false, nil
|
|
}
|