api.bm.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
  2. // source: api/grpc/v1/api.proto
  3. /*
  4. Package v1 is a generated blademaster stub package.
  5. This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
  6. It is generated from these files:
  7. api/grpc/v1/api.proto
  8. */
  9. package v1
  10. import (
  11. "context"
  12. bm "go-common/library/net/http/blademaster"
  13. "go-common/library/net/http/blademaster/binding"
  14. )
  15. // to suppressed 'imported but not used warning'
  16. var _ *bm.Context
  17. var _ context.Context
  18. var _ binding.StructValidator
  19. // ===================
  20. // Recommend Interface
  21. // ===================
  22. type Recommend interface {
  23. // 获取n个推荐, 得到的结果是在线的房间
  24. // 去重,不会重复推荐
  25. // 如果没有足够推荐的结果则返回空的结果,调用方需要补位
  26. RandomRecsByUser(ctx context.Context, req *GetRandomRecReq) (resp *GetRandomRecResp, err error)
  27. // 清空推荐缓存,清空推荐过的集合
  28. ClearRecommendCache(ctx context.Context, req *ClearRecommendRequest) (resp *ClearRecommendResponse, err error)
  29. }
  30. var v1RecommendSvc Recommend
  31. // @params GetRandomRecReq
  32. // @router GET /xlive/recommend/v1/recommend/random_recs_by_user
  33. // @response GetRandomRecResp
  34. func recommendRandomRecsByUser(c *bm.Context) {
  35. p := new(GetRandomRecReq)
  36. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  37. return
  38. }
  39. resp, err := v1RecommendSvc.RandomRecsByUser(c, p)
  40. c.JSON(resp, err)
  41. }
  42. // @params ClearRecommendRequest
  43. // @router GET /xlive/recommend/v1/recommend/clear_recommend_cache
  44. // @response ClearRecommendResponse
  45. func recommendClearRecommendCache(c *bm.Context) {
  46. p := new(ClearRecommendRequest)
  47. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  48. return
  49. }
  50. resp, err := v1RecommendSvc.ClearRecommendCache(c, p)
  51. c.JSON(resp, err)
  52. }
  53. // RegisterV1RecommendService Register the blademaster route with middleware map
  54. // midMap is the middleware map, the key is defined in proto
  55. func RegisterV1RecommendService(e *bm.Engine, svc Recommend, midMap map[string]bm.HandlerFunc) {
  56. v1RecommendSvc = svc
  57. e.GET("/xlive/recommend/v1/recommend/random_recs_by_user", recommendRandomRecsByUser)
  58. e.GET("/xlive/recommend/v1/recommend/clear_recommend_cache", recommendClearRecommendCache)
  59. }