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