grandmaster_match.gen.go 9.3 KB

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