world.gen.go 11 KB

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