mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 03:56:38 +08:00
b8e6418326
- internal/service/reader/rule/:逐方法移植 legado analyzeRule 包 (AnalyzeRule/AnalyzeByJSoup/AnalyzeByJSonPath/AnalyzeByXPath/ AnalyzeByRegex/AnalyzeUrl/RuleAnalyzer),JS 规则留 P2 接入点 - 书源导入(JSON数组/对象/Base64/URL)、多源聚合搜索(legado 四档 排序合并)、详情/目录/正文(nextContentUrl 翻页合并) - 数据模型 4 表注册迁移;/api/reader/* 路由组(书源/搜索/书架/进度/调试) - 单测 + httptest 全链路端到端测试 - docs/reader-ui-spec.md:legado UI 交互仿制规格(供 P1 前端使用)
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
// Package model 定义 GORM 数据模型和自动迁移使用的注册表。
|
|
// 每个子系统在 MeBox 中拥有一个表切片;AllModels 返回联合以供 db.AutoMigrate 使用。
|
|
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Base 嵌入每个域实体共享的字段:
|
|
//
|
|
// - ID: UUID v4 字符串主键
|
|
// - CreatedAt / UpdatedAt: 由 GORM 管理
|
|
// - DeletedAt: 软删除(查询自动过滤)
|
|
type Base struct {
|
|
ID string `gorm:"primaryKey;type:varchar(36)" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|
|
|
|
// BeforeCreate 如果调用者未提供则生成 UUID。
|
|
func (b *Base) BeforeCreate(_ *gorm.DB) error {
|
|
if b.ID == "" {
|
|
b.ID = uuid.NewString()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// AllModels returns the slice consumed by gorm.AutoMigrate.
|
|
func AllModels() []interface{} {
|
|
return []interface{}{
|
|
&User{},
|
|
&Library{},
|
|
&LibraryRoot{},
|
|
&Series{},
|
|
&Media{},
|
|
&PlaybackHistory{},
|
|
&MediaSegment{},
|
|
&MediaSegmentFetch{},
|
|
&MediaProbe{},
|
|
&Favorite{},
|
|
&Playlist{},
|
|
&PlaylistItem{},
|
|
&Setting{},
|
|
&AccessLog{},
|
|
&APIConfig{},
|
|
&UserPermission{},
|
|
&RefreshToken{},
|
|
&PlayProfile{},
|
|
&RegistrationCode{},
|
|
&SignIn{},
|
|
&UserDevice{},
|
|
&StrmAccount{},
|
|
&StrmSyncPath{},
|
|
&StrmSyncRecord{},
|
|
&StrmDownloadTask{},
|
|
&StrmUploadTask{},
|
|
&StrmDirCache{},
|
|
&ScrapeTask{},
|
|
&EmbyMount{},
|
|
&ReaderBookSource{},
|
|
&ReaderBook{},
|
|
&ReaderChapter{},
|
|
&ReaderReplaceRule{},
|
|
}
|
|
}
|