chapter_logs_user_details.gen.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 newChapterLogsUserDetail(db *gorm.DB, opts ...gen.DOOption) chapterLogsUserDetail {
  16. _chapterLogsUserDetail := chapterLogsUserDetail{}
  17. _chapterLogsUserDetail.chapterLogsUserDetailDo.UseDB(db, opts...)
  18. _chapterLogsUserDetail.chapterLogsUserDetailDo.UseModel(&model.ChapterLogsUserDetail{})
  19. tableName := _chapterLogsUserDetail.chapterLogsUserDetailDo.TableName()
  20. _chapterLogsUserDetail.ALL = field.NewAsterisk(tableName)
  21. _chapterLogsUserDetail.ID = field.NewInt64(tableName, "id")
  22. _chapterLogsUserDetail.UserID = field.NewInt64(tableName, "user_id")
  23. _chapterLogsUserDetail.ServerID = field.NewInt32(tableName, "server_id")
  24. _chapterLogsUserDetail.EventID = field.NewInt32(tableName, "event_id")
  25. _chapterLogsUserDetail.ChapterID = field.NewInt32(tableName, "chapter_id")
  26. _chapterLogsUserDetail.RoomID = field.NewInt32(tableName, "room_id")
  27. _chapterLogsUserDetail.UserCreatedAt = field.NewInt32(tableName, "user_created_at")
  28. _chapterLogsUserDetail.EventAt = field.NewInt32(tableName, "event_at")
  29. _chapterLogsUserDetail.Extra = field.NewString(tableName, "extra")
  30. _chapterLogsUserDetail.Token = field.NewString(tableName, "token")
  31. _chapterLogsUserDetail.Difficulty = field.NewInt32(tableName, "difficulty")
  32. _chapterLogsUserDetail.EventAtNs = field.NewInt64(tableName, "event_at_ns")
  33. _chapterLogsUserDetail.fillFieldMap()
  34. return _chapterLogsUserDetail
  35. }
  36. type chapterLogsUserDetail struct {
  37. chapterLogsUserDetailDo
  38. ALL field.Asterisk
  39. ID field.Int64
  40. UserID field.Int64 // 用户id
  41. ServerID field.Int32 // 服务器ID
  42. EventID field.Int32 // 埋点id
  43. ChapterID field.Int32 // 关卡id
  44. RoomID field.Int32 // 房间id
  45. UserCreatedAt field.Int32 // 用户注册时间
  46. EventAt field.Int32 // 埋点事件触发的时间
  47. Extra field.String // 其他参数
  48. Token field.String // 登陆的token
  49. Difficulty field.Int32 // 困难度
  50. EventAtNs field.Int64 // 埋点事件触发的时间
  51. fieldMap map[string]field.Expr
  52. }
  53. func (c chapterLogsUserDetail) Table(newTableName string) *chapterLogsUserDetail {
  54. c.chapterLogsUserDetailDo.UseTable(newTableName)
  55. return c.updateTableName(newTableName)
  56. }
  57. func (c chapterLogsUserDetail) As(alias string) *chapterLogsUserDetail {
  58. c.chapterLogsUserDetailDo.DO = *(c.chapterLogsUserDetailDo.As(alias).(*gen.DO))
  59. return c.updateTableName(alias)
  60. }
  61. func (c *chapterLogsUserDetail) updateTableName(table string) *chapterLogsUserDetail {
  62. c.ALL = field.NewAsterisk(table)
  63. c.ID = field.NewInt64(table, "id")
  64. c.UserID = field.NewInt64(table, "user_id")
  65. c.ServerID = field.NewInt32(table, "server_id")
  66. c.EventID = field.NewInt32(table, "event_id")
  67. c.ChapterID = field.NewInt32(table, "chapter_id")
  68. c.RoomID = field.NewInt32(table, "room_id")
  69. c.UserCreatedAt = field.NewInt32(table, "user_created_at")
  70. c.EventAt = field.NewInt32(table, "event_at")
  71. c.Extra = field.NewString(table, "extra")
  72. c.Token = field.NewString(table, "token")
  73. c.Difficulty = field.NewInt32(table, "difficulty")
  74. c.EventAtNs = field.NewInt64(table, "event_at_ns")
  75. c.fillFieldMap()
  76. return c
  77. }
  78. func (c *chapterLogsUserDetail) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  79. _f, ok := c.fieldMap[fieldName]
  80. if !ok || _f == nil {
  81. return nil, false
  82. }
  83. _oe, ok := _f.(field.OrderExpr)
  84. return _oe, ok
  85. }
  86. func (c *chapterLogsUserDetail) fillFieldMap() {
  87. c.fieldMap = make(map[string]field.Expr, 12)
  88. c.fieldMap["id"] = c.ID
  89. c.fieldMap["user_id"] = c.UserID
  90. c.fieldMap["server_id"] = c.ServerID
  91. c.fieldMap["event_id"] = c.EventID
  92. c.fieldMap["chapter_id"] = c.ChapterID
  93. c.fieldMap["room_id"] = c.RoomID
  94. c.fieldMap["user_created_at"] = c.UserCreatedAt
  95. c.fieldMap["event_at"] = c.EventAt
  96. c.fieldMap["extra"] = c.Extra
  97. c.fieldMap["token"] = c.Token
  98. c.fieldMap["difficulty"] = c.Difficulty
  99. c.fieldMap["event_at_ns"] = c.EventAtNs
  100. }
  101. func (c chapterLogsUserDetail) clone(db *gorm.DB) chapterLogsUserDetail {
  102. c.chapterLogsUserDetailDo.ReplaceConnPool(db.Statement.ConnPool)
  103. return c
  104. }
  105. func (c chapterLogsUserDetail) replaceDB(db *gorm.DB) chapterLogsUserDetail {
  106. c.chapterLogsUserDetailDo.ReplaceDB(db)
  107. return c
  108. }
  109. type chapterLogsUserDetailDo struct{ gen.DO }
  110. func (c chapterLogsUserDetailDo) Debug() *chapterLogsUserDetailDo {
  111. return c.withDO(c.DO.Debug())
  112. }
  113. func (c chapterLogsUserDetailDo) WithContext(ctx context.Context) *chapterLogsUserDetailDo {
  114. return c.withDO(c.DO.WithContext(ctx))
  115. }
  116. func (c chapterLogsUserDetailDo) ReadDB() *chapterLogsUserDetailDo {
  117. return c.Clauses(dbresolver.Read)
  118. }
  119. func (c chapterLogsUserDetailDo) WriteDB() *chapterLogsUserDetailDo {
  120. return c.Clauses(dbresolver.Write)
  121. }
  122. func (c chapterLogsUserDetailDo) Session(config *gorm.Session) *chapterLogsUserDetailDo {
  123. return c.withDO(c.DO.Session(config))
  124. }
  125. func (c chapterLogsUserDetailDo) Clauses(conds ...clause.Expression) *chapterLogsUserDetailDo {
  126. return c.withDO(c.DO.Clauses(conds...))
  127. }
  128. func (c chapterLogsUserDetailDo) Returning(value interface{}, columns ...string) *chapterLogsUserDetailDo {
  129. return c.withDO(c.DO.Returning(value, columns...))
  130. }
  131. func (c chapterLogsUserDetailDo) Not(conds ...gen.Condition) *chapterLogsUserDetailDo {
  132. return c.withDO(c.DO.Not(conds...))
  133. }
  134. func (c chapterLogsUserDetailDo) Or(conds ...gen.Condition) *chapterLogsUserDetailDo {
  135. return c.withDO(c.DO.Or(conds...))
  136. }
  137. func (c chapterLogsUserDetailDo) Select(conds ...field.Expr) *chapterLogsUserDetailDo {
  138. return c.withDO(c.DO.Select(conds...))
  139. }
  140. func (c chapterLogsUserDetailDo) Where(conds ...gen.Condition) *chapterLogsUserDetailDo {
  141. return c.withDO(c.DO.Where(conds...))
  142. }
  143. func (c chapterLogsUserDetailDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *chapterLogsUserDetailDo {
  144. return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  145. }
  146. func (c chapterLogsUserDetailDo) Order(conds ...field.Expr) *chapterLogsUserDetailDo {
  147. return c.withDO(c.DO.Order(conds...))
  148. }
  149. func (c chapterLogsUserDetailDo) Distinct(cols ...field.Expr) *chapterLogsUserDetailDo {
  150. return c.withDO(c.DO.Distinct(cols...))
  151. }
  152. func (c chapterLogsUserDetailDo) Omit(cols ...field.Expr) *chapterLogsUserDetailDo {
  153. return c.withDO(c.DO.Omit(cols...))
  154. }
  155. func (c chapterLogsUserDetailDo) Join(table schema.Tabler, on ...field.Expr) *chapterLogsUserDetailDo {
  156. return c.withDO(c.DO.Join(table, on...))
  157. }
  158. func (c chapterLogsUserDetailDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chapterLogsUserDetailDo {
  159. return c.withDO(c.DO.LeftJoin(table, on...))
  160. }
  161. func (c chapterLogsUserDetailDo) RightJoin(table schema.Tabler, on ...field.Expr) *chapterLogsUserDetailDo {
  162. return c.withDO(c.DO.RightJoin(table, on...))
  163. }
  164. func (c chapterLogsUserDetailDo) Group(cols ...field.Expr) *chapterLogsUserDetailDo {
  165. return c.withDO(c.DO.Group(cols...))
  166. }
  167. func (c chapterLogsUserDetailDo) Having(conds ...gen.Condition) *chapterLogsUserDetailDo {
  168. return c.withDO(c.DO.Having(conds...))
  169. }
  170. func (c chapterLogsUserDetailDo) Limit(limit int) *chapterLogsUserDetailDo {
  171. return c.withDO(c.DO.Limit(limit))
  172. }
  173. func (c chapterLogsUserDetailDo) Offset(offset int) *chapterLogsUserDetailDo {
  174. return c.withDO(c.DO.Offset(offset))
  175. }
  176. func (c chapterLogsUserDetailDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chapterLogsUserDetailDo {
  177. return c.withDO(c.DO.Scopes(funcs...))
  178. }
  179. func (c chapterLogsUserDetailDo) Unscoped() *chapterLogsUserDetailDo {
  180. return c.withDO(c.DO.Unscoped())
  181. }
  182. func (c chapterLogsUserDetailDo) Create(values ...*model.ChapterLogsUserDetail) error {
  183. if len(values) == 0 {
  184. return nil
  185. }
  186. return c.DO.Create(values)
  187. }
  188. func (c chapterLogsUserDetailDo) CreateInBatches(values []*model.ChapterLogsUserDetail, batchSize int) error {
  189. return c.DO.CreateInBatches(values, batchSize)
  190. }
  191. // Save : !!! underlying implementation is different with GORM
  192. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  193. func (c chapterLogsUserDetailDo) Save(values ...*model.ChapterLogsUserDetail) error {
  194. if len(values) == 0 {
  195. return nil
  196. }
  197. return c.DO.Save(values)
  198. }
  199. func (c chapterLogsUserDetailDo) First() (*model.ChapterLogsUserDetail, error) {
  200. if result, err := c.DO.First(); err != nil {
  201. return nil, err
  202. } else {
  203. return result.(*model.ChapterLogsUserDetail), nil
  204. }
  205. }
  206. func (c chapterLogsUserDetailDo) Take() (*model.ChapterLogsUserDetail, error) {
  207. if result, err := c.DO.Take(); err != nil {
  208. return nil, err
  209. } else {
  210. return result.(*model.ChapterLogsUserDetail), nil
  211. }
  212. }
  213. func (c chapterLogsUserDetailDo) Last() (*model.ChapterLogsUserDetail, error) {
  214. if result, err := c.DO.Last(); err != nil {
  215. return nil, err
  216. } else {
  217. return result.(*model.ChapterLogsUserDetail), nil
  218. }
  219. }
  220. func (c chapterLogsUserDetailDo) Find() ([]*model.ChapterLogsUserDetail, error) {
  221. result, err := c.DO.Find()
  222. return result.([]*model.ChapterLogsUserDetail), err
  223. }
  224. func (c chapterLogsUserDetailDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChapterLogsUserDetail, err error) {
  225. buf := make([]*model.ChapterLogsUserDetail, 0, batchSize)
  226. err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  227. defer func() { results = append(results, buf...) }()
  228. return fc(tx, batch)
  229. })
  230. return results, err
  231. }
  232. func (c chapterLogsUserDetailDo) FindInBatches(result *[]*model.ChapterLogsUserDetail, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  233. return c.DO.FindInBatches(result, batchSize, fc)
  234. }
  235. func (c chapterLogsUserDetailDo) Attrs(attrs ...field.AssignExpr) *chapterLogsUserDetailDo {
  236. return c.withDO(c.DO.Attrs(attrs...))
  237. }
  238. func (c chapterLogsUserDetailDo) Assign(attrs ...field.AssignExpr) *chapterLogsUserDetailDo {
  239. return c.withDO(c.DO.Assign(attrs...))
  240. }
  241. func (c chapterLogsUserDetailDo) Joins(fields ...field.RelationField) *chapterLogsUserDetailDo {
  242. for _, _f := range fields {
  243. c = *c.withDO(c.DO.Joins(_f))
  244. }
  245. return &c
  246. }
  247. func (c chapterLogsUserDetailDo) Preload(fields ...field.RelationField) *chapterLogsUserDetailDo {
  248. for _, _f := range fields {
  249. c = *c.withDO(c.DO.Preload(_f))
  250. }
  251. return &c
  252. }
  253. func (c chapterLogsUserDetailDo) FirstOrInit() (*model.ChapterLogsUserDetail, error) {
  254. if result, err := c.DO.FirstOrInit(); err != nil {
  255. return nil, err
  256. } else {
  257. return result.(*model.ChapterLogsUserDetail), nil
  258. }
  259. }
  260. func (c chapterLogsUserDetailDo) FirstOrCreate() (*model.ChapterLogsUserDetail, error) {
  261. if result, err := c.DO.FirstOrCreate(); err != nil {
  262. return nil, err
  263. } else {
  264. return result.(*model.ChapterLogsUserDetail), nil
  265. }
  266. }
  267. func (c chapterLogsUserDetailDo) FindByPage(offset int, limit int) (result []*model.ChapterLogsUserDetail, count int64, err error) {
  268. result, err = c.Offset(offset).Limit(limit).Find()
  269. if err != nil {
  270. return
  271. }
  272. if size := len(result); 0 < limit && 0 < size && size < limit {
  273. count = int64(size + offset)
  274. return
  275. }
  276. count, err = c.Offset(-1).Limit(-1).Count()
  277. return
  278. }
  279. func (c chapterLogsUserDetailDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  280. count, err = c.Count()
  281. if err != nil {
  282. return
  283. }
  284. err = c.Offset(offset).Limit(limit).Scan(result)
  285. return
  286. }
  287. func (c chapterLogsUserDetailDo) Scan(result interface{}) (err error) {
  288. return c.DO.Scan(result)
  289. }
  290. func (c chapterLogsUserDetailDo) Delete(models ...*model.ChapterLogsUserDetail) (result gen.ResultInfo, err error) {
  291. return c.DO.Delete(models)
  292. }
  293. func (c *chapterLogsUserDetailDo) withDO(do gen.Dao) *chapterLogsUserDetailDo {
  294. c.DO = *do.(*gen.DO)
  295. return c
  296. }