user_account.gen.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "gadmin/internal/gorm/model"
  14. )
  15. func newUserAccount(db *gorm.DB, opts ...gen.DOOption) userAccount {
  16. _userAccount := userAccount{}
  17. _userAccount.userAccountDo.UseDB(db, opts...)
  18. _userAccount.userAccountDo.UseModel(&model.UserAccount{})
  19. tableName := _userAccount.userAccountDo.TableName()
  20. _userAccount.ALL = field.NewAsterisk(tableName)
  21. _userAccount.ID = field.NewInt64(tableName, "id")
  22. _userAccount.AccID = field.NewInt64(tableName, "accId")
  23. _userAccount.Openid = field.NewString(tableName, "openid")
  24. _userAccount.Nickname = field.NewString(tableName, "nickname")
  25. _userAccount.Avatar = field.NewString(tableName, "avatar")
  26. _userAccount.Account = field.NewString(tableName, "account")
  27. _userAccount.Password = field.NewString(tableName, "password")
  28. _userAccount.Inviter = field.NewInt64(tableName, "inviter")
  29. _userAccount.Createtime = field.NewInt64(tableName, "createtime")
  30. _userAccount.Platopenid = field.NewString(tableName, "platopenid")
  31. _userAccount.Channel = field.NewInt32(tableName, "channel")
  32. _userAccount.Picture = field.NewInt32(tableName, "picture")
  33. _userAccount.Idcard = field.NewString(tableName, "idcard")
  34. _userAccount.Name = field.NewString(tableName, "name")
  35. _userAccount.Borntime = field.NewInt64(tableName, "borntime")
  36. _userAccount.Gametime = field.NewInt64(tableName, "gametime")
  37. _userAccount.Gametimelen = field.NewInt32(tableName, "gametimelen")
  38. _userAccount.Sessionkey = field.NewString(tableName, "sessionkey")
  39. _userAccount.Unionid = field.NewString(tableName, "unionid")
  40. _userAccount.Server = field.NewInt32(tableName, "server")
  41. _userAccount.Summary = field.NewString(tableName, "summary")
  42. _userAccount.Ban = field.NewInt32(tableName, "ban")
  43. _userAccount.GdtVid = field.NewString(tableName, "gdtVid")
  44. _userAccount.AID = field.NewString(tableName, "aId")
  45. _userAccount.Flag = field.NewInt32(tableName, "flag")
  46. _userAccount.AdSrc = field.NewString(tableName, "adSrc")
  47. _userAccount.fillFieldMap()
  48. return _userAccount
  49. }
  50. type userAccount struct {
  51. userAccountDo
  52. ALL field.Asterisk
  53. ID field.Int64
  54. AccID field.Int64
  55. Openid field.String
  56. Nickname field.String
  57. Avatar field.String
  58. Account field.String
  59. Password field.String
  60. Inviter field.Int64
  61. Createtime field.Int64
  62. Platopenid field.String
  63. Channel field.Int32
  64. Picture field.Int32
  65. Idcard field.String
  66. Name field.String
  67. Borntime field.Int64
  68. Gametime field.Int64
  69. Gametimelen field.Int32
  70. Sessionkey field.String
  71. Unionid field.String
  72. Server field.Int32
  73. Summary field.String
  74. Ban field.Int32
  75. GdtVid field.String
  76. AID field.String
  77. Flag field.Int32
  78. AdSrc field.String
  79. fieldMap map[string]field.Expr
  80. }
  81. func (u userAccount) Table(newTableName string) *userAccount {
  82. u.userAccountDo.UseTable(newTableName)
  83. return u.updateTableName(newTableName)
  84. }
  85. func (u userAccount) As(alias string) *userAccount {
  86. u.userAccountDo.DO = *(u.userAccountDo.As(alias).(*gen.DO))
  87. return u.updateTableName(alias)
  88. }
  89. func (u *userAccount) updateTableName(table string) *userAccount {
  90. u.ALL = field.NewAsterisk(table)
  91. u.ID = field.NewInt64(table, "id")
  92. u.AccID = field.NewInt64(table, "accId")
  93. u.Openid = field.NewString(table, "openid")
  94. u.Nickname = field.NewString(table, "nickname")
  95. u.Avatar = field.NewString(table, "avatar")
  96. u.Account = field.NewString(table, "account")
  97. u.Password = field.NewString(table, "password")
  98. u.Inviter = field.NewInt64(table, "inviter")
  99. u.Createtime = field.NewInt64(table, "createtime")
  100. u.Platopenid = field.NewString(table, "platopenid")
  101. u.Channel = field.NewInt32(table, "channel")
  102. u.Picture = field.NewInt32(table, "picture")
  103. u.Idcard = field.NewString(table, "idcard")
  104. u.Name = field.NewString(table, "name")
  105. u.Borntime = field.NewInt64(table, "borntime")
  106. u.Gametime = field.NewInt64(table, "gametime")
  107. u.Gametimelen = field.NewInt32(table, "gametimelen")
  108. u.Sessionkey = field.NewString(table, "sessionkey")
  109. u.Unionid = field.NewString(table, "unionid")
  110. u.Server = field.NewInt32(table, "server")
  111. u.Summary = field.NewString(table, "summary")
  112. u.Ban = field.NewInt32(table, "ban")
  113. u.GdtVid = field.NewString(table, "gdtVid")
  114. u.AID = field.NewString(table, "aId")
  115. u.Flag = field.NewInt32(table, "flag")
  116. u.AdSrc = field.NewString(table, "adSrc")
  117. u.fillFieldMap()
  118. return u
  119. }
  120. func (u *userAccount) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  121. _f, ok := u.fieldMap[fieldName]
  122. if !ok || _f == nil {
  123. return nil, false
  124. }
  125. _oe, ok := _f.(field.OrderExpr)
  126. return _oe, ok
  127. }
  128. func (u *userAccount) fillFieldMap() {
  129. u.fieldMap = make(map[string]field.Expr, 26)
  130. u.fieldMap["id"] = u.ID
  131. u.fieldMap["accId"] = u.AccID
  132. u.fieldMap["openid"] = u.Openid
  133. u.fieldMap["nickname"] = u.Nickname
  134. u.fieldMap["avatar"] = u.Avatar
  135. u.fieldMap["account"] = u.Account
  136. u.fieldMap["password"] = u.Password
  137. u.fieldMap["inviter"] = u.Inviter
  138. u.fieldMap["createtime"] = u.Createtime
  139. u.fieldMap["platopenid"] = u.Platopenid
  140. u.fieldMap["channel"] = u.Channel
  141. u.fieldMap["picture"] = u.Picture
  142. u.fieldMap["idcard"] = u.Idcard
  143. u.fieldMap["name"] = u.Name
  144. u.fieldMap["borntime"] = u.Borntime
  145. u.fieldMap["gametime"] = u.Gametime
  146. u.fieldMap["gametimelen"] = u.Gametimelen
  147. u.fieldMap["sessionkey"] = u.Sessionkey
  148. u.fieldMap["unionid"] = u.Unionid
  149. u.fieldMap["server"] = u.Server
  150. u.fieldMap["summary"] = u.Summary
  151. u.fieldMap["ban"] = u.Ban
  152. u.fieldMap["gdtVid"] = u.GdtVid
  153. u.fieldMap["aId"] = u.AID
  154. u.fieldMap["flag"] = u.Flag
  155. u.fieldMap["adSrc"] = u.AdSrc
  156. }
  157. func (u userAccount) clone(db *gorm.DB) userAccount {
  158. u.userAccountDo.ReplaceConnPool(db.Statement.ConnPool)
  159. return u
  160. }
  161. func (u userAccount) replaceDB(db *gorm.DB) userAccount {
  162. u.userAccountDo.ReplaceDB(db)
  163. return u
  164. }
  165. type userAccountDo struct{ gen.DO }
  166. func (u userAccountDo) Debug() *userAccountDo {
  167. return u.withDO(u.DO.Debug())
  168. }
  169. func (u userAccountDo) WithContext(ctx context.Context) *userAccountDo {
  170. return u.withDO(u.DO.WithContext(ctx))
  171. }
  172. func (u userAccountDo) ReadDB() *userAccountDo {
  173. return u.Clauses(dbresolver.Read)
  174. }
  175. func (u userAccountDo) WriteDB() *userAccountDo {
  176. return u.Clauses(dbresolver.Write)
  177. }
  178. func (u userAccountDo) Session(config *gorm.Session) *userAccountDo {
  179. return u.withDO(u.DO.Session(config))
  180. }
  181. func (u userAccountDo) Clauses(conds ...clause.Expression) *userAccountDo {
  182. return u.withDO(u.DO.Clauses(conds...))
  183. }
  184. func (u userAccountDo) Returning(value interface{}, columns ...string) *userAccountDo {
  185. return u.withDO(u.DO.Returning(value, columns...))
  186. }
  187. func (u userAccountDo) Not(conds ...gen.Condition) *userAccountDo {
  188. return u.withDO(u.DO.Not(conds...))
  189. }
  190. func (u userAccountDo) Or(conds ...gen.Condition) *userAccountDo {
  191. return u.withDO(u.DO.Or(conds...))
  192. }
  193. func (u userAccountDo) Select(conds ...field.Expr) *userAccountDo {
  194. return u.withDO(u.DO.Select(conds...))
  195. }
  196. func (u userAccountDo) Where(conds ...gen.Condition) *userAccountDo {
  197. return u.withDO(u.DO.Where(conds...))
  198. }
  199. func (u userAccountDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *userAccountDo {
  200. return u.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  201. }
  202. func (u userAccountDo) Order(conds ...field.Expr) *userAccountDo {
  203. return u.withDO(u.DO.Order(conds...))
  204. }
  205. func (u userAccountDo) Distinct(cols ...field.Expr) *userAccountDo {
  206. return u.withDO(u.DO.Distinct(cols...))
  207. }
  208. func (u userAccountDo) Omit(cols ...field.Expr) *userAccountDo {
  209. return u.withDO(u.DO.Omit(cols...))
  210. }
  211. func (u userAccountDo) Join(table schema.Tabler, on ...field.Expr) *userAccountDo {
  212. return u.withDO(u.DO.Join(table, on...))
  213. }
  214. func (u userAccountDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userAccountDo {
  215. return u.withDO(u.DO.LeftJoin(table, on...))
  216. }
  217. func (u userAccountDo) RightJoin(table schema.Tabler, on ...field.Expr) *userAccountDo {
  218. return u.withDO(u.DO.RightJoin(table, on...))
  219. }
  220. func (u userAccountDo) Group(cols ...field.Expr) *userAccountDo {
  221. return u.withDO(u.DO.Group(cols...))
  222. }
  223. func (u userAccountDo) Having(conds ...gen.Condition) *userAccountDo {
  224. return u.withDO(u.DO.Having(conds...))
  225. }
  226. func (u userAccountDo) Limit(limit int) *userAccountDo {
  227. return u.withDO(u.DO.Limit(limit))
  228. }
  229. func (u userAccountDo) Offset(offset int) *userAccountDo {
  230. return u.withDO(u.DO.Offset(offset))
  231. }
  232. func (u userAccountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userAccountDo {
  233. return u.withDO(u.DO.Scopes(funcs...))
  234. }
  235. func (u userAccountDo) Unscoped() *userAccountDo {
  236. return u.withDO(u.DO.Unscoped())
  237. }
  238. func (u userAccountDo) Create(values ...*model.UserAccount) error {
  239. if len(values) == 0 {
  240. return nil
  241. }
  242. return u.DO.Create(values)
  243. }
  244. func (u userAccountDo) CreateInBatches(values []*model.UserAccount, batchSize int) error {
  245. return u.DO.CreateInBatches(values, batchSize)
  246. }
  247. // Save : !!! underlying implementation is different with GORM
  248. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  249. func (u userAccountDo) Save(values ...*model.UserAccount) error {
  250. if len(values) == 0 {
  251. return nil
  252. }
  253. return u.DO.Save(values)
  254. }
  255. func (u userAccountDo) First() (*model.UserAccount, error) {
  256. if result, err := u.DO.First(); err != nil {
  257. return nil, err
  258. } else {
  259. return result.(*model.UserAccount), nil
  260. }
  261. }
  262. func (u userAccountDo) Take() (*model.UserAccount, error) {
  263. if result, err := u.DO.Take(); err != nil {
  264. return nil, err
  265. } else {
  266. return result.(*model.UserAccount), nil
  267. }
  268. }
  269. func (u userAccountDo) Last() (*model.UserAccount, error) {
  270. if result, err := u.DO.Last(); err != nil {
  271. return nil, err
  272. } else {
  273. return result.(*model.UserAccount), nil
  274. }
  275. }
  276. func (u userAccountDo) Find() ([]*model.UserAccount, error) {
  277. result, err := u.DO.Find()
  278. return result.([]*model.UserAccount), err
  279. }
  280. func (u userAccountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserAccount, err error) {
  281. buf := make([]*model.UserAccount, 0, batchSize)
  282. err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  283. defer func() { results = append(results, buf...) }()
  284. return fc(tx, batch)
  285. })
  286. return results, err
  287. }
  288. func (u userAccountDo) FindInBatches(result *[]*model.UserAccount, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  289. return u.DO.FindInBatches(result, batchSize, fc)
  290. }
  291. func (u userAccountDo) Attrs(attrs ...field.AssignExpr) *userAccountDo {
  292. return u.withDO(u.DO.Attrs(attrs...))
  293. }
  294. func (u userAccountDo) Assign(attrs ...field.AssignExpr) *userAccountDo {
  295. return u.withDO(u.DO.Assign(attrs...))
  296. }
  297. func (u userAccountDo) Joins(fields ...field.RelationField) *userAccountDo {
  298. for _, _f := range fields {
  299. u = *u.withDO(u.DO.Joins(_f))
  300. }
  301. return &u
  302. }
  303. func (u userAccountDo) Preload(fields ...field.RelationField) *userAccountDo {
  304. for _, _f := range fields {
  305. u = *u.withDO(u.DO.Preload(_f))
  306. }
  307. return &u
  308. }
  309. func (u userAccountDo) FirstOrInit() (*model.UserAccount, error) {
  310. if result, err := u.DO.FirstOrInit(); err != nil {
  311. return nil, err
  312. } else {
  313. return result.(*model.UserAccount), nil
  314. }
  315. }
  316. func (u userAccountDo) FirstOrCreate() (*model.UserAccount, error) {
  317. if result, err := u.DO.FirstOrCreate(); err != nil {
  318. return nil, err
  319. } else {
  320. return result.(*model.UserAccount), nil
  321. }
  322. }
  323. func (u userAccountDo) FindByPage(offset int, limit int) (result []*model.UserAccount, count int64, err error) {
  324. result, err = u.Offset(offset).Limit(limit).Find()
  325. if err != nil {
  326. return
  327. }
  328. if size := len(result); 0 < limit && 0 < size && size < limit {
  329. count = int64(size + offset)
  330. return
  331. }
  332. count, err = u.Offset(-1).Limit(-1).Count()
  333. return
  334. }
  335. func (u userAccountDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  336. count, err = u.Count()
  337. if err != nil {
  338. return
  339. }
  340. err = u.Offset(offset).Limit(limit).Scan(result)
  341. return
  342. }
  343. func (u userAccountDo) Scan(result interface{}) (err error) {
  344. return u.DO.Scan(result)
  345. }
  346. func (u userAccountDo) Delete(models ...*model.UserAccount) (result gen.ResultInfo, err error) {
  347. return u.DO.Delete(models)
  348. }
  349. func (u *userAccountDo) withDO(do gen.Dao) *userAccountDo {
  350. u.DO = *do.(*gen.DO)
  351. return u
  352. }