// 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/fields" "go.ipao.vip/gen" "go.ipao.vip/gen/types" ) const TableNameOrder = "orders" // Order mapped from table 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 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 // Update applies changed fields to the database using the default DB. func (m *Order) Update(ctx context.Context) (gen.ResultInfo, error) { return Q.Order.WithContext(ctx).Updates(m) } // Save upserts the model using the default DB. func (m *Order) Save(ctx context.Context) error { return Q.Order.WithContext(ctx).Save(m) } // Create inserts the model using the default DB. func (m *Order) Create(ctx context.Context) error { return Q.Order.WithContext(ctx).Create(m) } // Delete removes the row represented by the model using the default DB. func (m *Order) Delete(ctx context.Context) (gen.ResultInfo, error) { return Q.Order.WithContext(ctx).Delete(m) } // ForceDelete permanently deletes the row (ignores soft delete) using the default DB. func (m *Order) ForceDelete(ctx context.Context) (gen.ResultInfo, error) { return Q.Order.WithContext(ctx).Unscoped().Delete(m) } // Reload reloads the model from database by its primary key and overwrites current fields. func (m *Order) Reload(ctx context.Context) error { fresh, err := Q.Order.WithContext(ctx).GetByID(m.ID) if err != nil { return err } *m = *fresh return nil }