feat: 更新用户、订单、媒体资产和租户模型,添加新的字段类型和结构体
This commit is contained in:
@@ -14,19 +14,30 @@ field_type:
|
||||
users:
|
||||
gender: consts.Gender
|
||||
roles: types.Array[consts.Role]
|
||||
location: types.JSONType[fields.UserLocation]
|
||||
status: consts.UserStatus
|
||||
contents:
|
||||
status: consts.ContentStatus
|
||||
visibility: consts.ContentVisibility
|
||||
genre: string # genre is varchar(64) but no enum defined yet?
|
||||
genre: string
|
||||
tags: types.JSONSlice[string]
|
||||
content_prices:
|
||||
currency: consts.Currency
|
||||
discount_type: consts.DiscountType
|
||||
orders:
|
||||
status: consts.OrderStatus
|
||||
type: consts.OrderType
|
||||
snapshot: types.JSONType[fields.OrdersSnapshot]
|
||||
order_items:
|
||||
snapshot: types.JSONType[fields.OrderItemsSnapshot]
|
||||
tenants:
|
||||
status: consts.TenantStatus
|
||||
config: types.JSONType[fields.TenantConfig]
|
||||
tenant_users:
|
||||
role: types.Array[consts.TenantUserRole]
|
||||
# status: consts.UserStatus # Skipping status for now to avoid mismatch 'active' vs 'verified' without enum update
|
||||
field_relate:
|
||||
media_assets:
|
||||
meta: types.JSONType[fields.MediaAssetMeta]
|
||||
type: consts.MediaAssetType
|
||||
status: consts.MediaAssetStatus
|
||||
variant: consts.MediaAssetVariant
|
||||
field_relate:
|
||||
|
||||
13
backend/database/fields/media_assets.go
Normal file
13
backend/database/fields/media_assets.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package fields
|
||||
|
||||
// MediaAssetMeta 媒体资源元数据
|
||||
type MediaAssetMeta struct {
|
||||
Hash string `json:"hash,omitempty"`
|
||||
Duration float64 `json:"duration,omitempty"` // 秒
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
Bitrate int `json:"bitrate,omitempty"` // bps
|
||||
Codec string `json:"codec,omitempty"`
|
||||
Format string `json:"format,omitempty"`
|
||||
Size int64 `json:"size,omitempty"` // 字节
|
||||
}
|
||||
7
backend/database/fields/tenants.go
Normal file
7
backend/database/fields/tenants.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package fields
|
||||
|
||||
// TenantConfig 租户配置
|
||||
type TenantConfig struct {
|
||||
Theme string `json:"theme,omitempty"`
|
||||
Features []string `json:"features,omitempty"`
|
||||
}
|
||||
9
backend/database/fields/users.go
Normal file
9
backend/database/fields/users.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package fields
|
||||
|
||||
// UserLocation 用户位置信息
|
||||
type UserLocation struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
District string `json:"district,omitempty"`
|
||||
Address string `json:"address,omitempty"`
|
||||
}
|
||||
@@ -30,7 +30,7 @@ type Content struct {
|
||||
PreviewDownloadable bool `gorm:"column:preview_downloadable;type:boolean" json:"preview_downloadable"`
|
||||
PublishedAt time.Time `gorm:"column:published_at;type:timestamp with time zone" json:"published_at"`
|
||||
Summary string `gorm:"column:summary;type:character varying(256)" json:"summary"`
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;default:[]" json:"tags"`
|
||||
Tags types.JSONSlice[string] `gorm:"column:tags;type:jsonb;default:[]" json:"tags"`
|
||||
Body string `gorm:"column:body;type:text" json:"body"`
|
||||
Genre string `gorm:"column:genre;type:character varying(64)" json:"genre"`
|
||||
Views int32 `gorm:"column:views;type:integer" json:"views"`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,13 +28,13 @@ func newMediaAsset(db *gorm.DB, opts ...gen.DOOption) mediaAssetQuery {
|
||||
_mediaAssetQuery.ID = field.NewInt64(tableName, "id")
|
||||
_mediaAssetQuery.TenantID = field.NewInt64(tableName, "tenant_id")
|
||||
_mediaAssetQuery.UserID = field.NewInt64(tableName, "user_id")
|
||||
_mediaAssetQuery.Type = field.NewString(tableName, "type")
|
||||
_mediaAssetQuery.Status = field.NewString(tableName, "status")
|
||||
_mediaAssetQuery.Type = field.NewField(tableName, "type")
|
||||
_mediaAssetQuery.Status = field.NewField(tableName, "status")
|
||||
_mediaAssetQuery.Provider = field.NewString(tableName, "provider")
|
||||
_mediaAssetQuery.Bucket = field.NewString(tableName, "bucket")
|
||||
_mediaAssetQuery.ObjectKey = field.NewString(tableName, "object_key")
|
||||
_mediaAssetQuery.Meta = field.NewJSONB(tableName, "meta")
|
||||
_mediaAssetQuery.Variant = field.NewString(tableName, "variant")
|
||||
_mediaAssetQuery.Variant = field.NewField(tableName, "variant")
|
||||
_mediaAssetQuery.SourceAssetID = field.NewInt64(tableName, "source_asset_id")
|
||||
_mediaAssetQuery.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_mediaAssetQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
@@ -52,13 +52,13 @@ type mediaAssetQuery struct {
|
||||
ID field.Int64
|
||||
TenantID field.Int64
|
||||
UserID field.Int64
|
||||
Type field.String
|
||||
Status field.String
|
||||
Type field.Field
|
||||
Status field.Field
|
||||
Provider field.String
|
||||
Bucket field.String
|
||||
ObjectKey field.String
|
||||
Meta field.JSONB
|
||||
Variant field.String
|
||||
Variant field.Field
|
||||
SourceAssetID field.Int64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
@@ -82,13 +82,13 @@ func (m *mediaAssetQuery) updateTableName(table string) *mediaAssetQuery {
|
||||
m.ID = field.NewInt64(table, "id")
|
||||
m.TenantID = field.NewInt64(table, "tenant_id")
|
||||
m.UserID = field.NewInt64(table, "user_id")
|
||||
m.Type = field.NewString(table, "type")
|
||||
m.Status = field.NewString(table, "status")
|
||||
m.Type = field.NewField(table, "type")
|
||||
m.Status = field.NewField(table, "status")
|
||||
m.Provider = field.NewString(table, "provider")
|
||||
m.Bucket = field.NewString(table, "bucket")
|
||||
m.ObjectKey = field.NewString(table, "object_key")
|
||||
m.Meta = field.NewJSONB(table, "meta")
|
||||
m.Variant = field.NewString(table, "variant")
|
||||
m.Variant = field.NewField(table, "variant")
|
||||
m.SourceAssetID = field.NewInt64(table, "source_asset_id")
|
||||
m.CreatedAt = field.NewTime(table, "created_at")
|
||||
m.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/fields"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
@@ -16,16 +18,16 @@ const TableNameOrderItem = "order_items"
|
||||
|
||||
// OrderItem mapped from table <order_items>
|
||||
type OrderItem 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"`
|
||||
OrderID int64 `gorm:"column:order_id;type:bigint;not null" json:"order_id"`
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
|
||||
ContentUserID int64 `gorm:"column:content_user_id;type:bigint;not null" json:"content_user_id"`
|
||||
AmountPaid int64 `gorm:"column:amount_paid;type:bigint;not null" json:"amount_paid"`
|
||||
Snapshot types.JSON `gorm:"column:snapshot;type:jsonb;default:{}" json:"snapshot"`
|
||||
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"`
|
||||
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"`
|
||||
OrderID int64 `gorm:"column:order_id;type:bigint;not null" json:"order_id"`
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
|
||||
ContentUserID int64 `gorm:"column:content_user_id;type:bigint;not null" json:"content_user_id"`
|
||||
AmountPaid int64 `gorm:"column:amount_paid;type:bigint;not null" json:"amount_paid"`
|
||||
Snapshot types.JSONType[fields.OrderItemsSnapshot] `gorm:"column:snapshot;type:jsonb;default:{}" json:"snapshot"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/fields"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
@@ -18,24 +19,24 @@ const TableNameOrder = "orders"
|
||||
|
||||
// Order mapped from table <orders>
|
||||
type Order 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 consts.OrderType `gorm:"column:type;type:character varying(32);default:content_purchase" json:"type"`
|
||||
Status consts.OrderStatus `gorm:"column:status;type:character varying(32);default:created" json:"status"`
|
||||
Currency string `gorm:"column:currency;type:character varying(16);default:CNY" json:"currency"`
|
||||
AmountOriginal int64 `gorm:"column:amount_original;type:bigint;not null" json:"amount_original"`
|
||||
AmountDiscount int64 `gorm:"column:amount_discount;type:bigint;not null" json:"amount_discount"`
|
||||
AmountPaid int64 `gorm:"column:amount_paid;type:bigint;not null" json:"amount_paid"`
|
||||
Snapshot types.JSON `gorm:"column:snapshot;type:jsonb;default:{}" json:"snapshot"`
|
||||
IdempotencyKey string `gorm:"column:idempotency_key;type:character varying(128);not null" json:"idempotency_key"`
|
||||
PaidAt time.Time `gorm:"column:paid_at;type:timestamp with time zone" json:"paid_at"`
|
||||
RefundedAt time.Time `gorm:"column:refunded_at;type:timestamp with time zone" json:"refunded_at"`
|
||||
RefundForced bool `gorm:"column:refund_forced;type:boolean" json:"refund_forced"`
|
||||
RefundOperatorUserID int64 `gorm:"column:refund_operator_user_id;type:bigint" json:"refund_operator_user_id"`
|
||||
RefundReason string `gorm:"column:refund_reason;type:character varying(255)" json:"refund_reason"`
|
||||
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"`
|
||||
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.OrderType `gorm:"column:type;type:character varying(32);default:content_purchase" json:"type"`
|
||||
Status consts.OrderStatus `gorm:"column:status;type:character varying(32);default:created" json:"status"`
|
||||
Currency string `gorm:"column:currency;type:character varying(16);default:CNY" json:"currency"`
|
||||
AmountOriginal int64 `gorm:"column:amount_original;type:bigint;not null" json:"amount_original"`
|
||||
AmountDiscount int64 `gorm:"column:amount_discount;type:bigint;not null" json:"amount_discount"`
|
||||
AmountPaid int64 `gorm:"column:amount_paid;type:bigint;not null" json:"amount_paid"`
|
||||
Snapshot types.JSONType[fields.OrdersSnapshot] `gorm:"column:snapshot;type:jsonb;default:{}" json:"snapshot"`
|
||||
IdempotencyKey string `gorm:"column:idempotency_key;type:character varying(128);not null" json:"idempotency_key"`
|
||||
PaidAt time.Time `gorm:"column:paid_at;type:timestamp with time zone" json:"paid_at"`
|
||||
RefundedAt time.Time `gorm:"column:refunded_at;type:timestamp with time zone" json:"refunded_at"`
|
||||
RefundForced bool `gorm:"column:refund_forced;type:boolean" json:"refund_forced"`
|
||||
RefundOperatorUserID int64 `gorm:"column:refund_operator_user_id;type:bigint" json:"refund_operator_user_id"`
|
||||
RefundReason string `gorm:"column:refund_reason;type:character varying(255)" json:"refund_reason"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/fields"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
@@ -18,16 +19,16 @@ const TableNameTenant = "tenants"
|
||||
|
||||
// Tenant mapped from table <tenants>
|
||||
type Tenant struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
Code string `gorm:"column:code;type:character varying(64);not null" json:"code"`
|
||||
UUID types.UUID `gorm:"column:uuid;type:uuid;not null" json:"uuid"`
|
||||
Name string `gorm:"column:name;type:character varying(128);not null" json:"name"`
|
||||
Status consts.TenantStatus `gorm:"column:status;type:character varying(64);not null" json:"status"`
|
||||
Config types.JSON `gorm:"column:config;type:jsonb;default:{}" json:"config"`
|
||||
ExpiredAt time.Time `gorm:"column:expired_at;type:timestamp with time zone" json:"expired_at"`
|
||||
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"`
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
Code string `gorm:"column:code;type:character varying(64);not null" json:"code"`
|
||||
UUID types.UUID `gorm:"column:uuid;type:uuid;not null" json:"uuid"`
|
||||
Name string `gorm:"column:name;type:character varying(128);not null" json:"name"`
|
||||
Status consts.TenantStatus `gorm:"column:status;type:character varying(64);not null" json:"status"`
|
||||
Config types.JSONType[fields.TenantConfig] `gorm:"column:config;type:jsonb;default:{}" json:"config"`
|
||||
ExpiredAt time.Time `gorm:"column:expired_at;type:timestamp with time zone" json:"expired_at"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/fields"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
@@ -19,27 +20,27 @@ const TableNameUser = "users"
|
||||
|
||||
// User mapped from table <users>
|
||||
type User struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
Username string `gorm:"column:username;type:character varying(255);not null" json:"username"`
|
||||
Password string `gorm:"column:password;type:character varying(255);not null" json:"password"`
|
||||
Roles types.Array[consts.Role] `gorm:"column:roles;type:text[];default:{user}" json:"roles"`
|
||||
Status string `gorm:"column:status;type:character varying(50);default:active" json:"status"`
|
||||
Metas types.JSON `gorm:"column:metas;type:jsonb;default:{}" json:"metas"`
|
||||
Balance int64 `gorm:"column:balance;type:bigint" json:"balance"`
|
||||
BalanceFrozen int64 `gorm:"column:balance_frozen;type:bigint" json:"balance_frozen"`
|
||||
VerifiedAt time.Time `gorm:"column:verified_at;type:timestamp with time zone" json:"verified_at"`
|
||||
Nickname string `gorm:"column:nickname;type:character varying(255)" json:"nickname"`
|
||||
Avatar string `gorm:"column:avatar;type:character varying(512)" json:"avatar"`
|
||||
Gender consts.Gender `gorm:"column:gender;type:character varying(32);default:secret" json:"gender"`
|
||||
Bio string `gorm:"column:bio;type:character varying(512)" json:"bio"`
|
||||
Birthday types.Date `gorm:"column:birthday;type:date" json:"birthday"`
|
||||
Location types.JSON `gorm:"column:location;type:jsonb;default:{}" json:"location"`
|
||||
Points int64 `gorm:"column:points;type:bigint" json:"points"`
|
||||
Phone string `gorm:"column:phone;type:character varying(32)" json:"phone"`
|
||||
IsRealNameVerified bool `gorm:"column:is_real_name_verified;type:boolean" json:"is_real_name_verified"`
|
||||
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"`
|
||||
Username string `gorm:"column:username;type:character varying(255);not null" json:"username"`
|
||||
Password string `gorm:"column:password;type:character varying(255);not null" json:"password"`
|
||||
Roles types.Array[consts.Role] `gorm:"column:roles;type:text[];default:{user}" json:"roles"`
|
||||
Status consts.UserStatus `gorm:"column:status;type:character varying(50);default:active" json:"status"`
|
||||
Metas types.JSON `gorm:"column:metas;type:jsonb;default:{}" json:"metas"`
|
||||
Balance int64 `gorm:"column:balance;type:bigint" json:"balance"`
|
||||
BalanceFrozen int64 `gorm:"column:balance_frozen;type:bigint" json:"balance_frozen"`
|
||||
VerifiedAt time.Time `gorm:"column:verified_at;type:timestamp with time zone" json:"verified_at"`
|
||||
Nickname string `gorm:"column:nickname;type:character varying(255)" json:"nickname"`
|
||||
Avatar string `gorm:"column:avatar;type:character varying(512)" json:"avatar"`
|
||||
Gender consts.Gender `gorm:"column:gender;type:character varying(32);default:secret" json:"gender"`
|
||||
Bio string `gorm:"column:bio;type:character varying(512)" json:"bio"`
|
||||
Birthday types.Date `gorm:"column:birthday;type:date" json:"birthday"`
|
||||
Location types.JSONType[fields.UserLocation] `gorm:"column:location;type:jsonb;default:{}" json:"location"`
|
||||
Points int64 `gorm:"column:points;type:bigint" json:"points"`
|
||||
Phone string `gorm:"column:phone;type:character varying(32)" json:"phone"`
|
||||
IsRealNameVerified bool `gorm:"column:is_real_name_verified;type:boolean" json:"is_real_name_verified"`
|
||||
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
|
||||
|
||||
@@ -29,7 +29,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) userQuery {
|
||||
_userQuery.Username = field.NewString(tableName, "username")
|
||||
_userQuery.Password = field.NewString(tableName, "password")
|
||||
_userQuery.Roles = field.NewArray(tableName, "roles")
|
||||
_userQuery.Status = field.NewString(tableName, "status")
|
||||
_userQuery.Status = field.NewField(tableName, "status")
|
||||
_userQuery.Metas = field.NewJSONB(tableName, "metas")
|
||||
_userQuery.Balance = field.NewInt64(tableName, "balance")
|
||||
_userQuery.BalanceFrozen = field.NewInt64(tableName, "balance_frozen")
|
||||
@@ -60,7 +60,7 @@ type userQuery struct {
|
||||
Username field.String
|
||||
Password field.String
|
||||
Roles field.Array
|
||||
Status field.String
|
||||
Status field.Field
|
||||
Metas field.JSONB
|
||||
Balance field.Int64
|
||||
BalanceFrozen field.Int64
|
||||
@@ -97,7 +97,7 @@ func (u *userQuery) updateTableName(table string) *userQuery {
|
||||
u.Username = field.NewString(table, "username")
|
||||
u.Password = field.NewString(table, "password")
|
||||
u.Roles = field.NewArray(table, "roles")
|
||||
u.Status = field.NewString(table, "status")
|
||||
u.Status = field.NewField(table, "status")
|
||||
u.Metas = field.NewJSONB(table, "metas")
|
||||
u.Balance = field.NewInt64(table, "balance")
|
||||
u.BalanceFrozen = field.NewInt64(table, "balance_frozen")
|
||||
|
||||
Reference in New Issue
Block a user