user_chapter_logs.gen.go 10 KB

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