// 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 TableNameTenantLedger = "tenant_ledgers" // TenantLedger mapped from table type TenantLedger 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"` OrderID int64 `gorm:"column:order_id;type:bigint" json:"order_id"` Type string `gorm:"column:type;type:character varying(32);not null" json:"type"` Amount int64 `gorm:"column:amount;type:bigint;not null" json:"amount"` BalanceBefore int64 `gorm:"column:balance_before;type:bigint;not null" json:"balance_before"` BalanceAfter int64 `gorm:"column:balance_after;type:bigint;not null" json:"balance_after"` FrozenBefore int64 `gorm:"column:frozen_before;type:bigint;not null" json:"frozen_before"` FrozenAfter int64 `gorm:"column:frozen_after;type:bigint;not null" json:"frozen_after"` IdempotencyKey string `gorm:"column:idempotency_key;type:character varying(128);not null" json:"idempotency_key"` Remark string `gorm:"column:remark;type:character varying(255);not null" json:"remark"` OperatorUserID int64 `gorm:"column:operator_user_id;type:bigint" json:"operator_user_id"` BizRefType string `gorm:"column:biz_ref_type;type:character varying(32)" json:"biz_ref_type"` BizRefID int64 `gorm:"column:biz_ref_id;type:bigint" json:"biz_ref_id"` 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 *TenantLedger) Update(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantLedger.WithContext(ctx).Updates(m) } // Save upserts the model using the default DB. func (m *TenantLedger) Save(ctx context.Context) error { return Q.TenantLedger.WithContext(ctx).Save(m) } // Create inserts the model using the default DB. func (m *TenantLedger) Create(ctx context.Context) error { return Q.TenantLedger.WithContext(ctx).Create(m) } // Delete removes the row represented by the model using the default DB. func (m *TenantLedger) Delete(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantLedger.WithContext(ctx).Delete(m) } // ForceDelete permanently deletes the row (ignores soft delete) using the default DB. func (m *TenantLedger) ForceDelete(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantLedger.WithContext(ctx).Unscoped().Delete(m) } // Reload reloads the model from database by its primary key and overwrites current fields. func (m *TenantLedger) Reload(ctx context.Context) error { fresh, err := Q.TenantLedger.WithContext(ctx).GetByID(m.ID) if err != nil { return err } *m = *fresh return nil }