gen.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package query
  5. import (
  6. "context"
  7. "database/sql"
  8. "gorm.io/gorm"
  9. "gorm.io/gen"
  10. "gorm.io/plugin/dbresolver"
  11. )
  12. var (
  13. Q = new(Query)
  14. AcmeUser *acmeUser
  15. AuthToken *authToken
  16. AutoBackup *autoBackup
  17. BanIP *banIP
  18. Cert *cert
  19. Config *config
  20. ConfigBackup *configBackup
  21. DnsCredential *dnsCredential
  22. ExternalNotify *externalNotify
  23. LLMSession *lLMSession
  24. Namespace *namespace
  25. NginxLogIndex *nginxLogIndex
  26. Node *node
  27. Notification *notification
  28. Passkey *passkey
  29. Site *site
  30. SiteConfig *siteConfig
  31. Stream *stream
  32. UpstreamConfig *upstreamConfig
  33. User *user
  34. )
  35. func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
  36. *Q = *Use(db, opts...)
  37. AcmeUser = &Q.AcmeUser
  38. AuthToken = &Q.AuthToken
  39. AutoBackup = &Q.AutoBackup
  40. BanIP = &Q.BanIP
  41. Cert = &Q.Cert
  42. Config = &Q.Config
  43. ConfigBackup = &Q.ConfigBackup
  44. DnsCredential = &Q.DnsCredential
  45. ExternalNotify = &Q.ExternalNotify
  46. LLMSession = &Q.LLMSession
  47. Namespace = &Q.Namespace
  48. NginxLogIndex = &Q.NginxLogIndex
  49. Node = &Q.Node
  50. Notification = &Q.Notification
  51. Passkey = &Q.Passkey
  52. Site = &Q.Site
  53. SiteConfig = &Q.SiteConfig
  54. Stream = &Q.Stream
  55. UpstreamConfig = &Q.UpstreamConfig
  56. User = &Q.User
  57. }
  58. func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
  59. return &Query{
  60. db: db,
  61. AcmeUser: newAcmeUser(db, opts...),
  62. AuthToken: newAuthToken(db, opts...),
  63. AutoBackup: newAutoBackup(db, opts...),
  64. BanIP: newBanIP(db, opts...),
  65. Cert: newCert(db, opts...),
  66. Config: newConfig(db, opts...),
  67. ConfigBackup: newConfigBackup(db, opts...),
  68. DnsCredential: newDnsCredential(db, opts...),
  69. ExternalNotify: newExternalNotify(db, opts...),
  70. LLMSession: newLLMSession(db, opts...),
  71. Namespace: newNamespace(db, opts...),
  72. NginxLogIndex: newNginxLogIndex(db, opts...),
  73. Node: newNode(db, opts...),
  74. Notification: newNotification(db, opts...),
  75. Passkey: newPasskey(db, opts...),
  76. Site: newSite(db, opts...),
  77. SiteConfig: newSiteConfig(db, opts...),
  78. Stream: newStream(db, opts...),
  79. UpstreamConfig: newUpstreamConfig(db, opts...),
  80. User: newUser(db, opts...),
  81. }
  82. }
  83. type Query struct {
  84. db *gorm.DB
  85. AcmeUser acmeUser
  86. AuthToken authToken
  87. AutoBackup autoBackup
  88. BanIP banIP
  89. Cert cert
  90. Config config
  91. ConfigBackup configBackup
  92. DnsCredential dnsCredential
  93. ExternalNotify externalNotify
  94. LLMSession lLMSession
  95. Namespace namespace
  96. NginxLogIndex nginxLogIndex
  97. Node node
  98. Notification notification
  99. Passkey passkey
  100. Site site
  101. SiteConfig siteConfig
  102. Stream stream
  103. UpstreamConfig upstreamConfig
  104. User user
  105. }
  106. func (q *Query) Available() bool { return q.db != nil }
  107. func (q *Query) clone(db *gorm.DB) *Query {
  108. return &Query{
  109. db: db,
  110. AcmeUser: q.AcmeUser.clone(db),
  111. AuthToken: q.AuthToken.clone(db),
  112. AutoBackup: q.AutoBackup.clone(db),
  113. BanIP: q.BanIP.clone(db),
  114. Cert: q.Cert.clone(db),
  115. Config: q.Config.clone(db),
  116. ConfigBackup: q.ConfigBackup.clone(db),
  117. DnsCredential: q.DnsCredential.clone(db),
  118. ExternalNotify: q.ExternalNotify.clone(db),
  119. LLMSession: q.LLMSession.clone(db),
  120. Namespace: q.Namespace.clone(db),
  121. NginxLogIndex: q.NginxLogIndex.clone(db),
  122. Node: q.Node.clone(db),
  123. Notification: q.Notification.clone(db),
  124. Passkey: q.Passkey.clone(db),
  125. Site: q.Site.clone(db),
  126. SiteConfig: q.SiteConfig.clone(db),
  127. Stream: q.Stream.clone(db),
  128. UpstreamConfig: q.UpstreamConfig.clone(db),
  129. User: q.User.clone(db),
  130. }
  131. }
  132. func (q *Query) ReadDB() *Query {
  133. return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
  134. }
  135. func (q *Query) WriteDB() *Query {
  136. return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
  137. }
  138. func (q *Query) ReplaceDB(db *gorm.DB) *Query {
  139. return &Query{
  140. db: db,
  141. AcmeUser: q.AcmeUser.replaceDB(db),
  142. AuthToken: q.AuthToken.replaceDB(db),
  143. AutoBackup: q.AutoBackup.replaceDB(db),
  144. BanIP: q.BanIP.replaceDB(db),
  145. Cert: q.Cert.replaceDB(db),
  146. Config: q.Config.replaceDB(db),
  147. ConfigBackup: q.ConfigBackup.replaceDB(db),
  148. DnsCredential: q.DnsCredential.replaceDB(db),
  149. ExternalNotify: q.ExternalNotify.replaceDB(db),
  150. LLMSession: q.LLMSession.replaceDB(db),
  151. Namespace: q.Namespace.replaceDB(db),
  152. NginxLogIndex: q.NginxLogIndex.replaceDB(db),
  153. Node: q.Node.replaceDB(db),
  154. Notification: q.Notification.replaceDB(db),
  155. Passkey: q.Passkey.replaceDB(db),
  156. Site: q.Site.replaceDB(db),
  157. SiteConfig: q.SiteConfig.replaceDB(db),
  158. Stream: q.Stream.replaceDB(db),
  159. UpstreamConfig: q.UpstreamConfig.replaceDB(db),
  160. User: q.User.replaceDB(db),
  161. }
  162. }
  163. type queryCtx struct {
  164. AcmeUser *acmeUserDo
  165. AuthToken *authTokenDo
  166. AutoBackup *autoBackupDo
  167. BanIP *banIPDo
  168. Cert *certDo
  169. Config *configDo
  170. ConfigBackup *configBackupDo
  171. DnsCredential *dnsCredentialDo
  172. ExternalNotify *externalNotifyDo
  173. LLMSession *lLMSessionDo
  174. Namespace *namespaceDo
  175. NginxLogIndex *nginxLogIndexDo
  176. Node *nodeDo
  177. Notification *notificationDo
  178. Passkey *passkeyDo
  179. Site *siteDo
  180. SiteConfig *siteConfigDo
  181. Stream *streamDo
  182. UpstreamConfig *upstreamConfigDo
  183. User *userDo
  184. }
  185. func (q *Query) WithContext(ctx context.Context) *queryCtx {
  186. return &queryCtx{
  187. AcmeUser: q.AcmeUser.WithContext(ctx),
  188. AuthToken: q.AuthToken.WithContext(ctx),
  189. AutoBackup: q.AutoBackup.WithContext(ctx),
  190. BanIP: q.BanIP.WithContext(ctx),
  191. Cert: q.Cert.WithContext(ctx),
  192. Config: q.Config.WithContext(ctx),
  193. ConfigBackup: q.ConfigBackup.WithContext(ctx),
  194. DnsCredential: q.DnsCredential.WithContext(ctx),
  195. ExternalNotify: q.ExternalNotify.WithContext(ctx),
  196. LLMSession: q.LLMSession.WithContext(ctx),
  197. Namespace: q.Namespace.WithContext(ctx),
  198. NginxLogIndex: q.NginxLogIndex.WithContext(ctx),
  199. Node: q.Node.WithContext(ctx),
  200. Notification: q.Notification.WithContext(ctx),
  201. Passkey: q.Passkey.WithContext(ctx),
  202. Site: q.Site.WithContext(ctx),
  203. SiteConfig: q.SiteConfig.WithContext(ctx),
  204. Stream: q.Stream.WithContext(ctx),
  205. UpstreamConfig: q.UpstreamConfig.WithContext(ctx),
  206. User: q.User.WithContext(ctx),
  207. }
  208. }
  209. func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
  210. return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
  211. }
  212. func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
  213. tx := q.db.Begin(opts...)
  214. return &QueryTx{Query: q.clone(tx), Error: tx.Error}
  215. }
  216. type QueryTx struct {
  217. *Query
  218. Error error
  219. }
  220. func (q *QueryTx) Commit() error {
  221. return q.db.Commit().Error
  222. }
  223. func (q *QueryTx) Rollback() error {
  224. return q.db.Rollback().Error
  225. }
  226. func (q *QueryTx) SavePoint(name string) error {
  227. return q.db.SavePoint(name).Error
  228. }
  229. func (q *QueryTx) RollbackTo(name string) error {
  230. return q.db.RollbackTo(name).Error
  231. }