123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // 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/gen"
- "gorm.io/plugin/dbresolver"
- )
- func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
- return &Query{
- db: db,
- AdLog: newAdLog(db, opts...),
- GuideLog: newGuideLog(db, opts...),
- LoginLog: newLoginLog(db, opts...),
- OnlineDurationLog: newOnlineDurationLog(db, opts...),
- }
- }
- type Query struct {
- db *gorm.DB
- AdLog adLog
- GuideLog guideLog
- LoginLog loginLog
- OnlineDurationLog onlineDurationLog
- }
- func (q *Query) Available() bool { return q.db != nil }
- func (q *Query) clone(db *gorm.DB) *Query {
- return &Query{
- db: db,
- AdLog: q.AdLog.clone(db),
- GuideLog: q.GuideLog.clone(db),
- LoginLog: q.LoginLog.clone(db),
- OnlineDurationLog: q.OnlineDurationLog.clone(db),
- }
- }
- func (q *Query) ReadDB() *Query {
- return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
- }
- func (q *Query) WriteDB() *Query {
- return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
- }
- func (q *Query) ReplaceDB(db *gorm.DB) *Query {
- return &Query{
- db: db,
- AdLog: q.AdLog.replaceDB(db),
- GuideLog: q.GuideLog.replaceDB(db),
- LoginLog: q.LoginLog.replaceDB(db),
- OnlineDurationLog: q.OnlineDurationLog.replaceDB(db),
- }
- }
- type queryCtx struct {
- AdLog *adLogDo
- GuideLog *guideLogDo
- LoginLog *loginLogDo
- OnlineDurationLog *onlineDurationLogDo
- }
- func (q *Query) WithContext(ctx context.Context) *queryCtx {
- return &queryCtx{
- AdLog: q.AdLog.WithContext(ctx),
- GuideLog: q.GuideLog.WithContext(ctx),
- LoginLog: q.LoginLog.WithContext(ctx),
- OnlineDurationLog: q.OnlineDurationLog.WithContext(ctx),
- }
- }
- func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
- return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
- }
- func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
- tx := q.db.Begin(opts...)
- return &QueryTx{Query: q.clone(tx), Error: tx.Error}
- }
- type QueryTx struct {
- *Query
- Error error
- }
- func (q *QueryTx) Commit() error {
- return q.db.Commit().Error
- }
- func (q *QueryTx) Rollback() error {
- return q.db.Rollback().Error
- }
- func (q *QueryTx) SavePoint(name string) error {
- return q.db.SavePoint(name).Error
- }
- func (q *QueryTx) RollbackTo(name string) error {
- return q.db.RollbackTo(name).Error
- }
|