feat: 更新用户、订单、媒体资产和租户模型,添加新的字段类型和结构体

This commit is contained in:
2025-12-29 12:01:22 +08:00
parent 0d0aee87b1
commit d648a1e45b
13 changed files with 141 additions and 92 deletions

View File

@@ -8,6 +8,9 @@ import (
"context"
"time"
"quyun/v2/database/fields"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
"gorm.io/gorm"
@@ -17,20 +20,20 @@ const TableNameMediaAsset = "media_assets"
// MediaAsset mapped from table <media_assets>
type MediaAsset struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Type string `gorm:"column:type;type:character varying(32);default:video" json:"type"`
Status string `gorm:"column:status;type:character varying(32);default:uploaded" json:"status"`
Provider string `gorm:"column:provider;type:character varying(64);not null" json:"provider"`
Bucket string `gorm:"column:bucket;type:character varying(128);not null" json:"bucket"`
ObjectKey string `gorm:"column:object_key;type:character varying(512);not null" json:"object_key"`
Meta types.JSON `gorm:"column:meta;type:jsonb;default:{}" json:"meta"`
Variant string `gorm:"column:variant;type:character varying(32);default:main" json:"variant"`
SourceAssetID int64 `gorm:"column:source_asset_id;type:bigint" json:"source_asset_id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Type consts.MediaAssetType `gorm:"column:type;type:character varying(32);default:video" json:"type"`
Status consts.MediaAssetStatus `gorm:"column:status;type:character varying(32);default:uploaded" json:"status"`
Provider string `gorm:"column:provider;type:character varying(64);not null" json:"provider"`
Bucket string `gorm:"column:bucket;type:character varying(128);not null" json:"bucket"`
ObjectKey string `gorm:"column:object_key;type:character varying(512);not null" json:"object_key"`
Meta types.JSONType[fields.MediaAssetMeta] `gorm:"column:meta;type:jsonb;default:{}" json:"meta"`
Variant consts.MediaAssetVariant `gorm:"column:variant;type:character varying(32);default:main" json:"variant"`
SourceAssetID int64 `gorm:"column:source_asset_id;type:bigint" json:"source_asset_id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
}
// Quick operations without importing query package