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