fix: issues

This commit is contained in:
Rogee
2025-01-14 19:48:23 +08:00
parent b429f30916
commit 48a0a6c195
14 changed files with 1037 additions and 195 deletions

View File

@@ -8,27 +8,28 @@
package model
import (
"backend/database/fields"
"time"
)
type Posts 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"`
Hash string `json:"hash"`
Title string `json:"title"`
Description string `json:"description"`
Poster string `json:"poster"`
Content string `json:"content"`
Stage int16 `json:"stage"`
Status int16 `json:"status"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Views int64 `json:"views"`
Likes int64 `json:"likes"`
Meta *string `json:"meta"`
Assets *string `json:"assets"`
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"`
Type fields.PostType `json:"type"`
Stage fields.PostStage `json:"stage"`
Status fields.PostStatus `json:"status"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Title string `json:"title"`
Description string `json:"description"`
PosterAssetID int64 `json:"poster_asset_id"`
Content string `json:"content"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Views int64 `json:"views"`
Likes int64 `json:"likes"`
Meta *string `json:"meta"`
Assets *string `json:"assets"`
}

View File

@@ -17,25 +17,25 @@ type postsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
Hash postgres.ColumnString
Title postgres.ColumnString
Description postgres.ColumnString
Poster postgres.ColumnString
Content postgres.ColumnString
Stage postgres.ColumnInteger
Status postgres.ColumnInteger
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Views postgres.ColumnInteger
Likes postgres.ColumnInteger
Meta postgres.ColumnString
Assets postgres.ColumnString
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Type postgres.ColumnInteger
Stage postgres.ColumnInteger
Status postgres.ColumnInteger
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
Title postgres.ColumnString
Description postgres.ColumnString
PosterAssetID postgres.ColumnInteger
Content postgres.ColumnString
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Views postgres.ColumnInteger
Likes postgres.ColumnInteger
Meta postgres.ColumnString
Assets postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
@@ -76,52 +76,52 @@ func newPostsTable(schemaName, tableName, alias string) *PostsTable {
func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
HashColumn = postgres.StringColumn("hash")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
PosterColumn = postgres.StringColumn("poster")
ContentColumn = postgres.StringColumn("content")
StageColumn = postgres.IntegerColumn("stage")
StatusColumn = postgres.IntegerColumn("status")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
ViewsColumn = postgres.IntegerColumn("views")
LikesColumn = postgres.IntegerColumn("likes")
MetaColumn = postgres.StringColumn("meta")
AssetsColumn = postgres.StringColumn("assets")
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}
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TypeColumn = postgres.IntegerColumn("type")
StageColumn = postgres.IntegerColumn("stage")
StatusColumn = postgres.IntegerColumn("status")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
PosterAssetIDColumn = postgres.IntegerColumn("poster_asset_id")
ContentColumn = postgres.StringColumn("content")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
ViewsColumn = postgres.IntegerColumn("views")
LikesColumn = postgres.IntegerColumn("likes")
MetaColumn = postgres.StringColumn("meta")
AssetsColumn = postgres.StringColumn("assets")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TypeColumn, StageColumn, StatusColumn, TenantIDColumn, UserIDColumn, TitleColumn, DescriptionColumn, PosterAssetIDColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TypeColumn, StageColumn, StatusColumn, TenantIDColumn, UserIDColumn, TitleColumn, DescriptionColumn, PosterAssetIDColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
)
return postsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
Hash: HashColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Poster: PosterColumn,
Content: ContentColumn,
Stage: StageColumn,
Status: StatusColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Views: ViewsColumn,
Likes: LikesColumn,
Meta: MetaColumn,
Assets: AssetsColumn,
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Type: TypeColumn,
Stage: StageColumn,
Status: StatusColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
Title: TitleColumn,
Description: DescriptionColumn,
PosterAssetID: PosterAssetIDColumn,
Content: ContentColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Views: ViewsColumn,
Likes: LikesColumn,
Meta: MetaColumn,
Assets: AssetsColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,