feat: 初始化仓库
This commit is contained in:
22
models/classroom.go
Normal file
22
models/classroom.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Classroom 教室模型
|
||||
type Classroom struct {
|
||||
ID string `gorm:"type:uuid;primaryKey" json:"id"`
|
||||
Name string `gorm:"type:varchar(255);not null" json:"name"`
|
||||
Build string `gorm:"type:varchar(255);not null" json:"build"`
|
||||
BuildID string `gorm:"type:uuid;not null" json:"build_id"`
|
||||
CampusID string `gorm:"type:uuid;not null" json:"campus_id"` // 校区ID
|
||||
Campus string `gorm:"type:varchar(255);not null" json:"campus"` // 校区名称
|
||||
}
|
||||
|
||||
// BeforeCreate 在创建Classroom之前生成UUID
|
||||
func (classroom *Classroom) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
classroom.ID = uuid.New().String()
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user