update automic

This commit is contained in:
2026-01-22 17:03:07 +07:00
parent 4c85eb34f8
commit acd0be8fa1
8 changed files with 74 additions and 54 deletions

View File

@@ -12,16 +12,17 @@ const TableNamePayment = "payment"
// Payment mapped from table <payment>
type Payment struct {
ID string `gorm:"column:id;primaryKey;default:gen_random_uuid()" json:"id"`
UserID string `gorm:"column:user_id;not null" json:"user_id"`
PlanID string `gorm:"column:plan_id" json:"plan_id"`
Amount float64 `gorm:"column:amount;not null" json:"amount"`
Currency string `gorm:"column:currency;not null;default:USD" json:"currency"`
Status string `gorm:"column:status;not null;default:PENDING" json:"status"`
Provider string `gorm:"column:provider;not null;default:STRIPE" json:"provider"`
TransactionID string `gorm:"column:transaction_id" json:"transaction_id"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
ID string `gorm:"column:id;type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
UserID string `gorm:"column:user_id;type:uuid;not null" json:"user_id"`
PlanID *string `gorm:"column:plan_id;type:uuid" json:"plan_id"`
Amount float64 `gorm:"column:amount;type:numeric(65,30);not null" json:"amount"`
Currency *string `gorm:"column:currency;type:text;not null;default:USD" json:"currency"`
Status *string `gorm:"column:status;type:character varying(20);not null;default:PENDING" json:"status"`
Provider *string `gorm:"column:provider;type:character varying(20);not null;default:STRIPE" json:"provider"`
TransactionID *string `gorm:"column:transaction_id;type:text" json:"transaction_id"`
CreatedAt *time.Time `gorm:"column:created_at;type:timestamp(3) without time zone;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp(3) without time zone;not null" json:"updated_at"`
Version *int64 `gorm:"column:version;type:bigint;not null;default:1;version" json:"-"`
}
// TableName Payment's table name

View File

@@ -8,17 +8,18 @@ const TableNamePlan = "plan"
// Plan mapped from table <plan>
type Plan struct {
ID string `gorm:"column:id;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"column:name;not null" json:"name"`
Description string `gorm:"column:description" json:"description"`
Price float64 `gorm:"column:price;not null" json:"price"`
Cycle string `gorm:"column:cycle;not null" json:"cycle"`
StorageLimit int64 `gorm:"column:storage_limit;not null" json:"storage_limit"`
UploadLimit int32 `gorm:"column:upload_limit;not null" json:"upload_limit"`
DurationLimit int32 `gorm:"column:duration_limit;not null" json:"duration_limit"`
QualityLimit string `gorm:"column:quality_limit;not null" json:"quality_limit"`
Features string `gorm:"column:features" json:"features"`
IsActive bool `gorm:"column:is_active;not null;default:true" json:"is_active"`
ID string `gorm:"column:id;type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"column:name;type:text;not null" json:"name"`
Description *string `gorm:"column:description;type:text" json:"description"`
Price float64 `gorm:"column:price;type:numeric(65,30);not null" json:"price"`
Cycle string `gorm:"column:cycle;type:character varying(20);not null" json:"cycle"`
StorageLimit int64 `gorm:"column:storage_limit;type:bigint;not null" json:"storage_limit"`
UploadLimit int32 `gorm:"column:upload_limit;type:integer;not null" json:"upload_limit"`
DurationLimit int32 `gorm:"column:duration_limit;type:integer;not null" json:"duration_limit"`
QualityLimit string `gorm:"column:quality_limit;type:text;not null" json:"quality_limit"`
Features *string `gorm:"column:features;type:text[]" json:"features"`
IsActive *bool `gorm:"column:is_active;type:boolean;not null;default:true" json:"is_active"`
Version *int64 `gorm:"column:version;type:bigint;not null;default:1;version" json:"-"`
}
// TableName Plan's table name

View File

@@ -12,17 +12,18 @@ const TableNameUser = "user"
// User mapped from table <user>
type User struct {
ID string `gorm:"column:id;primaryKey;default:gen_random_uuid()" json:"id"`
Email string `gorm:"column:email;not null" json:"email"`
Password string `gorm:"column:password" json:"-"`
Username string `gorm:"column:username" json:"username"`
Avatar string `gorm:"column:avatar" json:"avatar"`
Role string `gorm:"column:role;not null;default:USER" json:"role"`
GoogleID string `gorm:"column:google_id" json:"google_id"`
StorageUsed int64 `gorm:"column:storage_used;not null" json:"storage_used"`
PlanID string `gorm:"column:plan_id" json:"plan_id"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
ID string `gorm:"column:id;type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Email string `gorm:"column:email;type:text;not null;uniqueIndex:user_email_key,priority:1" json:"email"`
Password *string `gorm:"column:password;type:text" json:"-"`
Username *string `gorm:"column:username;type:text" json:"username"`
Avatar *string `gorm:"column:avatar;type:text" json:"avatar"`
Role *string `gorm:"column:role;type:character varying(20);not null;default:USER" json:"role"`
GoogleID *string `gorm:"column:google_id;type:text;uniqueIndex:user_google_id_key,priority:1" json:"google_id"`
StorageUsed int64 `gorm:"column:storage_used;type:bigint;not null" json:"storage_used"`
PlanID *string `gorm:"column:plan_id;type:uuid" json:"plan_id"`
CreatedAt *time.Time `gorm:"column:created_at;type:timestamp(3) without time zone;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp(3) without time zone;not null" json:"updated_at"`
Version *int64 `gorm:"column:version;type:bigint;not null;default:1;version" json:"-"`
}
// TableName User's table name

View File

@@ -12,24 +12,25 @@ const TableNameVideo = "video"
// Video mapped from table <video>
type Video struct {
ID string `gorm:"column:id;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"column:name;not null" json:"name"`
Title string `gorm:"column:title;not null" json:"title"`
Description string `gorm:"column:description" json:"description"`
URL string `gorm:"column:url;not null" json:"url"`
Thumbnail string `gorm:"column:thumbnail" json:"thumbnail"`
HlsToken string `gorm:"column:hls_token" json:"hls_token"`
HlsPath string `gorm:"column:hls_path" json:"hls_path"`
Duration int32 `gorm:"column:duration;not null" json:"duration"`
Size int64 `gorm:"column:size;not null" json:"size"`
StorageType string `gorm:"column:storage_type;not null;default:tiktok_avatar" json:"storage_type"`
Format string `gorm:"column:format;not null" json:"format"`
Status string `gorm:"column:status;not null;default:PUBLIC" json:"status"`
ProcessingStatus string `gorm:"column:processing_status;not null;default:PENDING" json:"processing_status"`
Views int32 `gorm:"column:views;not null" json:"views"`
UserID string `gorm:"column:user_id;not null" json:"user_id"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
ID string `gorm:"column:id;type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"column:name;type:text;not null" json:"name"`
Title string `gorm:"column:title;type:text;not null" json:"title"`
Description *string `gorm:"column:description;type:text" json:"description"`
URL string `gorm:"column:url;type:text;not null" json:"url"`
Thumbnail *string `gorm:"column:thumbnail;type:text" json:"thumbnail"`
HlsToken *string `gorm:"column:hls_token;type:text" json:"hls_token"`
HlsPath *string `gorm:"column:hls_path;type:text" json:"hls_path"`
Duration int32 `gorm:"column:duration;type:integer;not null" json:"duration"`
Size int64 `gorm:"column:size;type:bigint;not null" json:"size"`
StorageType *string `gorm:"column:storage_type;type:character varying(20);not null;default:tiktok_avatar" json:"storage_type"`
Format string `gorm:"column:format;type:text;not null" json:"format"`
Status *string `gorm:"column:status;type:character varying(20);not null;default:PUBLIC" json:"status"`
ProcessingStatus *string `gorm:"column:processing_status;type:character varying(20);not null;default:PENDING" json:"processing_status"`
Views int32 `gorm:"column:views;type:integer;not null" json:"views"`
UserID string `gorm:"column:user_id;type:uuid;not null" json:"user_id"`
CreatedAt *time.Time `gorm:"column:created_at;type:timestamp(3) without time zone;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp(3) without time zone;not null" json:"updated_at"`
Version *int64 `gorm:"column:version;type:bigint;not null;default:1;version" json:"-"`
}
// TableName Video's table name

View File

@@ -38,6 +38,7 @@ func newPayment(db *gorm.DB, opts ...gen.DOOption) payment {
_payment.TransactionID = field.NewString(tableName, "transaction_id")
_payment.CreatedAt = field.NewTime(tableName, "created_at")
_payment.UpdatedAt = field.NewTime(tableName, "updated_at")
_payment.Version = field.NewInt64(tableName, "version")
_payment.fillFieldMap()
@@ -58,6 +59,7 @@ type payment struct {
TransactionID field.String
CreatedAt field.Time
UpdatedAt field.Time
Version field.Int64
fieldMap map[string]field.Expr
}
@@ -84,6 +86,7 @@ func (p *payment) updateTableName(table string) *payment {
p.TransactionID = field.NewString(table, "transaction_id")
p.CreatedAt = field.NewTime(table, "created_at")
p.UpdatedAt = field.NewTime(table, "updated_at")
p.Version = field.NewInt64(table, "version")
p.fillFieldMap()
@@ -108,7 +111,7 @@ func (p *payment) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (p *payment) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 10)
p.fieldMap = make(map[string]field.Expr, 11)
p.fieldMap["id"] = p.ID
p.fieldMap["user_id"] = p.UserID
p.fieldMap["plan_id"] = p.PlanID
@@ -119,6 +122,7 @@ func (p *payment) fillFieldMap() {
p.fieldMap["transaction_id"] = p.TransactionID
p.fieldMap["created_at"] = p.CreatedAt
p.fieldMap["updated_at"] = p.UpdatedAt
p.fieldMap["version"] = p.Version
}
func (p payment) clone(db *gorm.DB) payment {

View File

@@ -39,6 +39,7 @@ func newPlan(db *gorm.DB, opts ...gen.DOOption) plan {
_plan.QualityLimit = field.NewString(tableName, "quality_limit")
_plan.Features = field.NewString(tableName, "features")
_plan.IsActive = field.NewBool(tableName, "is_active")
_plan.Version = field.NewInt64(tableName, "version")
_plan.fillFieldMap()
@@ -60,6 +61,7 @@ type plan struct {
QualityLimit field.String
Features field.String
IsActive field.Bool
Version field.Int64
fieldMap map[string]field.Expr
}
@@ -87,6 +89,7 @@ func (p *plan) updateTableName(table string) *plan {
p.QualityLimit = field.NewString(table, "quality_limit")
p.Features = field.NewString(table, "features")
p.IsActive = field.NewBool(table, "is_active")
p.Version = field.NewInt64(table, "version")
p.fillFieldMap()
@@ -111,7 +114,7 @@ func (p *plan) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (p *plan) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 11)
p.fieldMap = make(map[string]field.Expr, 12)
p.fieldMap["id"] = p.ID
p.fieldMap["name"] = p.Name
p.fieldMap["description"] = p.Description
@@ -123,6 +126,7 @@ func (p *plan) fillFieldMap() {
p.fieldMap["quality_limit"] = p.QualityLimit
p.fieldMap["features"] = p.Features
p.fieldMap["is_active"] = p.IsActive
p.fieldMap["version"] = p.Version
}
func (p plan) clone(db *gorm.DB) plan {

View File

@@ -39,6 +39,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
_user.PlanID = field.NewString(tableName, "plan_id")
_user.CreatedAt = field.NewTime(tableName, "created_at")
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
_user.Version = field.NewInt64(tableName, "version")
_user.fillFieldMap()
@@ -60,6 +61,7 @@ type user struct {
PlanID field.String
CreatedAt field.Time
UpdatedAt field.Time
Version field.Int64
fieldMap map[string]field.Expr
}
@@ -87,6 +89,7 @@ func (u *user) updateTableName(table string) *user {
u.PlanID = field.NewString(table, "plan_id")
u.CreatedAt = field.NewTime(table, "created_at")
u.UpdatedAt = field.NewTime(table, "updated_at")
u.Version = field.NewInt64(table, "version")
u.fillFieldMap()
@@ -111,7 +114,7 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (u *user) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 11)
u.fieldMap = make(map[string]field.Expr, 12)
u.fieldMap["id"] = u.ID
u.fieldMap["email"] = u.Email
u.fieldMap["password"] = u.Password
@@ -123,6 +126,7 @@ func (u *user) fillFieldMap() {
u.fieldMap["plan_id"] = u.PlanID
u.fieldMap["created_at"] = u.CreatedAt
u.fieldMap["updated_at"] = u.UpdatedAt
u.fieldMap["version"] = u.Version
}
func (u user) clone(db *gorm.DB) user {

View File

@@ -46,6 +46,7 @@ func newVideo(db *gorm.DB, opts ...gen.DOOption) video {
_video.UserID = field.NewString(tableName, "user_id")
_video.CreatedAt = field.NewTime(tableName, "created_at")
_video.UpdatedAt = field.NewTime(tableName, "updated_at")
_video.Version = field.NewInt64(tableName, "version")
_video.fillFieldMap()
@@ -74,6 +75,7 @@ type video struct {
UserID field.String
CreatedAt field.Time
UpdatedAt field.Time
Version field.Int64
fieldMap map[string]field.Expr
}
@@ -108,6 +110,7 @@ func (v *video) updateTableName(table string) *video {
v.UserID = field.NewString(table, "user_id")
v.CreatedAt = field.NewTime(table, "created_at")
v.UpdatedAt = field.NewTime(table, "updated_at")
v.Version = field.NewInt64(table, "version")
v.fillFieldMap()
@@ -132,7 +135,7 @@ func (v *video) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (v *video) fillFieldMap() {
v.fieldMap = make(map[string]field.Expr, 18)
v.fieldMap = make(map[string]field.Expr, 19)
v.fieldMap["id"] = v.ID
v.fieldMap["name"] = v.Name
v.fieldMap["title"] = v.Title
@@ -151,6 +154,7 @@ func (v *video) fillFieldMap() {
v.fieldMap["user_id"] = v.UserID
v.fieldMap["created_at"] = v.CreatedAt
v.fieldMap["updated_at"] = v.UpdatedAt
v.fieldMap["version"] = v.Version
}
func (v video) clone(db *gorm.DB) video {