curiomake.gen.go 10 KB

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