report_level_output.gen.go 9.8 KB

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