feat: add wechat pay

This commit is contained in:
Rogee
2025-01-14 14:42:08 +08:00
parent 52c17b63bb
commit 9cd7659d14
32 changed files with 1431 additions and 110 deletions

View File

@@ -15,6 +15,7 @@ type Medias struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
PostID int64 `json:"post_id"`
StorageID int64 `json:"storage_id"`

View File

@@ -8,25 +8,26 @@
package model
import (
"backend/database/fields"
"time"
)
type Orders struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Type int16 `json:"type"`
Status int16 `json:"status"`
OrderSerial string `json:"order_serial"`
RemoteOrderSerial string `json:"remote_order_serial"`
RefundSerial string `json:"refund_serial"`
RemoteRefundSerial string `json:"remote_refund_serial"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Title string `json:"title"`
Description *string `json:"description"`
Meta *string `json:"meta"`
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Type fields.OrderType `json:"type"`
Status fields.OrderStatus `json:"status"`
OrderSerial string `json:"order_serial"`
RemoteOrderSerial string `json:"remote_order_serial"`
RefundSerial string `json:"refund_serial"`
RemoteRefundSerial string `json:"remote_refund_serial"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Title string `json:"title"`
Description *string `json:"description"`
Meta fields.Json[fields.OrderMeta] `json:"meta"`
}

View File

@@ -18,7 +18,7 @@ type Posts struct {
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
HashID string `json:"hash_id"`
Hash string `json:"hash"`
Title string `json:"title"`
Description string `json:"description"`
Poster string `json:"poster"`

View File

@@ -0,0 +1,24 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type UserBoughtPosts struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
PostID int64 `json:"post_id"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Meta *string `json:"meta"`
}

View File

@@ -20,6 +20,7 @@ type mediasTable struct {
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
PostID postgres.ColumnInteger
StorageID postgres.ColumnInteger
@@ -71,6 +72,7 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
PostIDColumn = postgres.IntegerColumn("post_id")
StorageIDColumn = postgres.IntegerColumn("storage_id")
@@ -79,8 +81,8 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
MimeTypeColumn = postgres.StringColumn("mime_type")
SizeColumn = postgres.IntegerColumn("size")
PathColumn = postgres.StringColumn("path")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, UserIDColumn, PostIDColumn, StorageIDColumn, NameColumn, UUIDColumn, MimeTypeColumn, SizeColumn, PathColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, UserIDColumn, PostIDColumn, StorageIDColumn, NameColumn, UUIDColumn, MimeTypeColumn, SizeColumn, PathColumn}
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, StorageIDColumn, NameColumn, UUIDColumn, MimeTypeColumn, SizeColumn, PathColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, StorageIDColumn, NameColumn, UUIDColumn, MimeTypeColumn, SizeColumn, PathColumn}
)
return mediasTable{
@@ -90,6 +92,7 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
PostID: PostIDColumn,
StorageID: StorageIDColumn,

View File

@@ -23,7 +23,7 @@ type postsTable struct {
DeletedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
HashID postgres.ColumnString
Hash postgres.ColumnString
Title postgres.ColumnString
Description postgres.ColumnString
Poster postgres.ColumnString
@@ -82,7 +82,7 @@ func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
HashIDColumn = postgres.StringColumn("hash_id")
HashColumn = postgres.StringColumn("hash")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
PosterColumn = postgres.StringColumn("poster")
@@ -95,8 +95,8 @@ func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
LikesColumn = postgres.IntegerColumn("likes")
MetaColumn = postgres.StringColumn("meta")
AssetsColumn = postgres.StringColumn("assets")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashIDColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashIDColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
)
return postsTable{
@@ -109,7 +109,7 @@ func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
DeletedAt: DeletedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
HashID: HashIDColumn,
Hash: HashColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Poster: PosterColumn,

View File

@@ -23,6 +23,7 @@ func UseSchema(schema string) {
TenantUserBalances = TenantUserBalances.FromSchema(schema)
TenantUsers = TenantUsers.FromSchema(schema)
Tenants = Tenants.FromSchema(schema)
UserBoughtPosts = UserBoughtPosts.FromSchema(schema)
UserOauths = UserOauths.FromSchema(schema)
Users = Users.FromSchema(schema)
}

View File

@@ -0,0 +1,99 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var UserBoughtPosts = newUserBoughtPostsTable("public", "user_bought_posts", "")
type userBoughtPostsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
PostID postgres.ColumnInteger
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Meta postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UserBoughtPostsTable struct {
userBoughtPostsTable
EXCLUDED userBoughtPostsTable
}
// AS creates new UserBoughtPostsTable with assigned alias
func (a UserBoughtPostsTable) AS(alias string) *UserBoughtPostsTable {
return newUserBoughtPostsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UserBoughtPostsTable with assigned schema name
func (a UserBoughtPostsTable) FromSchema(schemaName string) *UserBoughtPostsTable {
return newUserBoughtPostsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UserBoughtPostsTable with assigned table prefix
func (a UserBoughtPostsTable) WithPrefix(prefix string) *UserBoughtPostsTable {
return newUserBoughtPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UserBoughtPostsTable with assigned table suffix
func (a UserBoughtPostsTable) WithSuffix(suffix string) *UserBoughtPostsTable {
return newUserBoughtPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUserBoughtPostsTable(schemaName, tableName, alias string) *UserBoughtPostsTable {
return &UserBoughtPostsTable{
userBoughtPostsTable: newUserBoughtPostsTableImpl(schemaName, tableName, alias),
EXCLUDED: newUserBoughtPostsTableImpl("", "excluded", ""),
}
}
func newUserBoughtPostsTableImpl(schemaName, tableName, alias string) userBoughtPostsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
PostIDColumn = postgres.IntegerColumn("post_id")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
MetaColumn = postgres.StringColumn("meta")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, PriceColumn, DiscountColumn, MetaColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, PriceColumn, DiscountColumn, MetaColumn}
)
return userBoughtPostsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
PostID: PostIDColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Meta: MetaColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}