From d648a1e45bc33c1f1732d091ad3640e44954ad41 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 29 Dec 2025 12:01:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E3=80=81=E8=AE=A2=E5=8D=95=E3=80=81=E5=AA=92=E4=BD=93=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E5=92=8C=E7=A7=9F=E6=88=B7=E6=A8=A1=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E7=BB=93=E6=9E=84=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/user.go | 7 +-- backend/database/.transform.yaml | 17 ++++++-- backend/database/fields/media_assets.go | 13 ++++++ backend/database/fields/tenants.go | 7 +++ backend/database/fields/users.go | 9 ++++ backend/database/models/contents.gen.go | 2 +- backend/database/models/media_assets.gen.go | 31 +++++++------ .../database/models/media_assets.query.gen.go | 18 ++++---- backend/database/models/order_items.gen.go | 22 +++++----- backend/database/models/orders.gen.go | 37 ++++++++-------- backend/database/models/tenants.gen.go | 21 ++++----- backend/database/models/users.gen.go | 43 ++++++++++--------- backend/database/models/users.query.gen.go | 6 +-- 13 files changed, 141 insertions(+), 92 deletions(-) create mode 100644 backend/database/fields/media_assets.go create mode 100644 backend/database/fields/tenants.go create mode 100644 backend/database/fields/users.go diff --git a/backend/app/services/user.go b/backend/app/services/user.go index ad5e465..a15b962 100644 --- a/backend/app/services/user.go +++ b/backend/app/services/user.go @@ -48,8 +48,9 @@ func (s *user) LoginWithOTP(ctx context.Context, phone, otp string) (*auth_dto.L Username: phone, // 默认用户名 = 手机号 Password: "", // 免密登录 Nickname: "User_" + phone[len(phone)-4:], - Status: string(consts.UserStatusVerified), // 默认已审核?需确认业务逻辑 + Status: consts.UserStatusVerified, // 默认已审核 Roles: types.Array[consts.Role]{consts.RoleUser}, + Gender: consts.GenderSecret, // 默认性别 } if err := query.Create(u); err != nil { return nil, errorx.ErrDatabaseError.WithMsg("创建用户失败") @@ -60,7 +61,7 @@ func (s *user) LoginWithOTP(ctx context.Context, phone, otp string) (*auth_dto.L } // 3. 检查状态 - if u.Status == string(consts.UserStatusBanned) { + if u.Status == consts.UserStatusBanned { return nil, errorx.ErrAccountDisabled } @@ -182,7 +183,7 @@ func (s *user) toAuthUserDTO(u *models.User) *auth_dto.User { Phone: u.Phone, Nickname: u.Nickname, Avatar: u.Avatar, - Gender: consts.Gender(u.Gender), + Gender: u.Gender, // Direct assignment, types match Bio: u.Bio, Balance: float64(u.Balance) / 100.0, Points: u.Points, diff --git a/backend/database/.transform.yaml b/backend/database/.transform.yaml index 8ddaa3c..593cbcd 100644 --- a/backend/database/.transform.yaml +++ b/backend/database/.transform.yaml @@ -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: \ No newline at end of file + media_assets: + meta: types.JSONType[fields.MediaAssetMeta] + type: consts.MediaAssetType + status: consts.MediaAssetStatus + variant: consts.MediaAssetVariant +field_relate: diff --git a/backend/database/fields/media_assets.go b/backend/database/fields/media_assets.go new file mode 100644 index 0000000..d74f534 --- /dev/null +++ b/backend/database/fields/media_assets.go @@ -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"` // 字节 +} diff --git a/backend/database/fields/tenants.go b/backend/database/fields/tenants.go new file mode 100644 index 0000000..8d5cde7 --- /dev/null +++ b/backend/database/fields/tenants.go @@ -0,0 +1,7 @@ +package fields + +// TenantConfig 租户配置 +type TenantConfig struct { + Theme string `json:"theme,omitempty"` + Features []string `json:"features,omitempty"` +} diff --git a/backend/database/fields/users.go b/backend/database/fields/users.go new file mode 100644 index 0000000..e0ec83c --- /dev/null +++ b/backend/database/fields/users.go @@ -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"` +} diff --git a/backend/database/models/contents.gen.go b/backend/database/models/contents.gen.go index 94ba430..6777050 100644 --- a/backend/database/models/contents.gen.go +++ b/backend/database/models/contents.gen.go @@ -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"` diff --git a/backend/database/models/media_assets.gen.go b/backend/database/models/media_assets.gen.go index ba20847..79810a7 100644 --- a/backend/database/models/media_assets.gen.go +++ b/backend/database/models/media_assets.gen.go @@ -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 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 diff --git a/backend/database/models/media_assets.query.gen.go b/backend/database/models/media_assets.query.gen.go index dbc7764..c9f51d8 100644 --- a/backend/database/models/media_assets.query.gen.go +++ b/backend/database/models/media_assets.query.gen.go @@ -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") diff --git a/backend/database/models/order_items.gen.go b/backend/database/models/order_items.gen.go index 19c69e7..510cf87 100644 --- a/backend/database/models/order_items.gen.go +++ b/backend/database/models/order_items.gen.go @@ -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 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 diff --git a/backend/database/models/orders.gen.go b/backend/database/models/orders.gen.go index 323fcc5..5a6e775 100644 --- a/backend/database/models/orders.gen.go +++ b/backend/database/models/orders.gen.go @@ -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 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 diff --git a/backend/database/models/tenants.gen.go b/backend/database/models/tenants.gen.go index 93d16ac..334de26 100644 --- a/backend/database/models/tenants.gen.go +++ b/backend/database/models/tenants.gen.go @@ -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 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 diff --git a/backend/database/models/users.gen.go b/backend/database/models/users.gen.go index 503611c..737b9a3 100644 --- a/backend/database/models/users.gen.go +++ b/backend/database/models/users.gen.go @@ -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 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 diff --git a/backend/database/models/users.query.gen.go b/backend/database/models/users.query.gen.go index 5ab1606..102a2af 100644 --- a/backend/database/models/users.query.gen.go +++ b/backend/database/models/users.query.gen.go @@ -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")