This commit is contained in:
sjk
2025-11-28 15:18:10 +08:00
parent ad4a600af9
commit 5683f35942
188 changed files with 53680 additions and 1062 deletions

View File

@@ -0,0 +1,27 @@
package model
import (
"time"
)
// LiveStream 直播投流源模型
type LiveStream struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
Title string `json:"title" gorm:"type:varchar(255);not null;comment:投流源标题"`
Platform string `json:"platform" gorm:"type:varchar(50);not null;comment:平台名称(如:抖音,快手,淘宝,京东,小红书等)"`
StreamURL string `json:"stream_url" gorm:"type:varchar(500);not null;comment:投流URL地址"`
CoverImage string `json:"cover_image" gorm:"type:varchar(500);comment:封面图片URL"`
Description string `json:"description" gorm:"type:text;comment:描述信息"`
Status int `json:"status" gorm:"type:tinyint;not null;default:1;comment:状态:0-禁用,1-启用"`
Sort int `json:"sort" gorm:"type:int;not null;default:0;comment:排序值,数值越大越靠前"`
ViewCount int `json:"view_count" gorm:"type:int;not null;default:0;comment:观看次数"`
StartTime *time.Time `json:"start_time" gorm:"comment:开始时间"`
EndTime *time.Time `json:"end_time" gorm:"comment:结束时间"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
// TableName 指定表名
func (LiveStream) TableName() string {
return "ai_live_streams"
}

View File

@@ -0,0 +1,21 @@
package model
import "time"
// Platform 平台配置模型
type Platform struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
Code string `json:"code" gorm:"size:50;uniqueIndex;not null;comment:平台代码,如web,miniprogram"`
Name string `json:"name" gorm:"size:100;not null;comment:平台名称"`
Description string `json:"description" gorm:"size:255;comment:平台描述"`
Icon string `json:"icon" gorm:"size:255;comment:平台图标"`
Sort int `json:"sort" gorm:"default:0;comment:排序值"`
Status int `json:"status" gorm:"default:1;comment:状态:0-禁用,1-启用"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 指定表名
func (Platform) TableName() string {
return "ai_platforms"
}

View File

@@ -8,6 +8,25 @@ import (
"gorm.io/gorm"
)
// JSONUintSlice 自定义JSON uint切片类型
type JSONUintSlice []uint
func (j JSONUintSlice) Value() (driver.Value, error) {
return json.Marshal(j)
}
func (j *JSONUintSlice) Scan(value interface{}) error {
if value == nil {
*j = nil
return nil
}
bytes, ok := value.([]byte)
if !ok {
return nil
}
return json.Unmarshal(bytes, j)
}
// JSONSlice 自定义JSON切片类型
type JSONSlice []string
@@ -81,47 +100,50 @@ type Category struct {
Level int `json:"level" gorm:"default:1"`
Icon string `json:"icon" gorm:"size:255"`
Description string `json:"description" gorm:"size:255"`
Platform JSONSlice `json:"platform" gorm:"type:json;comment:平台标识列表"`
Sort int `json:"sort" gorm:"default:0"`
Status int `json:"status" gorm:"default:1"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联字段
Children []Category `json:"children,omitempty" gorm:"-"`
HasChildren bool `json:"hasChildren" gorm:"-"`
}
// Product 商品
type Product struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
CategoryID uint `json:"category_id" gorm:"not null"`
StoreID uint `json:"store_id" gorm:"default:1"`
Name string `json:"name" gorm:"size:100;not null"`
Description string `json:"description" gorm:"type:text"`
Price float64 `json:"price" gorm:"type:decimal(10,2);not null"`
OrigPrice float64 `json:"orig_price" gorm:"type:decimal(10,2)"`
Stock int `json:"stock" gorm:"default:0"`
Sales int `json:"sales" gorm:"default:0"`
CommentCount int `json:"comment_count" gorm:"default:0"`
AverageRating float64 `json:"average_rating" gorm:"type:decimal(3,2);default:0.00"`
MainImage string `json:"main_image" gorm:"size:255"`
Images JSONSlice `json:"images" gorm:"type:json"`
VideoURL string `json:"video_url" gorm:"size:255"`
DetailImages JSONSlice `json:"detail_images" gorm:"type:json"`
Status int `json:"status" gorm:"default:1"`
IsHot bool `json:"is_hot" gorm:"default:false"`
IsNew bool `json:"is_new" gorm:"default:false"`
IsRecommend bool `json:"is_recommend" gorm:"default:false"`
LimitBuy int `json:"limit_buy" gorm:"default:0"`
Points int `json:"points" gorm:"default:0"`
Level int `json:"level" gorm:"default:0"`
Weight float64 `json:"weight" gorm:"type:decimal(8,2)"`
Unit string `json:"unit" gorm:"size:20"`
Sort int `json:"sort" gorm:"default:0"`
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
CategoryID JSONUintSlice `json:"category_id" gorm:"type:json;comment:分类ID列表"` // 改为JSON数组支持多分类
StoreID uint `json:"store_id" gorm:"default:1"`
Name string `json:"name" gorm:"size:100;not null"`
Description string `json:"description" gorm:"type:text"`
Price float64 `json:"price" gorm:"type:decimal(10,2);not null"`
OrigPrice float64 `json:"orig_price" gorm:"type:decimal(10,2)"`
Stock int `json:"stock" gorm:"default:0"`
Sales int `json:"sales" gorm:"default:0"`
CommentCount int `json:"comment_count" gorm:"default:0"`
AverageRating float64 `json:"average_rating" gorm:"type:decimal(3,2);default:0.00"`
MainImage string `json:"main_image" gorm:"size:255"`
Images JSONSlice `json:"images" gorm:"type:json"`
VideoURL string `json:"video_url" gorm:"size:255"`
DetailImages JSONSlice `json:"detail_images" gorm:"type:json"`
Status int `json:"status" gorm:"default:1"`
IsHot bool `json:"is_hot" gorm:"default:false"`
IsNew bool `json:"is_new" gorm:"default:false"`
IsRecommend bool `json:"is_recommend" gorm:"default:false"`
LimitBuy int `json:"limit_buy" gorm:"default:0"`
Points int `json:"points" gorm:"default:0"`
Level int `json:"level" gorm:"default:0"`
Weight float64 `json:"weight" gorm:"type:decimal(8,2)"`
Unit string `json:"unit" gorm:"size:20"`
Sort int `json:"sort" gorm:"default:0"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"`
// 关联数据
Category Category `json:"category,omitempty" gorm:"foreignKey:CategoryID"`
Categories []Category `json:"categories,omitempty" gorm:"-"` // 读取时填充的分类信息
Store Store `json:"store,omitempty" gorm:"foreignKey:StoreID"`
SKUs []ProductSKU `json:"skus,omitempty" gorm:"foreignKey:ProductID"`
Tags []ProductTag `json:"tags,omitempty" gorm:"many2many:ai_product_tag_relations;"`

View File

@@ -15,7 +15,8 @@ type User struct {
Avatar string `json:"avatar" gorm:"size:255"`
Gender int `json:"gender" gorm:"default:0"` // 0未知1男2女
Phone string `json:"phone" gorm:"size:20"`
Email string `json:"email" gorm:"size:100"`
Email string `json:"email" gorm:"size:100;index"`
Password string `json:"-" gorm:"size:255"` // Web端邮箱登录密码不返回给前端
Birthday *time.Time `json:"birthday"`
Points int `json:"points" gorm:"default:0"`
Level int `json:"level" gorm:"default:1"`