dao.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package capsule
  2. import (
  3. "context"
  4. "go-common/app/interface/live/web-ucenter/conf"
  5. lotteryApi "go-common/app/service/live/xlottery/api/grpc/v1"
  6. )
  7. // Dao dao
  8. type Dao struct {
  9. client *lotteryApi.Client
  10. }
  11. // New init
  12. func New(c *conf.Config) (dao *Dao) {
  13. dao = &Dao{}
  14. client, err := lotteryApi.NewClient(conf.Conf.Warden)
  15. if err != nil {
  16. panic(err)
  17. }
  18. dao.client = client
  19. return
  20. }
  21. // GetDetail grpc
  22. func (d *Dao) GetDetail(ctx context.Context, uid int64, from string) (*lotteryApi.CapsuleGetDetailResp, error) {
  23. return d.client.CapsuleClient.GetDetail(ctx, &lotteryApi.CapsuleGetDetailReq{Uid: uid, From: from})
  24. }
  25. // OpenCapsule grpc
  26. func (d *Dao) OpenCapsule(ctx context.Context, uid int64, otype string, count int64, platform string) (*lotteryApi.CapsuleOpenCapsuleResp, error) {
  27. return d.client.CapsuleClient.OpenCapsule(ctx, &lotteryApi.CapsuleOpenCapsuleReq{Uid: uid, Type: otype, Count: count, Platform: platform})
  28. }
  29. // GetCapsuleInfo grpc
  30. func (d *Dao) GetCapsuleInfo(ctx context.Context, uid int64, otype, from string) (*lotteryApi.CapsuleGetCapsuleInfoResp, error) {
  31. return d.client.CapsuleClient.GetCapsuleInfo(ctx, &lotteryApi.CapsuleGetCapsuleInfoReq{Uid: uid, Type: otype, From: from})
  32. }
  33. // OpenCapsuleByType grpc
  34. func (d *Dao) OpenCapsuleByType(ctx context.Context, uid int64, otype string, count int64, platform string) (*lotteryApi.CapsuleOpenCapsuleByTypeResp, error) {
  35. return d.client.CapsuleClient.OpenCapsuleByType(ctx, &lotteryApi.CapsuleOpenCapsuleByTypeReq{Uid: uid, Type: otype, Count: count, Platform: platform})
  36. }