user.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/user"
  10. )
  11. // User is the model entity for the User schema.
  12. type User struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID int64 `json:"id,omitempty"`
  16. // CreatedAt holds the value of the "created_at" field.
  17. CreatedAt time.Time `json:"created_at,omitempty"`
  18. // UpdatedAt holds the value of the "updated_at" field.
  19. UpdatedAt time.Time `json:"updated_at,omitempty"`
  20. // DeletedAt holds the value of the "deleted_at" field.
  21. DeletedAt *time.Time `json:"deleted_at,omitempty"`
  22. // Email holds the value of the "email" field.
  23. Email string `json:"email,omitempty"`
  24. // PasswordHash holds the value of the "password_hash" field.
  25. PasswordHash string `json:"password_hash,omitempty"`
  26. // Role holds the value of the "role" field.
  27. Role string `json:"role,omitempty"`
  28. // Balance holds the value of the "balance" field.
  29. Balance float64 `json:"balance,omitempty"`
  30. // FrozenBalance holds the value of the "frozen_balance" field.
  31. FrozenBalance float64 `json:"frozen_balance,omitempty"`
  32. // Concurrency holds the value of the "concurrency" field.
  33. Concurrency int `json:"concurrency,omitempty"`
  34. // Status holds the value of the "status" field.
  35. Status string `json:"status,omitempty"`
  36. // Username holds the value of the "username" field.
  37. Username string `json:"username,omitempty"`
  38. // Notes holds the value of the "notes" field.
  39. Notes string `json:"notes,omitempty"`
  40. // TotpSecretEncrypted holds the value of the "totp_secret_encrypted" field.
  41. TotpSecretEncrypted *string `json:"totp_secret_encrypted,omitempty"`
  42. // TotpEnabled holds the value of the "totp_enabled" field.
  43. TotpEnabled bool `json:"totp_enabled,omitempty"`
  44. // TotpEnabledAt holds the value of the "totp_enabled_at" field.
  45. TotpEnabledAt *time.Time `json:"totp_enabled_at,omitempty"`
  46. // SignupSource holds the value of the "signup_source" field.
  47. SignupSource string `json:"signup_source,omitempty"`
  48. // LastLoginAt holds the value of the "last_login_at" field.
  49. LastLoginAt *time.Time `json:"last_login_at,omitempty"`
  50. // LastActiveAt holds the value of the "last_active_at" field.
  51. LastActiveAt *time.Time `json:"last_active_at,omitempty"`
  52. // RestrictPublicGroups holds the value of the "restrict_public_groups" field.
  53. RestrictPublicGroups bool `json:"restrict_public_groups,omitempty"`
  54. // BalanceNotifyEnabled holds the value of the "balance_notify_enabled" field.
  55. BalanceNotifyEnabled bool `json:"balance_notify_enabled,omitempty"`
  56. // BalanceNotifyThresholdType holds the value of the "balance_notify_threshold_type" field.
  57. BalanceNotifyThresholdType string `json:"balance_notify_threshold_type,omitempty"`
  58. // BalanceNotifyThreshold holds the value of the "balance_notify_threshold" field.
  59. BalanceNotifyThreshold *float64 `json:"balance_notify_threshold,omitempty"`
  60. // BalanceNotifyExtraEmails holds the value of the "balance_notify_extra_emails" field.
  61. BalanceNotifyExtraEmails string `json:"balance_notify_extra_emails,omitempty"`
  62. // TotalRecharged holds the value of the "total_recharged" field.
  63. TotalRecharged float64 `json:"total_recharged,omitempty"`
  64. // RpmLimit holds the value of the "rpm_limit" field.
  65. RpmLimit int `json:"rpm_limit,omitempty"`
  66. // Edges holds the relations/edges for other nodes in the graph.
  67. // The values are being populated by the UserQuery when eager-loading is set.
  68. Edges UserEdges `json:"edges"`
  69. selectValues sql.SelectValues
  70. }
  71. // UserEdges holds the relations/edges for other nodes in the graph.
  72. type UserEdges struct {
  73. // APIKeys holds the value of the api_keys edge.
  74. APIKeys []*APIKey `json:"api_keys,omitempty"`
  75. // RedeemCodes holds the value of the redeem_codes edge.
  76. RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"`
  77. // Subscriptions holds the value of the subscriptions edge.
  78. Subscriptions []*UserSubscription `json:"subscriptions,omitempty"`
  79. // AssignedSubscriptions holds the value of the assigned_subscriptions edge.
  80. AssignedSubscriptions []*UserSubscription `json:"assigned_subscriptions,omitempty"`
  81. // AnnouncementReads holds the value of the announcement_reads edge.
  82. AnnouncementReads []*AnnouncementRead `json:"announcement_reads,omitempty"`
  83. // AllowedGroups holds the value of the allowed_groups edge.
  84. AllowedGroups []*Group `json:"allowed_groups,omitempty"`
  85. // UsageLogs holds the value of the usage_logs edge.
  86. UsageLogs []*UsageLog `json:"usage_logs,omitempty"`
  87. // AttributeValues holds the value of the attribute_values edge.
  88. AttributeValues []*UserAttributeValue `json:"attribute_values,omitempty"`
  89. // PromoCodeUsages holds the value of the promo_code_usages edge.
  90. PromoCodeUsages []*PromoCodeUsage `json:"promo_code_usages,omitempty"`
  91. // PaymentOrders holds the value of the payment_orders edge.
  92. PaymentOrders []*PaymentOrder `json:"payment_orders,omitempty"`
  93. // AuthIdentities holds the value of the auth_identities edge.
  94. AuthIdentities []*AuthIdentity `json:"auth_identities,omitempty"`
  95. // PendingAuthSessions holds the value of the pending_auth_sessions edge.
  96. PendingAuthSessions []*PendingAuthSession `json:"pending_auth_sessions,omitempty"`
  97. // PlatformQuotas holds the value of the platform_quotas edge.
  98. PlatformQuotas []*UserPlatformQuota `json:"platform_quotas,omitempty"`
  99. // UserAllowedGroups holds the value of the user_allowed_groups edge.
  100. UserAllowedGroups []*UserAllowedGroup `json:"user_allowed_groups,omitempty"`
  101. // loadedTypes holds the information for reporting if a
  102. // type was loaded (or requested) in eager-loading or not.
  103. loadedTypes [14]bool
  104. }
  105. // APIKeysOrErr returns the APIKeys value or an error if the edge
  106. // was not loaded in eager-loading.
  107. func (e UserEdges) APIKeysOrErr() ([]*APIKey, error) {
  108. if e.loadedTypes[0] {
  109. return e.APIKeys, nil
  110. }
  111. return nil, &NotLoadedError{edge: "api_keys"}
  112. }
  113. // RedeemCodesOrErr returns the RedeemCodes value or an error if the edge
  114. // was not loaded in eager-loading.
  115. func (e UserEdges) RedeemCodesOrErr() ([]*RedeemCode, error) {
  116. if e.loadedTypes[1] {
  117. return e.RedeemCodes, nil
  118. }
  119. return nil, &NotLoadedError{edge: "redeem_codes"}
  120. }
  121. // SubscriptionsOrErr returns the Subscriptions value or an error if the edge
  122. // was not loaded in eager-loading.
  123. func (e UserEdges) SubscriptionsOrErr() ([]*UserSubscription, error) {
  124. if e.loadedTypes[2] {
  125. return e.Subscriptions, nil
  126. }
  127. return nil, &NotLoadedError{edge: "subscriptions"}
  128. }
  129. // AssignedSubscriptionsOrErr returns the AssignedSubscriptions value or an error if the edge
  130. // was not loaded in eager-loading.
  131. func (e UserEdges) AssignedSubscriptionsOrErr() ([]*UserSubscription, error) {
  132. if e.loadedTypes[3] {
  133. return e.AssignedSubscriptions, nil
  134. }
  135. return nil, &NotLoadedError{edge: "assigned_subscriptions"}
  136. }
  137. // AnnouncementReadsOrErr returns the AnnouncementReads value or an error if the edge
  138. // was not loaded in eager-loading.
  139. func (e UserEdges) AnnouncementReadsOrErr() ([]*AnnouncementRead, error) {
  140. if e.loadedTypes[4] {
  141. return e.AnnouncementReads, nil
  142. }
  143. return nil, &NotLoadedError{edge: "announcement_reads"}
  144. }
  145. // AllowedGroupsOrErr returns the AllowedGroups value or an error if the edge
  146. // was not loaded in eager-loading.
  147. func (e UserEdges) AllowedGroupsOrErr() ([]*Group, error) {
  148. if e.loadedTypes[5] {
  149. return e.AllowedGroups, nil
  150. }
  151. return nil, &NotLoadedError{edge: "allowed_groups"}
  152. }
  153. // UsageLogsOrErr returns the UsageLogs value or an error if the edge
  154. // was not loaded in eager-loading.
  155. func (e UserEdges) UsageLogsOrErr() ([]*UsageLog, error) {
  156. if e.loadedTypes[6] {
  157. return e.UsageLogs, nil
  158. }
  159. return nil, &NotLoadedError{edge: "usage_logs"}
  160. }
  161. // AttributeValuesOrErr returns the AttributeValues value or an error if the edge
  162. // was not loaded in eager-loading.
  163. func (e UserEdges) AttributeValuesOrErr() ([]*UserAttributeValue, error) {
  164. if e.loadedTypes[7] {
  165. return e.AttributeValues, nil
  166. }
  167. return nil, &NotLoadedError{edge: "attribute_values"}
  168. }
  169. // PromoCodeUsagesOrErr returns the PromoCodeUsages value or an error if the edge
  170. // was not loaded in eager-loading.
  171. func (e UserEdges) PromoCodeUsagesOrErr() ([]*PromoCodeUsage, error) {
  172. if e.loadedTypes[8] {
  173. return e.PromoCodeUsages, nil
  174. }
  175. return nil, &NotLoadedError{edge: "promo_code_usages"}
  176. }
  177. // PaymentOrdersOrErr returns the PaymentOrders value or an error if the edge
  178. // was not loaded in eager-loading.
  179. func (e UserEdges) PaymentOrdersOrErr() ([]*PaymentOrder, error) {
  180. if e.loadedTypes[9] {
  181. return e.PaymentOrders, nil
  182. }
  183. return nil, &NotLoadedError{edge: "payment_orders"}
  184. }
  185. // AuthIdentitiesOrErr returns the AuthIdentities value or an error if the edge
  186. // was not loaded in eager-loading.
  187. func (e UserEdges) AuthIdentitiesOrErr() ([]*AuthIdentity, error) {
  188. if e.loadedTypes[10] {
  189. return e.AuthIdentities, nil
  190. }
  191. return nil, &NotLoadedError{edge: "auth_identities"}
  192. }
  193. // PendingAuthSessionsOrErr returns the PendingAuthSessions value or an error if the edge
  194. // was not loaded in eager-loading.
  195. func (e UserEdges) PendingAuthSessionsOrErr() ([]*PendingAuthSession, error) {
  196. if e.loadedTypes[11] {
  197. return e.PendingAuthSessions, nil
  198. }
  199. return nil, &NotLoadedError{edge: "pending_auth_sessions"}
  200. }
  201. // PlatformQuotasOrErr returns the PlatformQuotas value or an error if the edge
  202. // was not loaded in eager-loading.
  203. func (e UserEdges) PlatformQuotasOrErr() ([]*UserPlatformQuota, error) {
  204. if e.loadedTypes[12] {
  205. return e.PlatformQuotas, nil
  206. }
  207. return nil, &NotLoadedError{edge: "platform_quotas"}
  208. }
  209. // UserAllowedGroupsOrErr returns the UserAllowedGroups value or an error if the edge
  210. // was not loaded in eager-loading.
  211. func (e UserEdges) UserAllowedGroupsOrErr() ([]*UserAllowedGroup, error) {
  212. if e.loadedTypes[13] {
  213. return e.UserAllowedGroups, nil
  214. }
  215. return nil, &NotLoadedError{edge: "user_allowed_groups"}
  216. }
  217. // scanValues returns the types for scanning values from sql.Rows.
  218. func (*User) scanValues(columns []string) ([]any, error) {
  219. values := make([]any, len(columns))
  220. for i := range columns {
  221. switch columns[i] {
  222. case user.FieldTotpEnabled, user.FieldRestrictPublicGroups, user.FieldBalanceNotifyEnabled:
  223. values[i] = new(sql.NullBool)
  224. case user.FieldBalance, user.FieldFrozenBalance, user.FieldBalanceNotifyThreshold, user.FieldTotalRecharged:
  225. values[i] = new(sql.NullFloat64)
  226. case user.FieldID, user.FieldConcurrency, user.FieldRpmLimit:
  227. values[i] = new(sql.NullInt64)
  228. case user.FieldEmail, user.FieldPasswordHash, user.FieldRole, user.FieldStatus, user.FieldUsername, user.FieldNotes, user.FieldTotpSecretEncrypted, user.FieldSignupSource, user.FieldBalanceNotifyThresholdType, user.FieldBalanceNotifyExtraEmails:
  229. values[i] = new(sql.NullString)
  230. case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldDeletedAt, user.FieldTotpEnabledAt, user.FieldLastLoginAt, user.FieldLastActiveAt:
  231. values[i] = new(sql.NullTime)
  232. default:
  233. values[i] = new(sql.UnknownType)
  234. }
  235. }
  236. return values, nil
  237. }
  238. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  239. // to the User fields.
  240. func (_m *User) assignValues(columns []string, values []any) error {
  241. if m, n := len(values), len(columns); m < n {
  242. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  243. }
  244. for i := range columns {
  245. switch columns[i] {
  246. case user.FieldID:
  247. value, ok := values[i].(*sql.NullInt64)
  248. if !ok {
  249. return fmt.Errorf("unexpected type %T for field id", value)
  250. }
  251. _m.ID = int64(value.Int64)
  252. case user.FieldCreatedAt:
  253. if value, ok := values[i].(*sql.NullTime); !ok {
  254. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  255. } else if value.Valid {
  256. _m.CreatedAt = value.Time
  257. }
  258. case user.FieldUpdatedAt:
  259. if value, ok := values[i].(*sql.NullTime); !ok {
  260. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  261. } else if value.Valid {
  262. _m.UpdatedAt = value.Time
  263. }
  264. case user.FieldDeletedAt:
  265. if value, ok := values[i].(*sql.NullTime); !ok {
  266. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  267. } else if value.Valid {
  268. _m.DeletedAt = new(time.Time)
  269. *_m.DeletedAt = value.Time
  270. }
  271. case user.FieldEmail:
  272. if value, ok := values[i].(*sql.NullString); !ok {
  273. return fmt.Errorf("unexpected type %T for field email", values[i])
  274. } else if value.Valid {
  275. _m.Email = value.String
  276. }
  277. case user.FieldPasswordHash:
  278. if value, ok := values[i].(*sql.NullString); !ok {
  279. return fmt.Errorf("unexpected type %T for field password_hash", values[i])
  280. } else if value.Valid {
  281. _m.PasswordHash = value.String
  282. }
  283. case user.FieldRole:
  284. if value, ok := values[i].(*sql.NullString); !ok {
  285. return fmt.Errorf("unexpected type %T for field role", values[i])
  286. } else if value.Valid {
  287. _m.Role = value.String
  288. }
  289. case user.FieldBalance:
  290. if value, ok := values[i].(*sql.NullFloat64); !ok {
  291. return fmt.Errorf("unexpected type %T for field balance", values[i])
  292. } else if value.Valid {
  293. _m.Balance = value.Float64
  294. }
  295. case user.FieldFrozenBalance:
  296. if value, ok := values[i].(*sql.NullFloat64); !ok {
  297. return fmt.Errorf("unexpected type %T for field frozen_balance", values[i])
  298. } else if value.Valid {
  299. _m.FrozenBalance = value.Float64
  300. }
  301. case user.FieldConcurrency:
  302. if value, ok := values[i].(*sql.NullInt64); !ok {
  303. return fmt.Errorf("unexpected type %T for field concurrency", values[i])
  304. } else if value.Valid {
  305. _m.Concurrency = int(value.Int64)
  306. }
  307. case user.FieldStatus:
  308. if value, ok := values[i].(*sql.NullString); !ok {
  309. return fmt.Errorf("unexpected type %T for field status", values[i])
  310. } else if value.Valid {
  311. _m.Status = value.String
  312. }
  313. case user.FieldUsername:
  314. if value, ok := values[i].(*sql.NullString); !ok {
  315. return fmt.Errorf("unexpected type %T for field username", values[i])
  316. } else if value.Valid {
  317. _m.Username = value.String
  318. }
  319. case user.FieldNotes:
  320. if value, ok := values[i].(*sql.NullString); !ok {
  321. return fmt.Errorf("unexpected type %T for field notes", values[i])
  322. } else if value.Valid {
  323. _m.Notes = value.String
  324. }
  325. case user.FieldTotpSecretEncrypted:
  326. if value, ok := values[i].(*sql.NullString); !ok {
  327. return fmt.Errorf("unexpected type %T for field totp_secret_encrypted", values[i])
  328. } else if value.Valid {
  329. _m.TotpSecretEncrypted = new(string)
  330. *_m.TotpSecretEncrypted = value.String
  331. }
  332. case user.FieldTotpEnabled:
  333. if value, ok := values[i].(*sql.NullBool); !ok {
  334. return fmt.Errorf("unexpected type %T for field totp_enabled", values[i])
  335. } else if value.Valid {
  336. _m.TotpEnabled = value.Bool
  337. }
  338. case user.FieldTotpEnabledAt:
  339. if value, ok := values[i].(*sql.NullTime); !ok {
  340. return fmt.Errorf("unexpected type %T for field totp_enabled_at", values[i])
  341. } else if value.Valid {
  342. _m.TotpEnabledAt = new(time.Time)
  343. *_m.TotpEnabledAt = value.Time
  344. }
  345. case user.FieldSignupSource:
  346. if value, ok := values[i].(*sql.NullString); !ok {
  347. return fmt.Errorf("unexpected type %T for field signup_source", values[i])
  348. } else if value.Valid {
  349. _m.SignupSource = value.String
  350. }
  351. case user.FieldLastLoginAt:
  352. if value, ok := values[i].(*sql.NullTime); !ok {
  353. return fmt.Errorf("unexpected type %T for field last_login_at", values[i])
  354. } else if value.Valid {
  355. _m.LastLoginAt = new(time.Time)
  356. *_m.LastLoginAt = value.Time
  357. }
  358. case user.FieldLastActiveAt:
  359. if value, ok := values[i].(*sql.NullTime); !ok {
  360. return fmt.Errorf("unexpected type %T for field last_active_at", values[i])
  361. } else if value.Valid {
  362. _m.LastActiveAt = new(time.Time)
  363. *_m.LastActiveAt = value.Time
  364. }
  365. case user.FieldRestrictPublicGroups:
  366. if value, ok := values[i].(*sql.NullBool); !ok {
  367. return fmt.Errorf("unexpected type %T for field restrict_public_groups", values[i])
  368. } else if value.Valid {
  369. _m.RestrictPublicGroups = value.Bool
  370. }
  371. case user.FieldBalanceNotifyEnabled:
  372. if value, ok := values[i].(*sql.NullBool); !ok {
  373. return fmt.Errorf("unexpected type %T for field balance_notify_enabled", values[i])
  374. } else if value.Valid {
  375. _m.BalanceNotifyEnabled = value.Bool
  376. }
  377. case user.FieldBalanceNotifyThresholdType:
  378. if value, ok := values[i].(*sql.NullString); !ok {
  379. return fmt.Errorf("unexpected type %T for field balance_notify_threshold_type", values[i])
  380. } else if value.Valid {
  381. _m.BalanceNotifyThresholdType = value.String
  382. }
  383. case user.FieldBalanceNotifyThreshold:
  384. if value, ok := values[i].(*sql.NullFloat64); !ok {
  385. return fmt.Errorf("unexpected type %T for field balance_notify_threshold", values[i])
  386. } else if value.Valid {
  387. _m.BalanceNotifyThreshold = new(float64)
  388. *_m.BalanceNotifyThreshold = value.Float64
  389. }
  390. case user.FieldBalanceNotifyExtraEmails:
  391. if value, ok := values[i].(*sql.NullString); !ok {
  392. return fmt.Errorf("unexpected type %T for field balance_notify_extra_emails", values[i])
  393. } else if value.Valid {
  394. _m.BalanceNotifyExtraEmails = value.String
  395. }
  396. case user.FieldTotalRecharged:
  397. if value, ok := values[i].(*sql.NullFloat64); !ok {
  398. return fmt.Errorf("unexpected type %T for field total_recharged", values[i])
  399. } else if value.Valid {
  400. _m.TotalRecharged = value.Float64
  401. }
  402. case user.FieldRpmLimit:
  403. if value, ok := values[i].(*sql.NullInt64); !ok {
  404. return fmt.Errorf("unexpected type %T for field rpm_limit", values[i])
  405. } else if value.Valid {
  406. _m.RpmLimit = int(value.Int64)
  407. }
  408. default:
  409. _m.selectValues.Set(columns[i], values[i])
  410. }
  411. }
  412. return nil
  413. }
  414. // Value returns the ent.Value that was dynamically selected and assigned to the User.
  415. // This includes values selected through modifiers, order, etc.
  416. func (_m *User) Value(name string) (ent.Value, error) {
  417. return _m.selectValues.Get(name)
  418. }
  419. // QueryAPIKeys queries the "api_keys" edge of the User entity.
  420. func (_m *User) QueryAPIKeys() *APIKeyQuery {
  421. return NewUserClient(_m.config).QueryAPIKeys(_m)
  422. }
  423. // QueryRedeemCodes queries the "redeem_codes" edge of the User entity.
  424. func (_m *User) QueryRedeemCodes() *RedeemCodeQuery {
  425. return NewUserClient(_m.config).QueryRedeemCodes(_m)
  426. }
  427. // QuerySubscriptions queries the "subscriptions" edge of the User entity.
  428. func (_m *User) QuerySubscriptions() *UserSubscriptionQuery {
  429. return NewUserClient(_m.config).QuerySubscriptions(_m)
  430. }
  431. // QueryAssignedSubscriptions queries the "assigned_subscriptions" edge of the User entity.
  432. func (_m *User) QueryAssignedSubscriptions() *UserSubscriptionQuery {
  433. return NewUserClient(_m.config).QueryAssignedSubscriptions(_m)
  434. }
  435. // QueryAnnouncementReads queries the "announcement_reads" edge of the User entity.
  436. func (_m *User) QueryAnnouncementReads() *AnnouncementReadQuery {
  437. return NewUserClient(_m.config).QueryAnnouncementReads(_m)
  438. }
  439. // QueryAllowedGroups queries the "allowed_groups" edge of the User entity.
  440. func (_m *User) QueryAllowedGroups() *GroupQuery {
  441. return NewUserClient(_m.config).QueryAllowedGroups(_m)
  442. }
  443. // QueryUsageLogs queries the "usage_logs" edge of the User entity.
  444. func (_m *User) QueryUsageLogs() *UsageLogQuery {
  445. return NewUserClient(_m.config).QueryUsageLogs(_m)
  446. }
  447. // QueryAttributeValues queries the "attribute_values" edge of the User entity.
  448. func (_m *User) QueryAttributeValues() *UserAttributeValueQuery {
  449. return NewUserClient(_m.config).QueryAttributeValues(_m)
  450. }
  451. // QueryPromoCodeUsages queries the "promo_code_usages" edge of the User entity.
  452. func (_m *User) QueryPromoCodeUsages() *PromoCodeUsageQuery {
  453. return NewUserClient(_m.config).QueryPromoCodeUsages(_m)
  454. }
  455. // QueryPaymentOrders queries the "payment_orders" edge of the User entity.
  456. func (_m *User) QueryPaymentOrders() *PaymentOrderQuery {
  457. return NewUserClient(_m.config).QueryPaymentOrders(_m)
  458. }
  459. // QueryAuthIdentities queries the "auth_identities" edge of the User entity.
  460. func (_m *User) QueryAuthIdentities() *AuthIdentityQuery {
  461. return NewUserClient(_m.config).QueryAuthIdentities(_m)
  462. }
  463. // QueryPendingAuthSessions queries the "pending_auth_sessions" edge of the User entity.
  464. func (_m *User) QueryPendingAuthSessions() *PendingAuthSessionQuery {
  465. return NewUserClient(_m.config).QueryPendingAuthSessions(_m)
  466. }
  467. // QueryPlatformQuotas queries the "platform_quotas" edge of the User entity.
  468. func (_m *User) QueryPlatformQuotas() *UserPlatformQuotaQuery {
  469. return NewUserClient(_m.config).QueryPlatformQuotas(_m)
  470. }
  471. // QueryUserAllowedGroups queries the "user_allowed_groups" edge of the User entity.
  472. func (_m *User) QueryUserAllowedGroups() *UserAllowedGroupQuery {
  473. return NewUserClient(_m.config).QueryUserAllowedGroups(_m)
  474. }
  475. // Update returns a builder for updating this User.
  476. // Note that you need to call User.Unwrap() before calling this method if this User
  477. // was returned from a transaction, and the transaction was committed or rolled back.
  478. func (_m *User) Update() *UserUpdateOne {
  479. return NewUserClient(_m.config).UpdateOne(_m)
  480. }
  481. // Unwrap unwraps the User entity that was returned from a transaction after it was closed,
  482. // so that all future queries will be executed through the driver which created the transaction.
  483. func (_m *User) Unwrap() *User {
  484. _tx, ok := _m.config.driver.(*txDriver)
  485. if !ok {
  486. panic("ent: User is not a transactional entity")
  487. }
  488. _m.config.driver = _tx.drv
  489. return _m
  490. }
  491. // String implements the fmt.Stringer.
  492. func (_m *User) String() string {
  493. var builder strings.Builder
  494. builder.WriteString("User(")
  495. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  496. builder.WriteString("created_at=")
  497. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  498. builder.WriteString(", ")
  499. builder.WriteString("updated_at=")
  500. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  501. builder.WriteString(", ")
  502. if v := _m.DeletedAt; v != nil {
  503. builder.WriteString("deleted_at=")
  504. builder.WriteString(v.Format(time.ANSIC))
  505. }
  506. builder.WriteString(", ")
  507. builder.WriteString("email=")
  508. builder.WriteString(_m.Email)
  509. builder.WriteString(", ")
  510. builder.WriteString("password_hash=")
  511. builder.WriteString(_m.PasswordHash)
  512. builder.WriteString(", ")
  513. builder.WriteString("role=")
  514. builder.WriteString(_m.Role)
  515. builder.WriteString(", ")
  516. builder.WriteString("balance=")
  517. builder.WriteString(fmt.Sprintf("%v", _m.Balance))
  518. builder.WriteString(", ")
  519. builder.WriteString("frozen_balance=")
  520. builder.WriteString(fmt.Sprintf("%v", _m.FrozenBalance))
  521. builder.WriteString(", ")
  522. builder.WriteString("concurrency=")
  523. builder.WriteString(fmt.Sprintf("%v", _m.Concurrency))
  524. builder.WriteString(", ")
  525. builder.WriteString("status=")
  526. builder.WriteString(_m.Status)
  527. builder.WriteString(", ")
  528. builder.WriteString("username=")
  529. builder.WriteString(_m.Username)
  530. builder.WriteString(", ")
  531. builder.WriteString("notes=")
  532. builder.WriteString(_m.Notes)
  533. builder.WriteString(", ")
  534. if v := _m.TotpSecretEncrypted; v != nil {
  535. builder.WriteString("totp_secret_encrypted=")
  536. builder.WriteString(*v)
  537. }
  538. builder.WriteString(", ")
  539. builder.WriteString("totp_enabled=")
  540. builder.WriteString(fmt.Sprintf("%v", _m.TotpEnabled))
  541. builder.WriteString(", ")
  542. if v := _m.TotpEnabledAt; v != nil {
  543. builder.WriteString("totp_enabled_at=")
  544. builder.WriteString(v.Format(time.ANSIC))
  545. }
  546. builder.WriteString(", ")
  547. builder.WriteString("signup_source=")
  548. builder.WriteString(_m.SignupSource)
  549. builder.WriteString(", ")
  550. if v := _m.LastLoginAt; v != nil {
  551. builder.WriteString("last_login_at=")
  552. builder.WriteString(v.Format(time.ANSIC))
  553. }
  554. builder.WriteString(", ")
  555. if v := _m.LastActiveAt; v != nil {
  556. builder.WriteString("last_active_at=")
  557. builder.WriteString(v.Format(time.ANSIC))
  558. }
  559. builder.WriteString(", ")
  560. builder.WriteString("restrict_public_groups=")
  561. builder.WriteString(fmt.Sprintf("%v", _m.RestrictPublicGroups))
  562. builder.WriteString(", ")
  563. builder.WriteString("balance_notify_enabled=")
  564. builder.WriteString(fmt.Sprintf("%v", _m.BalanceNotifyEnabled))
  565. builder.WriteString(", ")
  566. builder.WriteString("balance_notify_threshold_type=")
  567. builder.WriteString(_m.BalanceNotifyThresholdType)
  568. builder.WriteString(", ")
  569. if v := _m.BalanceNotifyThreshold; v != nil {
  570. builder.WriteString("balance_notify_threshold=")
  571. builder.WriteString(fmt.Sprintf("%v", *v))
  572. }
  573. builder.WriteString(", ")
  574. builder.WriteString("balance_notify_extra_emails=")
  575. builder.WriteString(_m.BalanceNotifyExtraEmails)
  576. builder.WriteString(", ")
  577. builder.WriteString("total_recharged=")
  578. builder.WriteString(fmt.Sprintf("%v", _m.TotalRecharged))
  579. builder.WriteString(", ")
  580. builder.WriteString("rpm_limit=")
  581. builder.WriteString(fmt.Sprintf("%v", _m.RpmLimit))
  582. builder.WriteByte(')')
  583. return builder.String()
  584. }
  585. // Users is a parsable slice of User.
  586. type Users []*User