chapter_logs.gen.go 10 KB

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