world.gen.go 11 KB

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