report_day_treasure_chest.gen.go 11 KB

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