draft grpc

This commit is contained in:
2026-03-13 02:17:18 +00:00
parent ea2edbb9e0
commit 91e5e3542b
116 changed files with 44505 additions and 558 deletions

View File

@@ -0,0 +1,439 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"stream.api/internal/database/model"
)
func newWalletTransaction(db *gorm.DB, opts ...gen.DOOption) walletTransaction {
_walletTransaction := walletTransaction{}
_walletTransaction.walletTransactionDo.UseDB(db, opts...)
_walletTransaction.walletTransactionDo.UseModel(&model.WalletTransaction{})
tableName := _walletTransaction.walletTransactionDo.TableName()
_walletTransaction.ALL = field.NewAsterisk(tableName)
_walletTransaction.ID = field.NewString(tableName, "id")
_walletTransaction.UserID = field.NewString(tableName, "user_id")
_walletTransaction.Type = field.NewString(tableName, "type")
_walletTransaction.Amount = field.NewFloat64(tableName, "amount")
_walletTransaction.Currency = field.NewString(tableName, "currency")
_walletTransaction.Note = field.NewString(tableName, "note")
_walletTransaction.CreatedAt = field.NewTime(tableName, "created_at")
_walletTransaction.UpdatedAt = field.NewTime(tableName, "updated_at")
_walletTransaction.PaymentID = field.NewString(tableName, "payment_id")
_walletTransaction.PlanID = field.NewString(tableName, "plan_id")
_walletTransaction.TermMonths = field.NewInt32(tableName, "term_months")
_walletTransaction.Version = field.NewInt64(tableName, "version")
_walletTransaction.fillFieldMap()
return _walletTransaction
}
type walletTransaction struct {
walletTransactionDo walletTransactionDo
ALL field.Asterisk
ID field.String
UserID field.String
Type field.String
Amount field.Float64
Currency field.String
Note field.String
CreatedAt field.Time
UpdatedAt field.Time
PaymentID field.String
PlanID field.String
TermMonths field.Int32
Version field.Int64
fieldMap map[string]field.Expr
}
func (w walletTransaction) Table(newTableName string) *walletTransaction {
w.walletTransactionDo.UseTable(newTableName)
return w.updateTableName(newTableName)
}
func (w walletTransaction) As(alias string) *walletTransaction {
w.walletTransactionDo.DO = *(w.walletTransactionDo.As(alias).(*gen.DO))
return w.updateTableName(alias)
}
func (w *walletTransaction) updateTableName(table string) *walletTransaction {
w.ALL = field.NewAsterisk(table)
w.ID = field.NewString(table, "id")
w.UserID = field.NewString(table, "user_id")
w.Type = field.NewString(table, "type")
w.Amount = field.NewFloat64(table, "amount")
w.Currency = field.NewString(table, "currency")
w.Note = field.NewString(table, "note")
w.CreatedAt = field.NewTime(table, "created_at")
w.UpdatedAt = field.NewTime(table, "updated_at")
w.PaymentID = field.NewString(table, "payment_id")
w.PlanID = field.NewString(table, "plan_id")
w.TermMonths = field.NewInt32(table, "term_months")
w.Version = field.NewInt64(table, "version")
w.fillFieldMap()
return w
}
func (w *walletTransaction) WithContext(ctx context.Context) IWalletTransactionDo {
return w.walletTransactionDo.WithContext(ctx)
}
func (w walletTransaction) TableName() string { return w.walletTransactionDo.TableName() }
func (w walletTransaction) Alias() string { return w.walletTransactionDo.Alias() }
func (w walletTransaction) Columns(cols ...field.Expr) gen.Columns {
return w.walletTransactionDo.Columns(cols...)
}
func (w *walletTransaction) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := w.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (w *walletTransaction) fillFieldMap() {
w.fieldMap = make(map[string]field.Expr, 12)
w.fieldMap["id"] = w.ID
w.fieldMap["user_id"] = w.UserID
w.fieldMap["type"] = w.Type
w.fieldMap["amount"] = w.Amount
w.fieldMap["currency"] = w.Currency
w.fieldMap["note"] = w.Note
w.fieldMap["created_at"] = w.CreatedAt
w.fieldMap["updated_at"] = w.UpdatedAt
w.fieldMap["payment_id"] = w.PaymentID
w.fieldMap["plan_id"] = w.PlanID
w.fieldMap["term_months"] = w.TermMonths
w.fieldMap["version"] = w.Version
}
func (w walletTransaction) clone(db *gorm.DB) walletTransaction {
w.walletTransactionDo.ReplaceConnPool(db.Statement.ConnPool)
return w
}
func (w walletTransaction) replaceDB(db *gorm.DB) walletTransaction {
w.walletTransactionDo.ReplaceDB(db)
return w
}
type walletTransactionDo struct{ gen.DO }
type IWalletTransactionDo interface {
gen.SubQuery
Debug() IWalletTransactionDo
WithContext(ctx context.Context) IWalletTransactionDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IWalletTransactionDo
WriteDB() IWalletTransactionDo
As(alias string) gen.Dao
Session(config *gorm.Session) IWalletTransactionDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IWalletTransactionDo
Not(conds ...gen.Condition) IWalletTransactionDo
Or(conds ...gen.Condition) IWalletTransactionDo
Select(conds ...field.Expr) IWalletTransactionDo
Where(conds ...gen.Condition) IWalletTransactionDo
Order(conds ...field.Expr) IWalletTransactionDo
Distinct(cols ...field.Expr) IWalletTransactionDo
Omit(cols ...field.Expr) IWalletTransactionDo
Join(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
LeftJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
RightJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
Group(cols ...field.Expr) IWalletTransactionDo
Having(conds ...gen.Condition) IWalletTransactionDo
Limit(limit int) IWalletTransactionDo
Offset(offset int) IWalletTransactionDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IWalletTransactionDo
Unscoped() IWalletTransactionDo
Create(values ...*model.WalletTransaction) error
CreateInBatches(values []*model.WalletTransaction, batchSize int) error
Save(values ...*model.WalletTransaction) error
First() (*model.WalletTransaction, error)
Take() (*model.WalletTransaction, error)
Last() (*model.WalletTransaction, error)
Find() ([]*model.WalletTransaction, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WalletTransaction, err error)
FindInBatches(result *[]*model.WalletTransaction, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.WalletTransaction) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IWalletTransactionDo
Assign(attrs ...field.AssignExpr) IWalletTransactionDo
Joins(fields ...field.RelationField) IWalletTransactionDo
Preload(fields ...field.RelationField) IWalletTransactionDo
FirstOrInit() (*model.WalletTransaction, error)
FirstOrCreate() (*model.WalletTransaction, error)
FindByPage(offset int, limit int) (result []*model.WalletTransaction, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Rows() (*sql.Rows, error)
Row() *sql.Row
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IWalletTransactionDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (w walletTransactionDo) Debug() IWalletTransactionDo {
return w.withDO(w.DO.Debug())
}
func (w walletTransactionDo) WithContext(ctx context.Context) IWalletTransactionDo {
return w.withDO(w.DO.WithContext(ctx))
}
func (w walletTransactionDo) ReadDB() IWalletTransactionDo {
return w.Clauses(dbresolver.Read)
}
func (w walletTransactionDo) WriteDB() IWalletTransactionDo {
return w.Clauses(dbresolver.Write)
}
func (w walletTransactionDo) Session(config *gorm.Session) IWalletTransactionDo {
return w.withDO(w.DO.Session(config))
}
func (w walletTransactionDo) Clauses(conds ...clause.Expression) IWalletTransactionDo {
return w.withDO(w.DO.Clauses(conds...))
}
func (w walletTransactionDo) Returning(value interface{}, columns ...string) IWalletTransactionDo {
return w.withDO(w.DO.Returning(value, columns...))
}
func (w walletTransactionDo) Not(conds ...gen.Condition) IWalletTransactionDo {
return w.withDO(w.DO.Not(conds...))
}
func (w walletTransactionDo) Or(conds ...gen.Condition) IWalletTransactionDo {
return w.withDO(w.DO.Or(conds...))
}
func (w walletTransactionDo) Select(conds ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Select(conds...))
}
func (w walletTransactionDo) Where(conds ...gen.Condition) IWalletTransactionDo {
return w.withDO(w.DO.Where(conds...))
}
func (w walletTransactionDo) Order(conds ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Order(conds...))
}
func (w walletTransactionDo) Distinct(cols ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Distinct(cols...))
}
func (w walletTransactionDo) Omit(cols ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Omit(cols...))
}
func (w walletTransactionDo) Join(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Join(table, on...))
}
func (w walletTransactionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.LeftJoin(table, on...))
}
func (w walletTransactionDo) RightJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.RightJoin(table, on...))
}
func (w walletTransactionDo) Group(cols ...field.Expr) IWalletTransactionDo {
return w.withDO(w.DO.Group(cols...))
}
func (w walletTransactionDo) Having(conds ...gen.Condition) IWalletTransactionDo {
return w.withDO(w.DO.Having(conds...))
}
func (w walletTransactionDo) Limit(limit int) IWalletTransactionDo {
return w.withDO(w.DO.Limit(limit))
}
func (w walletTransactionDo) Offset(offset int) IWalletTransactionDo {
return w.withDO(w.DO.Offset(offset))
}
func (w walletTransactionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWalletTransactionDo {
return w.withDO(w.DO.Scopes(funcs...))
}
func (w walletTransactionDo) Unscoped() IWalletTransactionDo {
return w.withDO(w.DO.Unscoped())
}
func (w walletTransactionDo) Create(values ...*model.WalletTransaction) error {
if len(values) == 0 {
return nil
}
return w.DO.Create(values)
}
func (w walletTransactionDo) CreateInBatches(values []*model.WalletTransaction, batchSize int) error {
return w.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (w walletTransactionDo) Save(values ...*model.WalletTransaction) error {
if len(values) == 0 {
return nil
}
return w.DO.Save(values)
}
func (w walletTransactionDo) First() (*model.WalletTransaction, error) {
if result, err := w.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.WalletTransaction), nil
}
}
func (w walletTransactionDo) Take() (*model.WalletTransaction, error) {
if result, err := w.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.WalletTransaction), nil
}
}
func (w walletTransactionDo) Last() (*model.WalletTransaction, error) {
if result, err := w.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.WalletTransaction), nil
}
}
func (w walletTransactionDo) Find() ([]*model.WalletTransaction, error) {
result, err := w.DO.Find()
return result.([]*model.WalletTransaction), err
}
func (w walletTransactionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WalletTransaction, err error) {
buf := make([]*model.WalletTransaction, 0, batchSize)
err = w.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (w walletTransactionDo) FindInBatches(result *[]*model.WalletTransaction, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return w.DO.FindInBatches(result, batchSize, fc)
}
func (w walletTransactionDo) Attrs(attrs ...field.AssignExpr) IWalletTransactionDo {
return w.withDO(w.DO.Attrs(attrs...))
}
func (w walletTransactionDo) Assign(attrs ...field.AssignExpr) IWalletTransactionDo {
return w.withDO(w.DO.Assign(attrs...))
}
func (w walletTransactionDo) Joins(fields ...field.RelationField) IWalletTransactionDo {
for _, _f := range fields {
w = *w.withDO(w.DO.Joins(_f))
}
return &w
}
func (w walletTransactionDo) Preload(fields ...field.RelationField) IWalletTransactionDo {
for _, _f := range fields {
w = *w.withDO(w.DO.Preload(_f))
}
return &w
}
func (w walletTransactionDo) FirstOrInit() (*model.WalletTransaction, error) {
if result, err := w.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.WalletTransaction), nil
}
}
func (w walletTransactionDo) FirstOrCreate() (*model.WalletTransaction, error) {
if result, err := w.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.WalletTransaction), nil
}
}
func (w walletTransactionDo) FindByPage(offset int, limit int) (result []*model.WalletTransaction, count int64, err error) {
result, err = w.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = w.Offset(-1).Limit(-1).Count()
return
}
func (w walletTransactionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = w.Count()
if err != nil {
return
}
err = w.Offset(offset).Limit(limit).Scan(result)
return
}
func (w walletTransactionDo) Scan(result interface{}) (err error) {
return w.DO.Scan(result)
}
func (w walletTransactionDo) Delete(models ...*model.WalletTransaction) (result gen.ResultInfo, err error) {
return w.DO.Delete(models)
}
func (w *walletTransactionDo) withDO(do gen.Dao) *walletTransactionDo {
w.DO = *do.(*gen.DO)
return w
}