Files
quyun-v2/backend/database/models/content_prices.gen.go
2025-12-18 09:54:29 +08:00

69 lines
3.0 KiB
Go

// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
package models
import (
"context"
"time"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
)
const TableNameContentPrice = "content_prices"
// ContentPrice mapped from table <content_prices>
type ContentPrice 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"`
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
Currency consts.Currency `gorm:"column:currency;type:character varying(16);not null;default:CNY" json:"currency"`
PriceAmount int64 `gorm:"column:price_amount;type:bigint;not null" json:"price_amount"`
DiscountType consts.DiscountType `gorm:"column:discount_type;type:character varying(16);not null;default:none" json:"discount_type"`
DiscountValue int64 `gorm:"column:discount_value;type:bigint;not null" json:"discount_value"`
DiscountStartAt time.Time `gorm:"column:discount_start_at;type:timestamp with time zone" json:"discount_start_at"`
DiscountEndAt time.Time `gorm:"column:discount_end_at;type:timestamp with time zone" json:"discount_end_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
}
// Quick operations without importing query package
// Update applies changed fields to the database using the default DB.
func (m *ContentPrice) Update(ctx context.Context) (gen.ResultInfo, error) {
return Q.ContentPrice.WithContext(ctx).Updates(m)
}
// Save upserts the model using the default DB.
func (m *ContentPrice) Save(ctx context.Context) error {
return Q.ContentPrice.WithContext(ctx).Save(m)
}
// Create inserts the model using the default DB.
func (m *ContentPrice) Create(ctx context.Context) error {
return Q.ContentPrice.WithContext(ctx).Create(m)
}
// Delete removes the row represented by the model using the default DB.
func (m *ContentPrice) Delete(ctx context.Context) (gen.ResultInfo, error) {
return Q.ContentPrice.WithContext(ctx).Delete(m)
}
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
func (m *ContentPrice) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
return Q.ContentPrice.WithContext(ctx).Unscoped().Delete(m)
}
// Reload reloads the model from database by its primary key and overwrites current fields.
func (m *ContentPrice) Reload(ctx context.Context) error {
fresh, err := Q.ContentPrice.WithContext(ctx).GetByID(m.ID)
if err != nil {
return err
}
*m = *fresh
return nil
}