banner.go 870 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package v1
  2. import (
  3. resAPI "go-common/app/interface/live/app-room/api/http/v1"
  4. "go-common/app/interface/live/app-room/conf"
  5. rspb "go-common/app/service/live/resource/api/grpc/v1"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. var _rsCli *rspb.Client
  9. // Init -
  10. func Init(c *conf.Config) {
  11. var err error
  12. if _rsCli, err = rspb.NewClient(c.ResourceClient); err != nil {
  13. panic(err)
  14. }
  15. }
  16. // GetBanner -
  17. func GetBanner(context *bm.Context) {
  18. p := new(rspb.GetBannerReq)
  19. if err := context.Bind(p); err != nil {
  20. return
  21. }
  22. respRPC, err := _rsCli.GetBanner(context, p)
  23. if err != nil {
  24. return
  25. }
  26. resp := make([]resAPI.GetBannerResp, len(respRPC.List))
  27. for index, banner := range respRPC.List {
  28. resp[index].Id = banner.Id
  29. resp[index].Title = banner.Title
  30. resp[index].Img = banner.ImageUrl
  31. resp[index].Link = banner.JumpPath
  32. }
  33. context.JSON(resp, err)
  34. }