feat: migrate serevices
Some checks failed
build quyun / Build (push) Failing after 2m50s

This commit is contained in:
2025-12-19 19:05:12 +08:00
parent 005585c53b
commit 557a641f41
71 changed files with 5626 additions and 280 deletions

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/fields"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
)
@@ -16,14 +18,14 @@ const TableNameMedia = "medias"
// Media mapped from table <medias>
type Media struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
Name string `gorm:"column:name;type:character varying(255);not null" json:"name"`
MimeType string `gorm:"column:mime_type;type:character varying(128);not null" json:"mime_type"`
Size int64 `gorm:"column:size;type:bigint;not null" json:"size"`
Path string `gorm:"column:path;type:character varying(255);not null" json:"path"`
Metas types.JSON `gorm:"column:metas;type:jsonb;not null;default:{}" json:"metas"`
Hash string `gorm:"column:hash;type:character varying(64);not null" json:"hash"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
Name string `gorm:"column:name;type:character varying(255);not null" json:"name"`
MimeType string `gorm:"column:mime_type;type:character varying(128);not null" json:"mime_type"`
Size int64 `gorm:"column:size;type:bigint;not null" json:"size"`
Path string `gorm:"column:path;type:character varying(255);not null" json:"path"`
Metas types.JSONType[fields.MediaMetas] `gorm:"column:metas;type:jsonb;not null;default:{}" json:"metas"`
Hash string `gorm:"column:hash;type:character varying(64);not null" json:"hash"`
}
// Quick operations without importing query package

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/fields"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
)
@@ -16,21 +18,21 @@ const TableNameOrder = "orders"
// Order mapped from table <orders>
type Order struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
OrderNo string `gorm:"column:order_no;type:character varying(64);not null" json:"order_no"`
SubOrderNo string `gorm:"column:sub_order_no;type:character varying(64);not null" json:"sub_order_no"`
TransactionID string `gorm:"column:transaction_id;type:character varying(64);not null" json:"transaction_id"`
RefundTransactionID string `gorm:"column:refund_transaction_id;type:character varying(64);not null" json:"refund_transaction_id"`
Price int64 `gorm:"column:price;type:bigint;not null" json:"price"`
Discount int16 `gorm:"column:discount;type:smallint;not null;default:100" json:"discount"`
Currency string `gorm:"column:currency;type:character varying(10);not null;default:CNY" json:"currency"`
PaymentMethod string `gorm:"column:payment_method;type:character varying(50);not null;default:wechatpay" json:"payment_method"`
PostID int64 `gorm:"column:post_id;type:bigint;not null" json:"post_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Status int16 `gorm:"column:status;type:smallint;not null" json:"status"`
Meta types.JSON `gorm:"column:meta;type:jsonb;not null;default:{}" json:"meta"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
OrderNo string `gorm:"column:order_no;type:character varying(64);not null" json:"order_no"`
SubOrderNo string `gorm:"column:sub_order_no;type:character varying(64);not null" json:"sub_order_no"`
TransactionID string `gorm:"column:transaction_id;type:character varying(64);not null" json:"transaction_id"`
RefundTransactionID string `gorm:"column:refund_transaction_id;type:character varying(64);not null" json:"refund_transaction_id"`
Price int64 `gorm:"column:price;type:bigint;not null" json:"price"`
Discount int16 `gorm:"column:discount;type:smallint;not null;default:100" json:"discount"`
Currency string `gorm:"column:currency;type:character varying(10);not null;default:CNY" json:"currency"`
PaymentMethod string `gorm:"column:payment_method;type:character varying(50);not null;default:wechatpay" json:"payment_method"`
PostID int64 `gorm:"column:post_id;type:bigint;not null" json:"post_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Status fields.OrderStatus `gorm:"column:status;type:smallint;not null" json:"status"`
Meta types.JSONType[fields.OrderMeta] `gorm:"column:meta;type:jsonb;not null;default:{}" json:"meta"`
}
// Quick operations without importing query package

View File

@@ -38,7 +38,7 @@ func newOrder(db *gorm.DB, opts ...gen.DOOption) orderQuery {
_orderQuery.PaymentMethod = field.NewString(tableName, "payment_method")
_orderQuery.PostID = field.NewInt64(tableName, "post_id")
_orderQuery.UserID = field.NewInt64(tableName, "user_id")
_orderQuery.Status = field.NewInt16(tableName, "status")
_orderQuery.Status = field.NewField(tableName, "status")
_orderQuery.Meta = field.NewJSONB(tableName, "meta")
_orderQuery.fillFieldMap()
@@ -63,7 +63,7 @@ type orderQuery struct {
PaymentMethod field.String
PostID field.Int64
UserID field.Int64
Status field.Int16
Status field.Field
Meta field.JSONB
fieldMap map[string]field.Expr
@@ -94,7 +94,7 @@ func (o *orderQuery) updateTableName(table string) *orderQuery {
o.PaymentMethod = field.NewString(table, "payment_method")
o.PostID = field.NewInt64(table, "post_id")
o.UserID = field.NewInt64(table, "user_id")
o.Status = field.NewInt16(table, "status")
o.Status = field.NewField(table, "status")
o.Meta = field.NewJSONB(table, "meta")
o.fillFieldMap()

View File

@@ -0,0 +1,5 @@
package models
func (m *Post) PayPrice() int64 {
return m.Price * int64(m.Discount) / 100
}

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/fields"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
"gorm.io/gorm"
@@ -17,21 +19,21 @@ const TableNamePost = "posts"
// Post mapped from table <posts>
type Post struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone" json:"deleted_at"`
Status int16 `gorm:"column:status;type:smallint;not null" json:"status"`
Title string `gorm:"column:title;type:character varying(128);not null" json:"title"`
HeadImages types.JSON `gorm:"column:head_images;type:jsonb;not null;default:[]" json:"head_images"`
Description string `gorm:"column:description;type:character varying(256);not null" json:"description"`
Content string `gorm:"column:content;type:text;not null" json:"content"`
Price int64 `gorm:"column:price;type:bigint;not null" json:"price"`
Discount int16 `gorm:"column:discount;type:smallint;not null;default:100" json:"discount"`
Views int64 `gorm:"column:views;type:bigint;not null" json:"views"`
Likes int64 `gorm:"column:likes;type:bigint;not null" json:"likes"`
Tags types.JSON `gorm:"column:tags;type:jsonb;default:{}" json:"tags"`
Assets types.JSON `gorm:"column:assets;type:jsonb;default:{}" json:"assets"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone" json:"deleted_at"`
Status fields.PostStatus `gorm:"column:status;type:smallint;not null" json:"status"`
Title string `gorm:"column:title;type:character varying(128);not null" json:"title"`
HeadImages types.JSONType[[]int64] `gorm:"column:head_images;type:jsonb;not null;default:[]" json:"head_images"`
Description string `gorm:"column:description;type:character varying(256);not null" json:"description"`
Content string `gorm:"column:content;type:text;not null" json:"content"`
Price int64 `gorm:"column:price;type:bigint;not null" json:"price"`
Discount int16 `gorm:"column:discount;type:smallint;not null;default:100" json:"discount"`
Views int64 `gorm:"column:views;type:bigint;not null" json:"views"`
Likes int64 `gorm:"column:likes;type:bigint;not null" json:"likes"`
Tags types.JSONType[[]string] `gorm:"column:tags;type:jsonb;default:{}" json:"tags"`
Assets types.JSONType[[]fields.MediaAsset] `gorm:"column:assets;type:jsonb;default:{}" json:"assets"`
}
// Quick operations without importing query package

View File

@@ -29,7 +29,7 @@ func newPost(db *gorm.DB, opts ...gen.DOOption) postQuery {
_postQuery.CreatedAt = field.NewTime(tableName, "created_at")
_postQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
_postQuery.DeletedAt = field.NewField(tableName, "deleted_at")
_postQuery.Status = field.NewInt16(tableName, "status")
_postQuery.Status = field.NewField(tableName, "status")
_postQuery.Title = field.NewString(tableName, "title")
_postQuery.HeadImages = field.NewJSONB(tableName, "head_images")
_postQuery.Description = field.NewString(tableName, "description")
@@ -54,7 +54,7 @@ type postQuery struct {
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
Status field.Int16
Status field.Field
Title field.String
HeadImages field.JSONB
Description field.String
@@ -85,7 +85,7 @@ func (p *postQuery) updateTableName(table string) *postQuery {
p.CreatedAt = field.NewTime(table, "created_at")
p.UpdatedAt = field.NewTime(table, "updated_at")
p.DeletedAt = field.NewField(table, "deleted_at")
p.Status = field.NewInt16(table, "status")
p.Status = field.NewField(table, "status")
p.Title = field.NewString(table, "title")
p.HeadImages = field.NewJSONB(table, "head_images")
p.Description = field.NewString(table, "description")

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/fields"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
"gorm.io/gorm"
@@ -17,17 +19,17 @@ const TableNameUser = "users"
// User mapped from table <users>
type User struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone" json:"deleted_at"`
Status int16 `gorm:"column:status;type:smallint;not null" json:"status"`
OpenID string `gorm:"column:open_id;type:character varying(128);not null" json:"open_id"`
Username string `gorm:"column:username;type:character varying(128);not null" json:"username"`
Avatar string `gorm:"column:avatar;type:text" json:"avatar"`
Metas types.JSON `gorm:"column:metas;type:jsonb;not null;default:{}" json:"metas"`
AuthToken types.JSON `gorm:"column:auth_token;type:jsonb;not null;default:{}" json:"auth_token"`
Balance int64 `gorm:"column:balance;type:bigint;not null" json:"balance"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone" json:"deleted_at"`
Status fields.UserStatus `gorm:"column:status;type:smallint;not null" json:"status"`
OpenID string `gorm:"column:open_id;type:character varying(128);not null" json:"open_id"`
Username string `gorm:"column:username;type:character varying(128);not null" json:"username"`
Avatar string `gorm:"column:avatar;type:text" json:"avatar"`
Metas types.JSONType[fields.UserMetas] `gorm:"column:metas;type:jsonb;not null;default:{}" json:"metas"`
AuthToken types.JSONType[fields.UserAuthToken] `gorm:"column:auth_token;type:jsonb;not null;default:{}" json:"auth_token"`
Balance int64 `gorm:"column:balance;type:bigint;not null" json:"balance"`
}
// Quick operations without importing query package

View File

@@ -29,7 +29,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) userQuery {
_userQuery.CreatedAt = field.NewTime(tableName, "created_at")
_userQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
_userQuery.DeletedAt = field.NewField(tableName, "deleted_at")
_userQuery.Status = field.NewInt16(tableName, "status")
_userQuery.Status = field.NewField(tableName, "status")
_userQuery.OpenID = field.NewString(tableName, "open_id")
_userQuery.Username = field.NewString(tableName, "username")
_userQuery.Avatar = field.NewString(tableName, "avatar")
@@ -50,7 +50,7 @@ type userQuery struct {
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
Status field.Int16
Status field.Field
OpenID field.String
Username field.String
Avatar field.String
@@ -77,7 +77,7 @@ func (u *userQuery) updateTableName(table string) *userQuery {
u.CreatedAt = field.NewTime(table, "created_at")
u.UpdatedAt = field.NewTime(table, "updated_at")
u.DeletedAt = field.NewField(table, "deleted_at")
u.Status = field.NewInt16(table, "status")
u.Status = field.NewField(table, "status")
u.OpenID = field.NewString(table, "open_id")
u.Username = field.NewString(table, "username")
u.Avatar = field.NewString(table, "avatar")