@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Route 路由模型
|
||||
type Route struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Method string `gorm:"not null;size:10" json:"method"` // GET, POST, PUT, DELETE等
|
||||
Path string `gorm:"not null;size:255;uniqueIndex" json:"path"` // 路由路径
|
||||
Type string `gorm:"not null;size:50" json:"type"` // view, json, file, static, custom
|
||||
Handler string `gorm:"type:text" json:"handler"` // 处理函数或文件路径
|
||||
Description string `gorm:"size:500" json:"description"` // 路由描述
|
||||
IsActive bool `gorm:"default:true" json:"is_active"` // 是否启用
|
||||
Order int `gorm:"default:0" json:"order"` // 排序
|
||||
}
|
||||
|
||||
// TableName 指定表名(支持前缀)
|
||||
func (r Route) TableName() string {
|
||||
if tablePrefix != "" {
|
||||
return tablePrefix + "routes"
|
||||
}
|
||||
return "routes"
|
||||
}
|
||||
Reference in New Issue
Block a user