From 262ce70998fa52dec3120589f51c47e96fb96df4 Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Tue, 03 Nov 2026 17:04:19 +0800
Subject: [PATCH] feat: 完成游戏盒子前后端基础功能开发
---
server/models/models.go | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/server/models/models.go b/server/models/models.go
new file mode 100644
index 0000000..4e328fd
--- /dev/null
+++ b/server/models/models.go
@@ -0,0 +1,104 @@
+package models
+
+import "time"
+
+type Admin struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Username string `gorm:"uniqueIndex;size:50" json:"username"`
+ Password string `json:"-"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type User struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Phone string `gorm:"uniqueIndex;size:20" json:"phone"`
+ Password string `json:"-"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type Category struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Name string `gorm:"uniqueIndex;size:50" json:"name"`
+ Sort int `json:"sort"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type Game struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Title string `gorm:"size:255" json:"title"`
+ CategoryID uint `json:"category_id"`
+ CategoryName string `gorm:"-" json:"category_name,omitempty"`
+ Platform string `gorm:"size:20;default:pc" json:"platform"` // pc / switch
+ Tags string `gorm:"size:200" json:"tags"` // 逗号分隔: 即时战略,经典怀旧
+ Size string `gorm:"size:20" json:"size"` // 游戏大小 232.6 GB
+ InstallSize string `gorm:"size:20" json:"install_size"` // 安装磁盘占用 411.6 GB
+ OSReq string `gorm:"size:100" json:"os_req"`
+ CPUReq string `gorm:"size:100" json:"cpu_req"`
+ GPUReq string `gorm:"size:100" json:"gpu_req"`
+ RAMReq string `gorm:"size:100" json:"ram_req"`
+ VersionNote string `gorm:"size:500" json:"version_note"` // V1.685.421顶级版|容量175GB|官方简体中文...
+ Cover string `gorm:"size:255" json:"cover"`
+ Video string `gorm:"size:255" json:"video"`
+ Screenshots string `gorm:"type:text" json:"screenshots"` // JSON数组
+ Description string `gorm:"type:longtext" json:"description"`
+ Files string `gorm:"type:text" json:"files"` // JSON数组 [{name,size,url}]
+ IsBanner bool `json:"is_banner"` // 是否在首页轮播
+ DownloadCount int `json:"download_count"`
+ UpdatedAt time.Time `json:"updated_at"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type Tool struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Name string `gorm:"size:100" json:"name"`
+ Size string `gorm:"size:20" json:"size"`
+ Cover string `gorm:"size:255" json:"cover"`
+ Description string `gorm:"size:500" json:"description"`
+ FileURL string `gorm:"size:255" json:"file_url"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type MemberKey struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Code string `gorm:"uniqueIndex;size:50" json:"code"`
+ CardType string `gorm:"size:20" json:"card_type"` // day/month/year
+ Status int `json:"status"` // 0未使用 1已使用
+ UserID uint `json:"user_id"`
+ MachineCode string `gorm:"size:100" json:"machine_code"`
+ ActivatedAt *time.Time `json:"activated_at"`
+ ExpiredAt *time.Time `json:"expired_at"`
+ ResetCount int `json:"reset_count"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+func (k MemberKey) CardName() string {
+ switch k.CardType {
+ case "day":
+ return "日卡"
+ case "month":
+ return "月卡"
+ case "year":
+ return "年卡"
+ }
+ return k.CardType
+}
+
+type Favorite struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ UserID uint `gorm:"uniqueIndex:idx_fav" json:"user_id"`
+ GameID uint `gorm:"uniqueIndex:idx_fav" json:"game_id"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type LibraryItem struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ UserID uint `gorm:"uniqueIndex:idx_lib" json:"user_id"`
+ GameID uint `gorm:"uniqueIndex:idx_lib" json:"game_id"`
+ CreatedAt time.Time `json:"created_at"`
+}
+
+type Announcement struct {
+ ID uint `gorm:"primaryKey" json:"id"`
+ Content string `gorm:"type:text" json:"content"`
+ CreatedAt time.Time `json:"created_at"`
+}
--
Gitblit v1.10.0