changed_statistics.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 newChangedStatistic(db *gorm.DB, opts ...gen.DOOption) changedStatistic {
  16. _changedStatistic := changedStatistic{}
  17. _changedStatistic.changedStatisticDo.UseDB(db, opts...)
  18. _changedStatistic.changedStatisticDo.UseModel(&model.ChangedStatistic{})
  19. tableName := _changedStatistic.changedStatisticDo.TableName()
  20. _changedStatistic.ALL = field.NewAsterisk(tableName)
  21. _changedStatistic.ID = field.NewInt64(tableName, "id")
  22. _changedStatistic.ChannelID = field.NewString(tableName, "channel_id")
  23. _changedStatistic.ServerID = field.NewInt32(tableName, "server_id")
  24. _changedStatistic.Type = field.NewInt32(tableName, "type")
  25. _changedStatistic.Source = field.NewInt32(tableName, "source")
  26. _changedStatistic.Amount = field.NewInt64(tableName, "amount")
  27. _changedStatistic.Players = field.NewString(tableName, "players")
  28. _changedStatistic.Counts = field.NewInt64(tableName, "counts")
  29. _changedStatistic.Date = field.NewString(tableName, "date")
  30. _changedStatistic.fillFieldMap()
  31. return _changedStatistic
  32. }
  33. type changedStatistic struct {
  34. changedStatisticDo
  35. ALL field.Asterisk
  36. ID field.Int64
  37. ChannelID field.String // 渠道ID
  38. ServerID field.Int32 // 服务器ID
  39. Type field.Int32 // 消费类型
  40. Source field.Int32 // 消费来源
  41. Amount field.Int64 // 消费金额
  42. Players field.String // 消费玩家ID集合
  43. Counts field.Int64 // 消费次数
  44. Date field.String // 日期
  45. fieldMap map[string]field.Expr
  46. }
  47. func (c changedStatistic) Table(newTableName string) *changedStatistic {
  48. c.changedStatisticDo.UseTable(newTableName)
  49. return c.updateTableName(newTableName)
  50. }
  51. func (c changedStatistic) As(alias string) *changedStatistic {
  52. c.changedStatisticDo.DO = *(c.changedStatisticDo.As(alias).(*gen.DO))
  53. return c.updateTableName(alias)
  54. }
  55. func (c *changedStatistic) updateTableName(table string) *changedStatistic {
  56. c.ALL = field.NewAsterisk(table)
  57. c.ID = field.NewInt64(table, "id")
  58. c.ChannelID = field.NewString(table, "channel_id")
  59. c.ServerID = field.NewInt32(table, "server_id")
  60. c.Type = field.NewInt32(table, "type")
  61. c.Source = field.NewInt32(table, "source")
  62. c.Amount = field.NewInt64(table, "amount")
  63. c.Players = field.NewString(table, "players")
  64. c.Counts = field.NewInt64(table, "counts")
  65. c.Date = field.NewString(table, "date")
  66. c.fillFieldMap()
  67. return c
  68. }
  69. func (c *changedStatistic) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  70. _f, ok := c.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 (c *changedStatistic) fillFieldMap() {
  78. c.fieldMap = make(map[string]field.Expr, 9)
  79. c.fieldMap["id"] = c.ID
  80. c.fieldMap["channel_id"] = c.ChannelID
  81. c.fieldMap["server_id"] = c.ServerID
  82. c.fieldMap["type"] = c.Type
  83. c.fieldMap["source"] = c.Source
  84. c.fieldMap["amount"] = c.Amount
  85. c.fieldMap["players"] = c.Players
  86. c.fieldMap["counts"] = c.Counts
  87. c.fieldMap["date"] = c.Date
  88. }
  89. func (c changedStatistic) clone(db *gorm.DB) changedStatistic {
  90. c.changedStatisticDo.ReplaceConnPool(db.Statement.ConnPool)
  91. return c
  92. }
  93. func (c changedStatistic) replaceDB(db *gorm.DB) changedStatistic {
  94. c.changedStatisticDo.ReplaceDB(db)
  95. return c
  96. }
  97. type changedStatisticDo struct{ gen.DO }
  98. func (c changedStatisticDo) Debug() *changedStatisticDo {
  99. return c.withDO(c.DO.Debug())
  100. }
  101. func (c changedStatisticDo) WithContext(ctx context.Context) *changedStatisticDo {
  102. return c.withDO(c.DO.WithContext(ctx))
  103. }
  104. func (c changedStatisticDo) ReadDB() *changedStatisticDo {
  105. return c.Clauses(dbresolver.Read)
  106. }
  107. func (c changedStatisticDo) WriteDB() *changedStatisticDo {
  108. return c.Clauses(dbresolver.Write)
  109. }
  110. func (c changedStatisticDo) Session(config *gorm.Session) *changedStatisticDo {
  111. return c.withDO(c.DO.Session(config))
  112. }
  113. func (c changedStatisticDo) Clauses(conds ...clause.Expression) *changedStatisticDo {
  114. return c.withDO(c.DO.Clauses(conds...))
  115. }
  116. func (c changedStatisticDo) Returning(value interface{}, columns ...string) *changedStatisticDo {
  117. return c.withDO(c.DO.Returning(value, columns...))
  118. }
  119. func (c changedStatisticDo) Not(conds ...gen.Condition) *changedStatisticDo {
  120. return c.withDO(c.DO.Not(conds...))
  121. }
  122. func (c changedStatisticDo) Or(conds ...gen.Condition) *changedStatisticDo {
  123. return c.withDO(c.DO.Or(conds...))
  124. }
  125. func (c changedStatisticDo) Select(conds ...field.Expr) *changedStatisticDo {
  126. return c.withDO(c.DO.Select(conds...))
  127. }
  128. func (c changedStatisticDo) Where(conds ...gen.Condition) *changedStatisticDo {
  129. return c.withDO(c.DO.Where(conds...))
  130. }
  131. func (c changedStatisticDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *changedStatisticDo {
  132. return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  133. }
  134. func (c changedStatisticDo) Order(conds ...field.Expr) *changedStatisticDo {
  135. return c.withDO(c.DO.Order(conds...))
  136. }
  137. func (c changedStatisticDo) Distinct(cols ...field.Expr) *changedStatisticDo {
  138. return c.withDO(c.DO.Distinct(cols...))
  139. }
  140. func (c changedStatisticDo) Omit(cols ...field.Expr) *changedStatisticDo {
  141. return c.withDO(c.DO.Omit(cols...))
  142. }
  143. func (c changedStatisticDo) Join(table schema.Tabler, on ...field.Expr) *changedStatisticDo {
  144. return c.withDO(c.DO.Join(table, on...))
  145. }
  146. func (c changedStatisticDo) LeftJoin(table schema.Tabler, on ...field.Expr) *changedStatisticDo {
  147. return c.withDO(c.DO.LeftJoin(table, on...))
  148. }
  149. func (c changedStatisticDo) RightJoin(table schema.Tabler, on ...field.Expr) *changedStatisticDo {
  150. return c.withDO(c.DO.RightJoin(table, on...))
  151. }
  152. func (c changedStatisticDo) Group(cols ...field.Expr) *changedStatisticDo {
  153. return c.withDO(c.DO.Group(cols...))
  154. }
  155. func (c changedStatisticDo) Having(conds ...gen.Condition) *changedStatisticDo {
  156. return c.withDO(c.DO.Having(conds...))
  157. }
  158. func (c changedStatisticDo) Limit(limit int) *changedStatisticDo {
  159. return c.withDO(c.DO.Limit(limit))
  160. }
  161. func (c changedStatisticDo) Offset(offset int) *changedStatisticDo {
  162. return c.withDO(c.DO.Offset(offset))
  163. }
  164. func (c changedStatisticDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *changedStatisticDo {
  165. return c.withDO(c.DO.Scopes(funcs...))
  166. }
  167. func (c changedStatisticDo) Unscoped() *changedStatisticDo {
  168. return c.withDO(c.DO.Unscoped())
  169. }
  170. func (c changedStatisticDo) Create(values ...*model.ChangedStatistic) error {
  171. if len(values) == 0 {
  172. return nil
  173. }
  174. return c.DO.Create(values)
  175. }
  176. func (c changedStatisticDo) CreateInBatches(values []*model.ChangedStatistic, batchSize int) error {
  177. return c.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 (c changedStatisticDo) Save(values ...*model.ChangedStatistic) error {
  182. if len(values) == 0 {
  183. return nil
  184. }
  185. return c.DO.Save(values)
  186. }
  187. func (c changedStatisticDo) First() (*model.ChangedStatistic, error) {
  188. if result, err := c.DO.First(); err != nil {
  189. return nil, err
  190. } else {
  191. return result.(*model.ChangedStatistic), nil
  192. }
  193. }
  194. func (c changedStatisticDo) Take() (*model.ChangedStatistic, error) {
  195. if result, err := c.DO.Take(); err != nil {
  196. return nil, err
  197. } else {
  198. return result.(*model.ChangedStatistic), nil
  199. }
  200. }
  201. func (c changedStatisticDo) Last() (*model.ChangedStatistic, error) {
  202. if result, err := c.DO.Last(); err != nil {
  203. return nil, err
  204. } else {
  205. return result.(*model.ChangedStatistic), nil
  206. }
  207. }
  208. func (c changedStatisticDo) Find() ([]*model.ChangedStatistic, error) {
  209. result, err := c.DO.Find()
  210. return result.([]*model.ChangedStatistic), err
  211. }
  212. func (c changedStatisticDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChangedStatistic, err error) {
  213. buf := make([]*model.ChangedStatistic, 0, batchSize)
  214. err = c.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 (c changedStatisticDo) FindInBatches(result *[]*model.ChangedStatistic, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  221. return c.DO.FindInBatches(result, batchSize, fc)
  222. }
  223. func (c changedStatisticDo) Attrs(attrs ...field.AssignExpr) *changedStatisticDo {
  224. return c.withDO(c.DO.Attrs(attrs...))
  225. }
  226. func (c changedStatisticDo) Assign(attrs ...field.AssignExpr) *changedStatisticDo {
  227. return c.withDO(c.DO.Assign(attrs...))
  228. }
  229. func (c changedStatisticDo) Joins(fields ...field.RelationField) *changedStatisticDo {
  230. for _, _f := range fields {
  231. c = *c.withDO(c.DO.Joins(_f))
  232. }
  233. return &c
  234. }
  235. func (c changedStatisticDo) Preload(fields ...field.RelationField) *changedStatisticDo {
  236. for _, _f := range fields {
  237. c = *c.withDO(c.DO.Preload(_f))
  238. }
  239. return &c
  240. }
  241. func (c changedStatisticDo) FirstOrInit() (*model.ChangedStatistic, error) {
  242. if result, err := c.DO.FirstOrInit(); err != nil {
  243. return nil, err
  244. } else {
  245. return result.(*model.ChangedStatistic), nil
  246. }
  247. }
  248. func (c changedStatisticDo) FirstOrCreate() (*model.ChangedStatistic, error) {
  249. if result, err := c.DO.FirstOrCreate(); err != nil {
  250. return nil, err
  251. } else {
  252. return result.(*model.ChangedStatistic), nil
  253. }
  254. }
  255. func (c changedStatisticDo) FindByPage(offset int, limit int) (result []*model.ChangedStatistic, count int64, err error) {
  256. result, err = c.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 = c.Offset(-1).Limit(-1).Count()
  265. return
  266. }
  267. func (c changedStatisticDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  268. count, err = c.Count()
  269. if err != nil {
  270. return
  271. }
  272. err = c.Offset(offset).Limit(limit).Scan(result)
  273. return
  274. }
  275. func (c changedStatisticDo) Scan(result interface{}) (err error) {
  276. return c.DO.Scan(result)
  277. }
  278. func (c changedStatisticDo) Delete(models ...*model.ChangedStatistic) (result gen.ResultInfo, err error) {
  279. return c.DO.Delete(models)
  280. }
  281. func (c *changedStatisticDo) withDO(do gen.Dao) *changedStatisticDo {
  282. c.DO = *do.(*gen.DO)
  283. return c
  284. }