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