main.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "log"
  6. "time"
  7. "fmt"
  8. "go-common/app/service/live/xrewardcenter/api/grpc/v1"
  9. "go-common/library/net/rpc/warden"
  10. xtime "go-common/library/time"
  11. )
  12. var name, addr string
  13. func init() {
  14. flag.StringVar(&name, "name", "lily", "name")
  15. flag.StringVar(&addr, "addr", "127.0.0.1:9004", "server addr")
  16. }
  17. func main() {
  18. flag.Parse()
  19. cfg := &warden.ClientConfig{
  20. Dial: xtime.Duration(time.Second * 3),
  21. Timeout: xtime.Duration(time.Second * 3),
  22. }
  23. cc, err := warden.NewClient(cfg).Dial(context.Background(), addr)
  24. if err != nil {
  25. log.Fatalf("new client failed!err:=%v", err)
  26. return
  27. }
  28. client := v1.NewAnchorRewardClient(cc)
  29. resp, err := client.MyReward(context.Background(), &v1.AnchorTaskMyRewardReq{
  30. Page: 1,
  31. Uid: 10000,
  32. })
  33. fmt.Printf("****** myReward:******* \n %+v \n %v \n", resp, err)
  34. resp2, err := client.AddReward(context.Background(), &v1.AnchorTaskAddRewardReq{
  35. RewardId: 1,
  36. Roomid: 555,
  37. Source: 1,
  38. Uid: 10000,
  39. OrderId: "test123",
  40. Lifespan: 1,
  41. })
  42. fmt.Printf("***** addReward:********\n%+v \n %v \n", resp2, err)
  43. //resp3, err := client.IsViewed(context.Background(), &v1.AnchorTaskIsViewedReq{
  44. // Uid: 10000,
  45. //})
  46. //fmt.Printf("got IsViewed:%+v", resp3)
  47. //resp4, _ := client.UseRecord(context.Background(), &v1.AnchorTaskUseRecordReq{
  48. // Page: 1,
  49. // Uid: 10000,
  50. //})
  51. //fmt.Printf("got UseRecord:%+v", resp4)
  52. //
  53. //resp5, err := client.UseReward(context.Background(), &v1.AnchorTaskUseRewardReq{
  54. // Id: 1,
  55. // Uid: 10000,
  56. // UsePlat: "ios",
  57. //})
  58. //fmt.Printf("got UseReward:%+v", resp5)
  59. }