user_poster.go 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package model
  2. import (
  3. "context"
  4. "icloudapp.cn/tools/entity"
  5. "icloudapp.cn/tools/service"
  6. )
  7. type UserPoster struct {
  8. ctx context.Context
  9. }
  10. func NewUserPoster(ctx context.Context) *UserPoster {
  11. return &UserPoster{ctx: ctx}
  12. }
  13. func (p *UserPoster) Info(posterID int64) (entity.UserPosterInfo, error) {
  14. sPoster := service.NewUserPoster(p.ctx)
  15. return sPoster.InfoByID(posterID)
  16. }
  17. func (p *UserPoster) InfoByUUID(uuid int64) (entity.UserPosterInfo, error) {
  18. sPoster := service.NewUserPoster(p.ctx)
  19. return sPoster.InfoByUUID(uuid)
  20. }
  21. func (p *UserPoster) SimpleLists(uid int64) []entity.PostersListForApi {
  22. sPoster := service.NewUserPoster(p.ctx)
  23. lists := sPoster.SimpleLists(uid)
  24. res := make([]entity.PostersListForApi, 0)
  25. for _, v := range lists {
  26. var poster entity.PostersListForApi
  27. poster.Id = v.PosterID
  28. poster.Name = v.PosterName
  29. poster.Preview = *v.Preview
  30. poster.Visits = v.Visits
  31. poster.Status = v.Status
  32. poster.CreateAt = v.CreateAt
  33. res = append(res, poster)
  34. }
  35. return res
  36. }