user_poster_batches.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 model
  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. "icloudapp.cn/tools/service/entity"
  14. )
  15. func newUserPosterBatch(db *gorm.DB, opts ...gen.DOOption) MUserPosterBatch {
  16. _MUserPosterBatch := MUserPosterBatch{}
  17. _MUserPosterBatch.MUserPosterBatchDo.UseDB(db, opts...)
  18. _MUserPosterBatch.MUserPosterBatchDo.UseModel(&entity.UserPosterBatch{})
  19. tableName := _MUserPosterBatch.MUserPosterBatchDo.TableName()
  20. _MUserPosterBatch.ALL = field.NewAsterisk(tableName)
  21. _MUserPosterBatch.BatchID = field.NewInt64(tableName, "batch_id")
  22. _MUserPosterBatch.UID = field.NewInt64(tableName, "uid")
  23. _MUserPosterBatch.PosterID = field.NewInt64(tableName, "poster_id")
  24. _MUserPosterBatch.Name = field.NewString(tableName, "name")
  25. _MUserPosterBatch.UUID = field.NewString(tableName, "uuid")
  26. _MUserPosterBatch.Raw = field.NewString(tableName, "raw")
  27. _MUserPosterBatch.Num = field.NewInt64(tableName, "num")
  28. _MUserPosterBatch.DoneNum = field.NewInt64(tableName, "done_num")
  29. _MUserPosterBatch.Type = field.NewString(tableName, "type")
  30. _MUserPosterBatch.Path = field.NewString(tableName, "path")
  31. _MUserPosterBatch.Status = field.NewInt64(tableName, "status")
  32. _MUserPosterBatch.CreateAt = field.NewTime(tableName, "create_at")
  33. _MUserPosterBatch.UpdateAt = field.NewTime(tableName, "update_at")
  34. _MUserPosterBatch.fillFieldMap()
  35. return _MUserPosterBatch
  36. }
  37. type MUserPosterBatch struct {
  38. MUserPosterBatchDo MUserPosterBatchDo
  39. ALL field.Asterisk
  40. BatchID field.Int64
  41. UID field.Int64 // 用户ID
  42. PosterID field.Int64 // 海报ID
  43. Name field.String // 海报名称
  44. UUID field.String // 海报唯一标识
  45. Raw field.String // 生成的内容
  46. Num field.Int64 // 海报份数
  47. DoneNum field.Int64 // 已经生成的份数
  48. Type field.String // 生成图片类型
  49. Path field.String // 海报存储路径
  50. Status field.Int64 // 海报生成状态
  51. CreateAt field.Time // 创建时间
  52. UpdateAt field.Time // 更新时间
  53. fieldMap map[string]field.Expr
  54. }
  55. func (u MUserPosterBatch) Table(newTableName string) *MUserPosterBatch {
  56. u.MUserPosterBatchDo.UseTable(newTableName)
  57. return u.updateTableName(newTableName)
  58. }
  59. func (u MUserPosterBatch) As(alias string) *MUserPosterBatch {
  60. u.MUserPosterBatchDo.DO = *(u.MUserPosterBatchDo.As(alias).(*gen.DO))
  61. return u.updateTableName(alias)
  62. }
  63. func (u *MUserPosterBatch) updateTableName(table string) *MUserPosterBatch {
  64. u.ALL = field.NewAsterisk(table)
  65. u.BatchID = field.NewInt64(table, "batch_id")
  66. u.UID = field.NewInt64(table, "uid")
  67. u.PosterID = field.NewInt64(table, "poster_id")
  68. u.Name = field.NewString(table, "name")
  69. u.UUID = field.NewString(table, "uuid")
  70. u.Raw = field.NewString(table, "raw")
  71. u.Num = field.NewInt64(table, "num")
  72. u.DoneNum = field.NewInt64(table, "done_num")
  73. u.Type = field.NewString(table, "type")
  74. u.Path = field.NewString(table, "path")
  75. u.Status = field.NewInt64(table, "status")
  76. u.CreateAt = field.NewTime(table, "create_at")
  77. u.UpdateAt = field.NewTime(table, "update_at")
  78. u.fillFieldMap()
  79. return u
  80. }
  81. func (u *MUserPosterBatch) WithContext(ctx context.Context) IUserPosterBatchDo {
  82. return u.MUserPosterBatchDo.WithContext(ctx)
  83. }
  84. func (u MUserPosterBatch) TableName() string { return u.MUserPosterBatchDo.TableName() }
  85. func (u MUserPosterBatch) Alias() string { return u.MUserPosterBatchDo.Alias() }
  86. func (u *MUserPosterBatch) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  87. _f, ok := u.fieldMap[fieldName]
  88. if !ok || _f == nil {
  89. return nil, false
  90. }
  91. _oe, ok := _f.(field.OrderExpr)
  92. return _oe, ok
  93. }
  94. func (u *MUserPosterBatch) fillFieldMap() {
  95. u.fieldMap = make(map[string]field.Expr, 13)
  96. u.fieldMap["batch_id"] = u.BatchID
  97. u.fieldMap["uid"] = u.UID
  98. u.fieldMap["poster_id"] = u.PosterID
  99. u.fieldMap["name"] = u.Name
  100. u.fieldMap["uuid"] = u.UUID
  101. u.fieldMap["raw"] = u.Raw
  102. u.fieldMap["num"] = u.Num
  103. u.fieldMap["done_num"] = u.DoneNum
  104. u.fieldMap["type"] = u.Type
  105. u.fieldMap["path"] = u.Path
  106. u.fieldMap["status"] = u.Status
  107. u.fieldMap["create_at"] = u.CreateAt
  108. u.fieldMap["update_at"] = u.UpdateAt
  109. }
  110. func (u MUserPosterBatch) clone(db *gorm.DB) MUserPosterBatch {
  111. u.MUserPosterBatchDo.ReplaceConnPool(db.Statement.ConnPool)
  112. return u
  113. }
  114. func (u MUserPosterBatch) replaceDB(db *gorm.DB) MUserPosterBatch {
  115. u.MUserPosterBatchDo.ReplaceDB(db)
  116. return u
  117. }
  118. type MUserPosterBatchDo struct{ gen.DO }
  119. type IUserPosterBatchDo interface {
  120. gen.SubQuery
  121. Debug() IUserPosterBatchDo
  122. WithContext(ctx context.Context) IUserPosterBatchDo
  123. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  124. ReplaceDB(db *gorm.DB)
  125. ReadDB() IUserPosterBatchDo
  126. WriteDB() IUserPosterBatchDo
  127. As(alias string) gen.Dao
  128. Session(config *gorm.Session) IUserPosterBatchDo
  129. Columns(cols ...field.Expr) gen.Columns
  130. Clauses(conds ...clause.Expression) IUserPosterBatchDo
  131. Not(conds ...gen.Condition) IUserPosterBatchDo
  132. Or(conds ...gen.Condition) IUserPosterBatchDo
  133. Select(conds ...field.Expr) IUserPosterBatchDo
  134. Where(conds ...gen.Condition) IUserPosterBatchDo
  135. Order(conds ...field.Expr) IUserPosterBatchDo
  136. Distinct(cols ...field.Expr) IUserPosterBatchDo
  137. Omit(cols ...field.Expr) IUserPosterBatchDo
  138. Join(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo
  139. LeftJoin(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo
  140. RightJoin(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo
  141. Group(cols ...field.Expr) IUserPosterBatchDo
  142. Having(conds ...gen.Condition) IUserPosterBatchDo
  143. Limit(limit int) IUserPosterBatchDo
  144. Offset(offset int) IUserPosterBatchDo
  145. Count() (count int64, err error)
  146. Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPosterBatchDo
  147. Unscoped() IUserPosterBatchDo
  148. Create(values ...*entity.UserPosterBatch) error
  149. CreateInBatches(values []*entity.UserPosterBatch, batchSize int) error
  150. Save(values ...*entity.UserPosterBatch) error
  151. First() (*entity.UserPosterBatch, error)
  152. Take() (*entity.UserPosterBatch, error)
  153. Last() (*entity.UserPosterBatch, error)
  154. Find() ([]*entity.UserPosterBatch, error)
  155. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.UserPosterBatch, err error)
  156. FindInBatches(result *[]*entity.UserPosterBatch, batchSize int, fc func(tx gen.Dao, batch int) error) error
  157. Pluck(column field.Expr, dest interface{}) error
  158. Delete(...*entity.UserPosterBatch) (info gen.ResultInfo, err error)
  159. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  160. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  161. Updates(value interface{}) (info gen.ResultInfo, err error)
  162. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  163. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  164. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  165. UpdateFrom(q gen.SubQuery) gen.Dao
  166. Attrs(attrs ...field.AssignExpr) IUserPosterBatchDo
  167. Assign(attrs ...field.AssignExpr) IUserPosterBatchDo
  168. Joins(fields ...field.RelationField) IUserPosterBatchDo
  169. Preload(fields ...field.RelationField) IUserPosterBatchDo
  170. FirstOrInit() (*entity.UserPosterBatch, error)
  171. FirstOrCreate() (*entity.UserPosterBatch, error)
  172. FindByPage(offset int, limit int) (result []*entity.UserPosterBatch, count int64, err error)
  173. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  174. Scan(result interface{}) (err error)
  175. Returning(value interface{}, columns ...string) IUserPosterBatchDo
  176. UnderlyingDB() *gorm.DB
  177. schema.Tabler
  178. }
  179. func (u MUserPosterBatchDo) Debug() IUserPosterBatchDo {
  180. return u.withDO(u.DO.Debug())
  181. }
  182. func (u MUserPosterBatchDo) WithContext(ctx context.Context) IUserPosterBatchDo {
  183. return u.withDO(u.DO.WithContext(ctx))
  184. }
  185. func (u MUserPosterBatchDo) ReadDB() IUserPosterBatchDo {
  186. return u.Clauses(dbresolver.Read)
  187. }
  188. func (u MUserPosterBatchDo) WriteDB() IUserPosterBatchDo {
  189. return u.Clauses(dbresolver.Write)
  190. }
  191. func (u MUserPosterBatchDo) Session(config *gorm.Session) IUserPosterBatchDo {
  192. return u.withDO(u.DO.Session(config))
  193. }
  194. func (u MUserPosterBatchDo) Clauses(conds ...clause.Expression) IUserPosterBatchDo {
  195. return u.withDO(u.DO.Clauses(conds...))
  196. }
  197. func (u MUserPosterBatchDo) Returning(value interface{}, columns ...string) IUserPosterBatchDo {
  198. return u.withDO(u.DO.Returning(value, columns...))
  199. }
  200. func (u MUserPosterBatchDo) Not(conds ...gen.Condition) IUserPosterBatchDo {
  201. return u.withDO(u.DO.Not(conds...))
  202. }
  203. func (u MUserPosterBatchDo) Or(conds ...gen.Condition) IUserPosterBatchDo {
  204. return u.withDO(u.DO.Or(conds...))
  205. }
  206. func (u MUserPosterBatchDo) Select(conds ...field.Expr) IUserPosterBatchDo {
  207. return u.withDO(u.DO.Select(conds...))
  208. }
  209. func (u MUserPosterBatchDo) Where(conds ...gen.Condition) IUserPosterBatchDo {
  210. return u.withDO(u.DO.Where(conds...))
  211. }
  212. func (u MUserPosterBatchDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IUserPosterBatchDo {
  213. return u.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  214. }
  215. func (u MUserPosterBatchDo) Order(conds ...field.Expr) IUserPosterBatchDo {
  216. return u.withDO(u.DO.Order(conds...))
  217. }
  218. func (u MUserPosterBatchDo) Distinct(cols ...field.Expr) IUserPosterBatchDo {
  219. return u.withDO(u.DO.Distinct(cols...))
  220. }
  221. func (u MUserPosterBatchDo) Omit(cols ...field.Expr) IUserPosterBatchDo {
  222. return u.withDO(u.DO.Omit(cols...))
  223. }
  224. func (u MUserPosterBatchDo) Join(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo {
  225. return u.withDO(u.DO.Join(table, on...))
  226. }
  227. func (u MUserPosterBatchDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo {
  228. return u.withDO(u.DO.LeftJoin(table, on...))
  229. }
  230. func (u MUserPosterBatchDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserPosterBatchDo {
  231. return u.withDO(u.DO.RightJoin(table, on...))
  232. }
  233. func (u MUserPosterBatchDo) Group(cols ...field.Expr) IUserPosterBatchDo {
  234. return u.withDO(u.DO.Group(cols...))
  235. }
  236. func (u MUserPosterBatchDo) Having(conds ...gen.Condition) IUserPosterBatchDo {
  237. return u.withDO(u.DO.Having(conds...))
  238. }
  239. func (u MUserPosterBatchDo) Limit(limit int) IUserPosterBatchDo {
  240. return u.withDO(u.DO.Limit(limit))
  241. }
  242. func (u MUserPosterBatchDo) Offset(offset int) IUserPosterBatchDo {
  243. return u.withDO(u.DO.Offset(offset))
  244. }
  245. func (u MUserPosterBatchDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPosterBatchDo {
  246. return u.withDO(u.DO.Scopes(funcs...))
  247. }
  248. func (u MUserPosterBatchDo) Unscoped() IUserPosterBatchDo {
  249. return u.withDO(u.DO.Unscoped())
  250. }
  251. func (u MUserPosterBatchDo) Create(values ...*entity.UserPosterBatch) error {
  252. if len(values) == 0 {
  253. return nil
  254. }
  255. return u.DO.Create(values)
  256. }
  257. func (u MUserPosterBatchDo) CreateInBatches(values []*entity.UserPosterBatch, batchSize int) error {
  258. return u.DO.CreateInBatches(values, batchSize)
  259. }
  260. // Save : !!! underlying implementation is different with GORM
  261. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  262. func (u MUserPosterBatchDo) Save(values ...*entity.UserPosterBatch) error {
  263. if len(values) == 0 {
  264. return nil
  265. }
  266. return u.DO.Save(values)
  267. }
  268. func (u MUserPosterBatchDo) First() (*entity.UserPosterBatch, error) {
  269. if result, err := u.DO.First(); err != nil {
  270. return nil, err
  271. } else {
  272. return result.(*entity.UserPosterBatch), nil
  273. }
  274. }
  275. func (u MUserPosterBatchDo) Take() (*entity.UserPosterBatch, error) {
  276. if result, err := u.DO.Take(); err != nil {
  277. return nil, err
  278. } else {
  279. return result.(*entity.UserPosterBatch), nil
  280. }
  281. }
  282. func (u MUserPosterBatchDo) Last() (*entity.UserPosterBatch, error) {
  283. if result, err := u.DO.Last(); err != nil {
  284. return nil, err
  285. } else {
  286. return result.(*entity.UserPosterBatch), nil
  287. }
  288. }
  289. func (u MUserPosterBatchDo) Find() ([]*entity.UserPosterBatch, error) {
  290. result, err := u.DO.Find()
  291. return result.([]*entity.UserPosterBatch), err
  292. }
  293. func (u MUserPosterBatchDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.UserPosterBatch, err error) {
  294. buf := make([]*entity.UserPosterBatch, 0, batchSize)
  295. err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  296. defer func() { results = append(results, buf...) }()
  297. return fc(tx, batch)
  298. })
  299. return results, err
  300. }
  301. func (u MUserPosterBatchDo) FindInBatches(result *[]*entity.UserPosterBatch, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  302. return u.DO.FindInBatches(result, batchSize, fc)
  303. }
  304. func (u MUserPosterBatchDo) Attrs(attrs ...field.AssignExpr) IUserPosterBatchDo {
  305. return u.withDO(u.DO.Attrs(attrs...))
  306. }
  307. func (u MUserPosterBatchDo) Assign(attrs ...field.AssignExpr) IUserPosterBatchDo {
  308. return u.withDO(u.DO.Assign(attrs...))
  309. }
  310. func (u MUserPosterBatchDo) Joins(fields ...field.RelationField) IUserPosterBatchDo {
  311. for _, _f := range fields {
  312. u = *u.withDO(u.DO.Joins(_f))
  313. }
  314. return &u
  315. }
  316. func (u MUserPosterBatchDo) Preload(fields ...field.RelationField) IUserPosterBatchDo {
  317. for _, _f := range fields {
  318. u = *u.withDO(u.DO.Preload(_f))
  319. }
  320. return &u
  321. }
  322. func (u MUserPosterBatchDo) FirstOrInit() (*entity.UserPosterBatch, error) {
  323. if result, err := u.DO.FirstOrInit(); err != nil {
  324. return nil, err
  325. } else {
  326. return result.(*entity.UserPosterBatch), nil
  327. }
  328. }
  329. func (u MUserPosterBatchDo) FirstOrCreate() (*entity.UserPosterBatch, error) {
  330. if result, err := u.DO.FirstOrCreate(); err != nil {
  331. return nil, err
  332. } else {
  333. return result.(*entity.UserPosterBatch), nil
  334. }
  335. }
  336. func (u MUserPosterBatchDo) FindByPage(offset int, limit int) (result []*entity.UserPosterBatch, count int64, err error) {
  337. result, err = u.Offset(offset).Limit(limit).Find()
  338. if err != nil {
  339. return
  340. }
  341. if size := len(result); 0 < limit && 0 < size && size < limit {
  342. count = int64(size + offset)
  343. return
  344. }
  345. count, err = u.Offset(-1).Limit(-1).Count()
  346. return
  347. }
  348. func (u MUserPosterBatchDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  349. count, err = u.Count()
  350. if err != nil {
  351. return
  352. }
  353. err = u.Offset(offset).Limit(limit).Scan(result)
  354. return
  355. }
  356. func (u MUserPosterBatchDo) Scan(result interface{}) (err error) {
  357. return u.DO.Scan(result)
  358. }
  359. func (u MUserPosterBatchDo) Delete(models ...*entity.UserPosterBatch) (result gen.ResultInfo, err error) {
  360. return u.DO.Delete(models)
  361. }
  362. func (u *MUserPosterBatchDo) withDO(do gen.Dao) *MUserPosterBatchDo {
  363. u.DO = *do.(*gen.DO)
  364. return u
  365. }