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

288 lines
10 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"
"database/sql"
"gorm.io/gorm"
"go.ipao.vip/gen"
"gorm.io/plugin/dbresolver"
)
var (
Q = new(Query)
AuditLogQuery *auditLogQuery
CommentQuery *commentQuery
ContentQuery *contentQuery
ContentAccessQuery *contentAccessQuery
ContentAssetQuery *contentAssetQuery
ContentPriceQuery *contentPriceQuery
ContentReportQuery *contentReportQuery
CouponQuery *couponQuery
MediaAssetQuery *mediaAssetQuery
NotificationQuery *notificationQuery
NotificationTemplateQuery *notificationTemplateQuery
OrderQuery *orderQuery
OrderItemQuery *orderItemQuery
PayoutAccountQuery *payoutAccountQuery
SystemConfigQuery *systemConfigQuery
TenantQuery *tenantQuery
TenantInviteQuery *tenantInviteQuery
TenantJoinRequestQuery *tenantJoinRequestQuery
TenantLedgerQuery *tenantLedgerQuery
TenantUserQuery *tenantUserQuery
UserQuery *userQuery
UserCommentActionQuery *userCommentActionQuery
UserContentActionQuery *userContentActionQuery
UserCouponQuery *userCouponQuery
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
AuditLogQuery = &Q.AuditLog
CommentQuery = &Q.Comment
ContentQuery = &Q.Content
ContentAccessQuery = &Q.ContentAccess
ContentAssetQuery = &Q.ContentAsset
ContentPriceQuery = &Q.ContentPrice
ContentReportQuery = &Q.ContentReport
CouponQuery = &Q.Coupon
MediaAssetQuery = &Q.MediaAsset
NotificationQuery = &Q.Notification
NotificationTemplateQuery = &Q.NotificationTemplate
OrderQuery = &Q.Order
OrderItemQuery = &Q.OrderItem
PayoutAccountQuery = &Q.PayoutAccount
SystemConfigQuery = &Q.SystemConfig
TenantQuery = &Q.Tenant
TenantInviteQuery = &Q.TenantInvite
TenantJoinRequestQuery = &Q.TenantJoinRequest
TenantLedgerQuery = &Q.TenantLedger
TenantUserQuery = &Q.TenantUser
UserQuery = &Q.User
UserCommentActionQuery = &Q.UserCommentAction
UserContentActionQuery = &Q.UserContentAction
UserCouponQuery = &Q.UserCoupon
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
AuditLog: newAuditLog(db, opts...),
Comment: newComment(db, opts...),
Content: newContent(db, opts...),
ContentAccess: newContentAccess(db, opts...),
ContentAsset: newContentAsset(db, opts...),
ContentPrice: newContentPrice(db, opts...),
ContentReport: newContentReport(db, opts...),
Coupon: newCoupon(db, opts...),
MediaAsset: newMediaAsset(db, opts...),
Notification: newNotification(db, opts...),
NotificationTemplate: newNotificationTemplate(db, opts...),
Order: newOrder(db, opts...),
OrderItem: newOrderItem(db, opts...),
PayoutAccount: newPayoutAccount(db, opts...),
SystemConfig: newSystemConfig(db, opts...),
Tenant: newTenant(db, opts...),
TenantInvite: newTenantInvite(db, opts...),
TenantJoinRequest: newTenantJoinRequest(db, opts...),
TenantLedger: newTenantLedger(db, opts...),
TenantUser: newTenantUser(db, opts...),
User: newUser(db, opts...),
UserCommentAction: newUserCommentAction(db, opts...),
UserContentAction: newUserContentAction(db, opts...),
UserCoupon: newUserCoupon(db, opts...),
}
}
type Query struct {
db *gorm.DB
AuditLog auditLogQuery
Comment commentQuery
Content contentQuery
ContentAccess contentAccessQuery
ContentAsset contentAssetQuery
ContentPrice contentPriceQuery
ContentReport contentReportQuery
Coupon couponQuery
MediaAsset mediaAssetQuery
Notification notificationQuery
NotificationTemplate notificationTemplateQuery
Order orderQuery
OrderItem orderItemQuery
PayoutAccount payoutAccountQuery
SystemConfig systemConfigQuery
Tenant tenantQuery
TenantInvite tenantInviteQuery
TenantJoinRequest tenantJoinRequestQuery
TenantLedger tenantLedgerQuery
TenantUser tenantUserQuery
User userQuery
UserCommentAction userCommentActionQuery
UserContentAction userContentActionQuery
UserCoupon userCouponQuery
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
AuditLog: q.AuditLog.clone(db),
Comment: q.Comment.clone(db),
Content: q.Content.clone(db),
ContentAccess: q.ContentAccess.clone(db),
ContentAsset: q.ContentAsset.clone(db),
ContentPrice: q.ContentPrice.clone(db),
ContentReport: q.ContentReport.clone(db),
Coupon: q.Coupon.clone(db),
MediaAsset: q.MediaAsset.clone(db),
Notification: q.Notification.clone(db),
NotificationTemplate: q.NotificationTemplate.clone(db),
Order: q.Order.clone(db),
OrderItem: q.OrderItem.clone(db),
PayoutAccount: q.PayoutAccount.clone(db),
SystemConfig: q.SystemConfig.clone(db),
Tenant: q.Tenant.clone(db),
TenantInvite: q.TenantInvite.clone(db),
TenantJoinRequest: q.TenantJoinRequest.clone(db),
TenantLedger: q.TenantLedger.clone(db),
TenantUser: q.TenantUser.clone(db),
User: q.User.clone(db),
UserCommentAction: q.UserCommentAction.clone(db),
UserContentAction: q.UserContentAction.clone(db),
UserCoupon: q.UserCoupon.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,
AuditLog: q.AuditLog.replaceDB(db),
Comment: q.Comment.replaceDB(db),
Content: q.Content.replaceDB(db),
ContentAccess: q.ContentAccess.replaceDB(db),
ContentAsset: q.ContentAsset.replaceDB(db),
ContentPrice: q.ContentPrice.replaceDB(db),
ContentReport: q.ContentReport.replaceDB(db),
Coupon: q.Coupon.replaceDB(db),
MediaAsset: q.MediaAsset.replaceDB(db),
Notification: q.Notification.replaceDB(db),
NotificationTemplate: q.NotificationTemplate.replaceDB(db),
Order: q.Order.replaceDB(db),
OrderItem: q.OrderItem.replaceDB(db),
PayoutAccount: q.PayoutAccount.replaceDB(db),
SystemConfig: q.SystemConfig.replaceDB(db),
Tenant: q.Tenant.replaceDB(db),
TenantInvite: q.TenantInvite.replaceDB(db),
TenantJoinRequest: q.TenantJoinRequest.replaceDB(db),
TenantLedger: q.TenantLedger.replaceDB(db),
TenantUser: q.TenantUser.replaceDB(db),
User: q.User.replaceDB(db),
UserCommentAction: q.UserCommentAction.replaceDB(db),
UserContentAction: q.UserContentAction.replaceDB(db),
UserCoupon: q.UserCoupon.replaceDB(db),
}
}
type queryCtx struct {
AuditLog *auditLogQueryDo
Comment *commentQueryDo
Content *contentQueryDo
ContentAccess *contentAccessQueryDo
ContentAsset *contentAssetQueryDo
ContentPrice *contentPriceQueryDo
ContentReport *contentReportQueryDo
Coupon *couponQueryDo
MediaAsset *mediaAssetQueryDo
Notification *notificationQueryDo
NotificationTemplate *notificationTemplateQueryDo
Order *orderQueryDo
OrderItem *orderItemQueryDo
PayoutAccount *payoutAccountQueryDo
SystemConfig *systemConfigQueryDo
Tenant *tenantQueryDo
TenantInvite *tenantInviteQueryDo
TenantJoinRequest *tenantJoinRequestQueryDo
TenantLedger *tenantLedgerQueryDo
TenantUser *tenantUserQueryDo
User *userQueryDo
UserCommentAction *userCommentActionQueryDo
UserContentAction *userContentActionQueryDo
UserCoupon *userCouponQueryDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
AuditLog: q.AuditLog.WithContext(ctx),
Comment: q.Comment.WithContext(ctx),
Content: q.Content.WithContext(ctx),
ContentAccess: q.ContentAccess.WithContext(ctx),
ContentAsset: q.ContentAsset.WithContext(ctx),
ContentPrice: q.ContentPrice.WithContext(ctx),
ContentReport: q.ContentReport.WithContext(ctx),
Coupon: q.Coupon.WithContext(ctx),
MediaAsset: q.MediaAsset.WithContext(ctx),
Notification: q.Notification.WithContext(ctx),
NotificationTemplate: q.NotificationTemplate.WithContext(ctx),
Order: q.Order.WithContext(ctx),
OrderItem: q.OrderItem.WithContext(ctx),
PayoutAccount: q.PayoutAccount.WithContext(ctx),
SystemConfig: q.SystemConfig.WithContext(ctx),
Tenant: q.Tenant.WithContext(ctx),
TenantInvite: q.TenantInvite.WithContext(ctx),
TenantJoinRequest: q.TenantJoinRequest.WithContext(ctx),
TenantLedger: q.TenantLedger.WithContext(ctx),
TenantUser: q.TenantUser.WithContext(ctx),
User: q.User.WithContext(ctx),
UserCommentAction: q.UserCommentAction.WithContext(ctx),
UserContentAction: q.UserContentAction.WithContext(ctx),
UserCoupon: q.UserCoupon.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
}