Files
quyun-v2/backend/database/models/recharge_codes.gen.go

67 lines
2.8 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"
"go.ipao.vip/gen"
)
const TableNameRechargeCode = "recharge_codes"
// RechargeCode mapped from table <recharge_codes>
type RechargeCode struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
Code string `gorm:"column:code;type:character varying(64);not null" json:"code"`
Amount int64 `gorm:"column:amount;type:bigint;not null" json:"amount"`
Status string `gorm:"column:status;type:character varying(32);default:inactive" json:"status"`
ActivatedBy int64 `gorm:"column:activated_by;type:bigint" json:"activated_by"`
ActivatedAt time.Time `gorm:"column:activated_at;type:timestamp with time zone" json:"activated_at"`
RedeemedBy int64 `gorm:"column:redeemed_by;type:bigint" json:"redeemed_by"`
RedeemedAt time.Time `gorm:"column:redeemed_at;type:timestamp with time zone" json:"redeemed_at"`
RedeemedOrderID int64 `gorm:"column:redeemed_order_id;type:bigint" json:"redeemed_order_id"`
Remark string `gorm:"column:remark;type:character varying(255)" json:"remark"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
}
// Quick operations without importing query package
// Update applies changed fields to the database using the default DB.
func (m *RechargeCode) Update(ctx context.Context) (gen.ResultInfo, error) {
return Q.RechargeCode.WithContext(ctx).Updates(m)
}
// Save upserts the model using the default DB.
func (m *RechargeCode) Save(ctx context.Context) error {
return Q.RechargeCode.WithContext(ctx).Save(m)
}
// Create inserts the model using the default DB.
func (m *RechargeCode) Create(ctx context.Context) error {
return Q.RechargeCode.WithContext(ctx).Create(m)
}
// Delete removes the row represented by the model using the default DB.
func (m *RechargeCode) Delete(ctx context.Context) (gen.ResultInfo, error) {
return Q.RechargeCode.WithContext(ctx).Delete(m)
}
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
func (m *RechargeCode) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
return Q.RechargeCode.WithContext(ctx).Unscoped().Delete(m)
}
// Reload reloads the model from database by its primary key and overwrites current fields.
func (m *RechargeCode) Reload(ctx context.Context) error {
fresh, err := Q.RechargeCode.WithContext(ctx).GetByID(m.ID)
if err != nil {
return err
}
*m = *fresh
return nil
}