add migration;add api create employee

This commit is contained in:
MacBook Air M1
2026-01-05 17:17:25 +07:00
parent c1a162b4d4
commit df504e3ff0
12 changed files with 787 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
package entities
import "time"
type Employee struct {
Id uint `gorm:"primaryKey"`
Name string `gorm:"not null"`
IsActive bool `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
EmployeeKandangs []EmployeeKandang `gorm:"foreignKey:EmployeeId;references:Id"`
}
type Employees = Employee
type EmployeeKandang struct {
Id uint `gorm:"primaryKey"`
EmployeeId uint `gorm:"not null"`
KandangId uint `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
Employee Employee `gorm:"foreignKey:EmployeeId;references:Id"`
Kandang Kandang `gorm:"foreignKey:KandangId;references:Id"`
}