report_day_chapter_pass.gen.go 10 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 newReportDayChapterPass(db *gorm.DB, opts ...gen.DOOption) reportDayChapterPass {
  16. _reportDayChapterPass := reportDayChapterPass{}
  17. _reportDayChapterPass.reportDayChapterPassDo.UseDB(db, opts...)
  18. _reportDayChapterPass.reportDayChapterPassDo.UseModel(&model.ReportDayChapterPass{})
  19. tableName := _reportDayChapterPass.reportDayChapterPassDo.TableName()
  20. _reportDayChapterPass.ALL = field.NewAsterisk(tableName)
  21. _reportDayChapterPass.ID = field.NewInt64(tableName, "id")
  22. _reportDayChapterPass.Date = field.NewString(tableName, "date")
  23. _reportDayChapterPass.ChannelID = field.NewString(tableName, "channel_id")
  24. _reportDayChapterPass.ServerID = field.NewInt32(tableName, "server_id")
  25. _reportDayChapterPass.Data = field.NewString(tableName, "data")
  26. _reportDayChapterPass.RolesData = field.NewString(tableName, "roles_data")
  27. _reportDayChapterPass.Flag = field.NewInt32(tableName, "flag")
  28. _reportDayChapterPass.fillFieldMap()
  29. return _reportDayChapterPass
  30. }
  31. type reportDayChapterPass struct {
  32. reportDayChapterPassDo
  33. ALL field.Asterisk
  34. ID field.Int64
  35. Date field.String
  36. ChannelID field.String // 渠道ID
  37. ServerID field.Int32 // 服务器ID
  38. Data field.String // 每个章节的通关率 ,json表示
  39. RolesData field.String
  40. Flag field.Int32
  41. fieldMap map[string]field.Expr
  42. }
  43. func (r reportDayChapterPass) Table(newTableName string) *reportDayChapterPass {
  44. r.reportDayChapterPassDo.UseTable(newTableName)
  45. return r.updateTableName(newTableName)
  46. }
  47. func (r reportDayChapterPass) As(alias string) *reportDayChapterPass {
  48. r.reportDayChapterPassDo.DO = *(r.reportDayChapterPassDo.As(alias).(*gen.DO))
  49. return r.updateTableName(alias)
  50. }
  51. func (r *reportDayChapterPass) updateTableName(table string) *reportDayChapterPass {
  52. r.ALL = field.NewAsterisk(table)
  53. r.ID = field.NewInt64(table, "id")
  54. r.Date = field.NewString(table, "date")
  55. r.ChannelID = field.NewString(table, "channel_id")
  56. r.ServerID = field.NewInt32(table, "server_id")
  57. r.Data = field.NewString(table, "data")
  58. r.RolesData = field.NewString(table, "roles_data")
  59. r.Flag = field.NewInt32(table, "flag")
  60. r.fillFieldMap()
  61. return r
  62. }
  63. func (r *reportDayChapterPass) 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 *reportDayChapterPass) 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["channel_id"] = r.ChannelID
  76. r.fieldMap["server_id"] = r.ServerID
  77. r.fieldMap["data"] = r.Data
  78. r.fieldMap["roles_data"] = r.RolesData
  79. r.fieldMap["flag"] = r.Flag
  80. }
  81. func (r reportDayChapterPass) clone(db *gorm.DB) reportDayChapterPass {
  82. r.reportDayChapterPassDo.ReplaceConnPool(db.Statement.ConnPool)
  83. return r
  84. }
  85. func (r reportDayChapterPass) replaceDB(db *gorm.DB) reportDayChapterPass {
  86. r.reportDayChapterPassDo.ReplaceDB(db)
  87. return r
  88. }
  89. type reportDayChapterPassDo struct{ gen.DO }
  90. func (r reportDayChapterPassDo) Debug() *reportDayChapterPassDo {
  91. return r.withDO(r.DO.Debug())
  92. }
  93. func (r reportDayChapterPassDo) WithContext(ctx context.Context) *reportDayChapterPassDo {
  94. return r.withDO(r.DO.WithContext(ctx))
  95. }
  96. func (r reportDayChapterPassDo) ReadDB() *reportDayChapterPassDo {
  97. return r.Clauses(dbresolver.Read)
  98. }
  99. func (r reportDayChapterPassDo) WriteDB() *reportDayChapterPassDo {
  100. return r.Clauses(dbresolver.Write)
  101. }
  102. func (r reportDayChapterPassDo) Session(config *gorm.Session) *reportDayChapterPassDo {
  103. return r.withDO(r.DO.Session(config))
  104. }
  105. func (r reportDayChapterPassDo) Clauses(conds ...clause.Expression) *reportDayChapterPassDo {
  106. return r.withDO(r.DO.Clauses(conds...))
  107. }
  108. func (r reportDayChapterPassDo) Returning(value interface{}, columns ...string) *reportDayChapterPassDo {
  109. return r.withDO(r.DO.Returning(value, columns...))
  110. }
  111. func (r reportDayChapterPassDo) Not(conds ...gen.Condition) *reportDayChapterPassDo {
  112. return r.withDO(r.DO.Not(conds...))
  113. }
  114. func (r reportDayChapterPassDo) Or(conds ...gen.Condition) *reportDayChapterPassDo {
  115. return r.withDO(r.DO.Or(conds...))
  116. }
  117. func (r reportDayChapterPassDo) Select(conds ...field.Expr) *reportDayChapterPassDo {
  118. return r.withDO(r.DO.Select(conds...))
  119. }
  120. func (r reportDayChapterPassDo) Where(conds ...gen.Condition) *reportDayChapterPassDo {
  121. return r.withDO(r.DO.Where(conds...))
  122. }
  123. func (r reportDayChapterPassDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *reportDayChapterPassDo {
  124. return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  125. }
  126. func (r reportDayChapterPassDo) Order(conds ...field.Expr) *reportDayChapterPassDo {
  127. return r.withDO(r.DO.Order(conds...))
  128. }
  129. func (r reportDayChapterPassDo) Distinct(cols ...field.Expr) *reportDayChapterPassDo {
  130. return r.withDO(r.DO.Distinct(cols...))
  131. }
  132. func (r reportDayChapterPassDo) Omit(cols ...field.Expr) *reportDayChapterPassDo {
  133. return r.withDO(r.DO.Omit(cols...))
  134. }
  135. func (r reportDayChapterPassDo) Join(table schema.Tabler, on ...field.Expr) *reportDayChapterPassDo {
  136. return r.withDO(r.DO.Join(table, on...))
  137. }
  138. func (r reportDayChapterPassDo) LeftJoin(table schema.Tabler, on ...field.Expr) *reportDayChapterPassDo {
  139. return r.withDO(r.DO.LeftJoin(table, on...))
  140. }
  141. func (r reportDayChapterPassDo) RightJoin(table schema.Tabler, on ...field.Expr) *reportDayChapterPassDo {
  142. return r.withDO(r.DO.RightJoin(table, on...))
  143. }
  144. func (r reportDayChapterPassDo) Group(cols ...field.Expr) *reportDayChapterPassDo {
  145. return r.withDO(r.DO.Group(cols...))
  146. }
  147. func (r reportDayChapterPassDo) Having(conds ...gen.Condition) *reportDayChapterPassDo {
  148. return r.withDO(r.DO.Having(conds...))
  149. }
  150. func (r reportDayChapterPassDo) Limit(limit int) *reportDayChapterPassDo {
  151. return r.withDO(r.DO.Limit(limit))
  152. }
  153. func (r reportDayChapterPassDo) Offset(offset int) *reportDayChapterPassDo {
  154. return r.withDO(r.DO.Offset(offset))
  155. }
  156. func (r reportDayChapterPassDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *reportDayChapterPassDo {
  157. return r.withDO(r.DO.Scopes(funcs...))
  158. }
  159. func (r reportDayChapterPassDo) Unscoped() *reportDayChapterPassDo {
  160. return r.withDO(r.DO.Unscoped())
  161. }
  162. func (r reportDayChapterPassDo) Create(values ...*model.ReportDayChapterPass) error {
  163. if len(values) == 0 {
  164. return nil
  165. }
  166. return r.DO.Create(values)
  167. }
  168. func (r reportDayChapterPassDo) CreateInBatches(values []*model.ReportDayChapterPass, 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 reportDayChapterPassDo) Save(values ...*model.ReportDayChapterPass) error {
  174. if len(values) == 0 {
  175. return nil
  176. }
  177. return r.DO.Save(values)
  178. }
  179. func (r reportDayChapterPassDo) First() (*model.ReportDayChapterPass, error) {
  180. if result, err := r.DO.First(); err != nil {
  181. return nil, err
  182. } else {
  183. return result.(*model.ReportDayChapterPass), nil
  184. }
  185. }
  186. func (r reportDayChapterPassDo) Take() (*model.ReportDayChapterPass, error) {
  187. if result, err := r.DO.Take(); err != nil {
  188. return nil, err
  189. } else {
  190. return result.(*model.ReportDayChapterPass), nil
  191. }
  192. }
  193. func (r reportDayChapterPassDo) Last() (*model.ReportDayChapterPass, error) {
  194. if result, err := r.DO.Last(); err != nil {
  195. return nil, err
  196. } else {
  197. return result.(*model.ReportDayChapterPass), nil
  198. }
  199. }
  200. func (r reportDayChapterPassDo) Find() ([]*model.ReportDayChapterPass, error) {
  201. result, err := r.DO.Find()
  202. return result.([]*model.ReportDayChapterPass), err
  203. }
  204. func (r reportDayChapterPassDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ReportDayChapterPass, err error) {
  205. buf := make([]*model.ReportDayChapterPass, 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 reportDayChapterPassDo) FindInBatches(result *[]*model.ReportDayChapterPass, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  213. return r.DO.FindInBatches(result, batchSize, fc)
  214. }
  215. func (r reportDayChapterPassDo) Attrs(attrs ...field.AssignExpr) *reportDayChapterPassDo {
  216. return r.withDO(r.DO.Attrs(attrs...))
  217. }
  218. func (r reportDayChapterPassDo) Assign(attrs ...field.AssignExpr) *reportDayChapterPassDo {
  219. return r.withDO(r.DO.Assign(attrs...))
  220. }
  221. func (r reportDayChapterPassDo) Joins(fields ...field.RelationField) *reportDayChapterPassDo {
  222. for _, _f := range fields {
  223. r = *r.withDO(r.DO.Joins(_f))
  224. }
  225. return &r
  226. }
  227. func (r reportDayChapterPassDo) Preload(fields ...field.RelationField) *reportDayChapterPassDo {
  228. for _, _f := range fields {
  229. r = *r.withDO(r.DO.Preload(_f))
  230. }
  231. return &r
  232. }
  233. func (r reportDayChapterPassDo) FirstOrInit() (*model.ReportDayChapterPass, error) {
  234. if result, err := r.DO.FirstOrInit(); err != nil {
  235. return nil, err
  236. } else {
  237. return result.(*model.ReportDayChapterPass), nil
  238. }
  239. }
  240. func (r reportDayChapterPassDo) FirstOrCreate() (*model.ReportDayChapterPass, error) {
  241. if result, err := r.DO.FirstOrCreate(); err != nil {
  242. return nil, err
  243. } else {
  244. return result.(*model.ReportDayChapterPass), nil
  245. }
  246. }
  247. func (r reportDayChapterPassDo) FindByPage(offset int, limit int) (result []*model.ReportDayChapterPass, 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 reportDayChapterPassDo) 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 reportDayChapterPassDo) Scan(result interface{}) (err error) {
  268. return r.DO.Scan(result)
  269. }
  270. func (r reportDayChapterPassDo) Delete(models ...*model.ReportDayChapterPass) (result gen.ResultInfo, err error) {
  271. return r.DO.Delete(models)
  272. }
  273. func (r *reportDayChapterPassDo) withDO(do gen.Dao) *reportDayChapterPassDo {
  274. r.DO = *do.(*gen.DO)
  275. return r
  276. }