user_poster.go 13 KB

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