report_day_basic.gen.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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 newReportDayBasic(db *gorm.DB, opts ...gen.DOOption) reportDayBasic {
  16. _reportDayBasic := reportDayBasic{}
  17. _reportDayBasic.reportDayBasicDo.UseDB(db, opts...)
  18. _reportDayBasic.reportDayBasicDo.UseModel(&model.ReportDayBasic{})
  19. tableName := _reportDayBasic.reportDayBasicDo.TableName()
  20. _reportDayBasic.ALL = field.NewAsterisk(tableName)
  21. _reportDayBasic.ID = field.NewInt64(tableName, "id")
  22. _reportDayBasic.Date = field.NewString(tableName, "date")
  23. _reportDayBasic.ChannelID = field.NewString(tableName, "channel_id")
  24. _reportDayBasic.Flag = field.NewInt32(tableName, "flag")
  25. _reportDayBasic.ServerID = field.NewInt32(tableName, "server_id")
  26. _reportDayBasic.NewCount = field.NewInt64(tableName, "new_count")
  27. _reportDayBasic.ValidCount = field.NewInt64(tableName, "valid_count")
  28. _reportDayBasic.ActiveCount = field.NewInt64(tableName, "active_count")
  29. _reportDayBasic.OldCount = field.NewInt64(tableName, "old_count")
  30. _reportDayBasic.NewDuration = field.NewInt64(tableName, "new_duration")
  31. _reportDayBasic.ValidDuration = field.NewInt64(tableName, "valid_duration")
  32. _reportDayBasic.ActiveDuration = field.NewInt64(tableName, "active_duration")
  33. _reportDayBasic.Active1Day = field.NewInt64(tableName, "active_1_day")
  34. _reportDayBasic.Active2Day = field.NewInt64(tableName, "active_2_day")
  35. _reportDayBasic.Active3Day = field.NewInt64(tableName, "active_3_day")
  36. _reportDayBasic.Active4Day = field.NewInt64(tableName, "active_4_day")
  37. _reportDayBasic.Active5Day = field.NewInt64(tableName, "active_5_day")
  38. _reportDayBasic.Active6Day = field.NewInt64(tableName, "active_6_day")
  39. _reportDayBasic.Active7Day = field.NewInt64(tableName, "active_7_day")
  40. _reportDayBasic.Active14Day = field.NewInt64(tableName, "active_14_day")
  41. _reportDayBasic.Active30Day = field.NewInt64(tableName, "active_30_day")
  42. _reportDayBasic.C1 = field.NewInt64(tableName, "c1")
  43. _reportDayBasic.C2 = field.NewInt64(tableName, "c2")
  44. _reportDayBasic.C3 = field.NewInt64(tableName, "c3")
  45. _reportDayBasic.C4 = field.NewInt64(tableName, "c4")
  46. _reportDayBasic.C5 = field.NewInt64(tableName, "c5")
  47. _reportDayBasic.C6 = field.NewInt64(tableName, "c6")
  48. _reportDayBasic.C7 = field.NewInt64(tableName, "c7")
  49. _reportDayBasic.C14 = field.NewInt64(tableName, "c14")
  50. _reportDayBasic.C30 = field.NewInt64(tableName, "c30")
  51. _reportDayBasic.CreatedAt = field.NewInt32(tableName, "created_at")
  52. _reportDayBasic.UpdatedAt = field.NewInt32(tableName, "updated_at")
  53. _reportDayBasic.fillFieldMap()
  54. return _reportDayBasic
  55. }
  56. type reportDayBasic struct {
  57. reportDayBasicDo
  58. ALL field.Asterisk
  59. ID field.Int64
  60. Date field.String
  61. ChannelID field.String // 渠道ID
  62. Flag field.Int32
  63. ServerID field.Int32 // 服务器ID
  64. NewCount field.Int64
  65. ValidCount field.Int64 // 有效用户
  66. ActiveCount field.Int64
  67. OldCount field.Int64 // 老玩家数量
  68. NewDuration field.Int64 // 新增用户的平均时长
  69. ValidDuration field.Int64
  70. ActiveDuration field.Int64 // 活跃用户的平均时长
  71. Active1Day field.Int64
  72. Active2Day field.Int64
  73. Active3Day field.Int64
  74. Active4Day field.Int64
  75. Active5Day field.Int64
  76. Active6Day field.Int64
  77. Active7Day field.Int64
  78. Active14Day field.Int64
  79. Active30Day field.Int64
  80. C1 field.Int64
  81. C2 field.Int64
  82. C3 field.Int64
  83. C4 field.Int64
  84. C5 field.Int64
  85. C6 field.Int64
  86. C7 field.Int64
  87. C14 field.Int64
  88. C30 field.Int64
  89. CreatedAt field.Int32
  90. UpdatedAt field.Int32
  91. fieldMap map[string]field.Expr
  92. }
  93. func (r reportDayBasic) Table(newTableName string) *reportDayBasic {
  94. r.reportDayBasicDo.UseTable(newTableName)
  95. return r.updateTableName(newTableName)
  96. }
  97. func (r reportDayBasic) As(alias string) *reportDayBasic {
  98. r.reportDayBasicDo.DO = *(r.reportDayBasicDo.As(alias).(*gen.DO))
  99. return r.updateTableName(alias)
  100. }
  101. func (r *reportDayBasic) updateTableName(table string) *reportDayBasic {
  102. r.ALL = field.NewAsterisk(table)
  103. r.ID = field.NewInt64(table, "id")
  104. r.Date = field.NewString(table, "date")
  105. r.ChannelID = field.NewString(table, "channel_id")
  106. r.Flag = field.NewInt32(table, "flag")
  107. r.ServerID = field.NewInt32(table, "server_id")
  108. r.NewCount = field.NewInt64(table, "new_count")
  109. r.ValidCount = field.NewInt64(table, "valid_count")
  110. r.ActiveCount = field.NewInt64(table, "active_count")
  111. r.OldCount = field.NewInt64(table, "old_count")
  112. r.NewDuration = field.NewInt64(table, "new_duration")
  113. r.ValidDuration = field.NewInt64(table, "valid_duration")
  114. r.ActiveDuration = field.NewInt64(table, "active_duration")
  115. r.Active1Day = field.NewInt64(table, "active_1_day")
  116. r.Active2Day = field.NewInt64(table, "active_2_day")
  117. r.Active3Day = field.NewInt64(table, "active_3_day")
  118. r.Active4Day = field.NewInt64(table, "active_4_day")
  119. r.Active5Day = field.NewInt64(table, "active_5_day")
  120. r.Active6Day = field.NewInt64(table, "active_6_day")
  121. r.Active7Day = field.NewInt64(table, "active_7_day")
  122. r.Active14Day = field.NewInt64(table, "active_14_day")
  123. r.Active30Day = field.NewInt64(table, "active_30_day")
  124. r.C1 = field.NewInt64(table, "c1")
  125. r.C2 = field.NewInt64(table, "c2")
  126. r.C3 = field.NewInt64(table, "c3")
  127. r.C4 = field.NewInt64(table, "c4")
  128. r.C5 = field.NewInt64(table, "c5")
  129. r.C6 = field.NewInt64(table, "c6")
  130. r.C7 = field.NewInt64(table, "c7")
  131. r.C14 = field.NewInt64(table, "c14")
  132. r.C30 = field.NewInt64(table, "c30")
  133. r.CreatedAt = field.NewInt32(table, "created_at")
  134. r.UpdatedAt = field.NewInt32(table, "updated_at")
  135. r.fillFieldMap()
  136. return r
  137. }
  138. func (r *reportDayBasic) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  139. _f, ok := r.fieldMap[fieldName]
  140. if !ok || _f == nil {
  141. return nil, false
  142. }
  143. _oe, ok := _f.(field.OrderExpr)
  144. return _oe, ok
  145. }
  146. func (r *reportDayBasic) fillFieldMap() {
  147. r.fieldMap = make(map[string]field.Expr, 32)
  148. r.fieldMap["id"] = r.ID
  149. r.fieldMap["date"] = r.Date
  150. r.fieldMap["channel_id"] = r.ChannelID
  151. r.fieldMap["flag"] = r.Flag
  152. r.fieldMap["server_id"] = r.ServerID
  153. r.fieldMap["new_count"] = r.NewCount
  154. r.fieldMap["valid_count"] = r.ValidCount
  155. r.fieldMap["active_count"] = r.ActiveCount
  156. r.fieldMap["old_count"] = r.OldCount
  157. r.fieldMap["new_duration"] = r.NewDuration
  158. r.fieldMap["valid_duration"] = r.ValidDuration
  159. r.fieldMap["active_duration"] = r.ActiveDuration
  160. r.fieldMap["active_1_day"] = r.Active1Day
  161. r.fieldMap["active_2_day"] = r.Active2Day
  162. r.fieldMap["active_3_day"] = r.Active3Day
  163. r.fieldMap["active_4_day"] = r.Active4Day
  164. r.fieldMap["active_5_day"] = r.Active5Day
  165. r.fieldMap["active_6_day"] = r.Active6Day
  166. r.fieldMap["active_7_day"] = r.Active7Day
  167. r.fieldMap["active_14_day"] = r.Active14Day
  168. r.fieldMap["active_30_day"] = r.Active30Day
  169. r.fieldMap["c1"] = r.C1
  170. r.fieldMap["c2"] = r.C2
  171. r.fieldMap["c3"] = r.C3
  172. r.fieldMap["c4"] = r.C4
  173. r.fieldMap["c5"] = r.C5
  174. r.fieldMap["c6"] = r.C6
  175. r.fieldMap["c7"] = r.C7
  176. r.fieldMap["c14"] = r.C14
  177. r.fieldMap["c30"] = r.C30
  178. r.fieldMap["created_at"] = r.CreatedAt
  179. r.fieldMap["updated_at"] = r.UpdatedAt
  180. }
  181. func (r reportDayBasic) clone(db *gorm.DB) reportDayBasic {
  182. r.reportDayBasicDo.ReplaceConnPool(db.Statement.ConnPool)
  183. return r
  184. }
  185. func (r reportDayBasic) replaceDB(db *gorm.DB) reportDayBasic {
  186. r.reportDayBasicDo.ReplaceDB(db)
  187. return r
  188. }
  189. type reportDayBasicDo struct{ gen.DO }
  190. func (r reportDayBasicDo) Debug() *reportDayBasicDo {
  191. return r.withDO(r.DO.Debug())
  192. }
  193. func (r reportDayBasicDo) WithContext(ctx context.Context) *reportDayBasicDo {
  194. return r.withDO(r.DO.WithContext(ctx))
  195. }
  196. func (r reportDayBasicDo) ReadDB() *reportDayBasicDo {
  197. return r.Clauses(dbresolver.Read)
  198. }
  199. func (r reportDayBasicDo) WriteDB() *reportDayBasicDo {
  200. return r.Clauses(dbresolver.Write)
  201. }
  202. func (r reportDayBasicDo) Session(config *gorm.Session) *reportDayBasicDo {
  203. return r.withDO(r.DO.Session(config))
  204. }
  205. func (r reportDayBasicDo) Clauses(conds ...clause.Expression) *reportDayBasicDo {
  206. return r.withDO(r.DO.Clauses(conds...))
  207. }
  208. func (r reportDayBasicDo) Returning(value interface{}, columns ...string) *reportDayBasicDo {
  209. return r.withDO(r.DO.Returning(value, columns...))
  210. }
  211. func (r reportDayBasicDo) Not(conds ...gen.Condition) *reportDayBasicDo {
  212. return r.withDO(r.DO.Not(conds...))
  213. }
  214. func (r reportDayBasicDo) Or(conds ...gen.Condition) *reportDayBasicDo {
  215. return r.withDO(r.DO.Or(conds...))
  216. }
  217. func (r reportDayBasicDo) Select(conds ...field.Expr) *reportDayBasicDo {
  218. return r.withDO(r.DO.Select(conds...))
  219. }
  220. func (r reportDayBasicDo) Where(conds ...gen.Condition) *reportDayBasicDo {
  221. return r.withDO(r.DO.Where(conds...))
  222. }
  223. func (r reportDayBasicDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *reportDayBasicDo {
  224. return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  225. }
  226. func (r reportDayBasicDo) Order(conds ...field.Expr) *reportDayBasicDo {
  227. return r.withDO(r.DO.Order(conds...))
  228. }
  229. func (r reportDayBasicDo) Distinct(cols ...field.Expr) *reportDayBasicDo {
  230. return r.withDO(r.DO.Distinct(cols...))
  231. }
  232. func (r reportDayBasicDo) Omit(cols ...field.Expr) *reportDayBasicDo {
  233. return r.withDO(r.DO.Omit(cols...))
  234. }
  235. func (r reportDayBasicDo) Join(table schema.Tabler, on ...field.Expr) *reportDayBasicDo {
  236. return r.withDO(r.DO.Join(table, on...))
  237. }
  238. func (r reportDayBasicDo) LeftJoin(table schema.Tabler, on ...field.Expr) *reportDayBasicDo {
  239. return r.withDO(r.DO.LeftJoin(table, on...))
  240. }
  241. func (r reportDayBasicDo) RightJoin(table schema.Tabler, on ...field.Expr) *reportDayBasicDo {
  242. return r.withDO(r.DO.RightJoin(table, on...))
  243. }
  244. func (r reportDayBasicDo) Group(cols ...field.Expr) *reportDayBasicDo {
  245. return r.withDO(r.DO.Group(cols...))
  246. }
  247. func (r reportDayBasicDo) Having(conds ...gen.Condition) *reportDayBasicDo {
  248. return r.withDO(r.DO.Having(conds...))
  249. }
  250. func (r reportDayBasicDo) Limit(limit int) *reportDayBasicDo {
  251. return r.withDO(r.DO.Limit(limit))
  252. }
  253. func (r reportDayBasicDo) Offset(offset int) *reportDayBasicDo {
  254. return r.withDO(r.DO.Offset(offset))
  255. }
  256. func (r reportDayBasicDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *reportDayBasicDo {
  257. return r.withDO(r.DO.Scopes(funcs...))
  258. }
  259. func (r reportDayBasicDo) Unscoped() *reportDayBasicDo {
  260. return r.withDO(r.DO.Unscoped())
  261. }
  262. func (r reportDayBasicDo) Create(values ...*model.ReportDayBasic) error {
  263. if len(values) == 0 {
  264. return nil
  265. }
  266. return r.DO.Create(values)
  267. }
  268. func (r reportDayBasicDo) CreateInBatches(values []*model.ReportDayBasic, batchSize int) error {
  269. return r.DO.CreateInBatches(values, batchSize)
  270. }
  271. // Save : !!! underlying implementation is different with GORM
  272. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  273. func (r reportDayBasicDo) Save(values ...*model.ReportDayBasic) error {
  274. if len(values) == 0 {
  275. return nil
  276. }
  277. return r.DO.Save(values)
  278. }
  279. func (r reportDayBasicDo) First() (*model.ReportDayBasic, error) {
  280. if result, err := r.DO.First(); err != nil {
  281. return nil, err
  282. } else {
  283. return result.(*model.ReportDayBasic), nil
  284. }
  285. }
  286. func (r reportDayBasicDo) Take() (*model.ReportDayBasic, error) {
  287. if result, err := r.DO.Take(); err != nil {
  288. return nil, err
  289. } else {
  290. return result.(*model.ReportDayBasic), nil
  291. }
  292. }
  293. func (r reportDayBasicDo) Last() (*model.ReportDayBasic, error) {
  294. if result, err := r.DO.Last(); err != nil {
  295. return nil, err
  296. } else {
  297. return result.(*model.ReportDayBasic), nil
  298. }
  299. }
  300. func (r reportDayBasicDo) Find() ([]*model.ReportDayBasic, error) {
  301. result, err := r.DO.Find()
  302. return result.([]*model.ReportDayBasic), err
  303. }
  304. func (r reportDayBasicDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ReportDayBasic, err error) {
  305. buf := make([]*model.ReportDayBasic, 0, batchSize)
  306. err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  307. defer func() { results = append(results, buf...) }()
  308. return fc(tx, batch)
  309. })
  310. return results, err
  311. }
  312. func (r reportDayBasicDo) FindInBatches(result *[]*model.ReportDayBasic, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  313. return r.DO.FindInBatches(result, batchSize, fc)
  314. }
  315. func (r reportDayBasicDo) Attrs(attrs ...field.AssignExpr) *reportDayBasicDo {
  316. return r.withDO(r.DO.Attrs(attrs...))
  317. }
  318. func (r reportDayBasicDo) Assign(attrs ...field.AssignExpr) *reportDayBasicDo {
  319. return r.withDO(r.DO.Assign(attrs...))
  320. }
  321. func (r reportDayBasicDo) Joins(fields ...field.RelationField) *reportDayBasicDo {
  322. for _, _f := range fields {
  323. r = *r.withDO(r.DO.Joins(_f))
  324. }
  325. return &r
  326. }
  327. func (r reportDayBasicDo) Preload(fields ...field.RelationField) *reportDayBasicDo {
  328. for _, _f := range fields {
  329. r = *r.withDO(r.DO.Preload(_f))
  330. }
  331. return &r
  332. }
  333. func (r reportDayBasicDo) FirstOrInit() (*model.ReportDayBasic, error) {
  334. if result, err := r.DO.FirstOrInit(); err != nil {
  335. return nil, err
  336. } else {
  337. return result.(*model.ReportDayBasic), nil
  338. }
  339. }
  340. func (r reportDayBasicDo) FirstOrCreate() (*model.ReportDayBasic, error) {
  341. if result, err := r.DO.FirstOrCreate(); err != nil {
  342. return nil, err
  343. } else {
  344. return result.(*model.ReportDayBasic), nil
  345. }
  346. }
  347. func (r reportDayBasicDo) FindByPage(offset int, limit int) (result []*model.ReportDayBasic, count int64, err error) {
  348. result, err = r.Offset(offset).Limit(limit).Find()
  349. if err != nil {
  350. return
  351. }
  352. if size := len(result); 0 < limit && 0 < size && size < limit {
  353. count = int64(size + offset)
  354. return
  355. }
  356. count, err = r.Offset(-1).Limit(-1).Count()
  357. return
  358. }
  359. func (r reportDayBasicDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  360. count, err = r.Count()
  361. if err != nil {
  362. return
  363. }
  364. err = r.Offset(offset).Limit(limit).Scan(result)
  365. return
  366. }
  367. func (r reportDayBasicDo) Scan(result interface{}) (err error) {
  368. return r.DO.Scan(result)
  369. }
  370. func (r reportDayBasicDo) Delete(models ...*model.ReportDayBasic) (result gen.ResultInfo, err error) {
  371. return r.DO.Delete(models)
  372. }
  373. func (r *reportDayBasicDo) withDO(do gen.Dao) *reportDayBasicDo {
  374. r.DO = *do.(*gen.DO)
  375. return r
  376. }