rcvr.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package impl
  4. import (
  5. "context"
  6. "smart-thirdparty/impl/v1/alarm"
  7. "smart-thirdparty/impl/v1/email"
  8. "smart-thirdparty/impl/v1/notify"
  9. "smart-thirdparty/impl/v1/vcode"
  10. "smart-thirdparty/pb"
  11. pb_v1 "smart-thirdparty/pb/v1"
  12. "github.com/jaryhe/gopkgs/tasker/rpctasker"
  13. "google.golang.org/grpc"
  14. )
  15. // 具体实现
  16. type Rcvr struct {
  17. }
  18. func Register(s *grpc.Server) {
  19. pb.RegisterSmartSiteThirdpartyServer(s, &Rcvr{})
  20. }
  21. func (c *Rcvr) GetVcode(ctx context.Context, req *pb_v1.GetVcodeRequest) (reply *pb_v1.GetVcodeReply, err error) {
  22. t1 := func() error {
  23. reply, err = vcode.GetVcode(ctx, req)
  24. return err
  25. }
  26. return reply, rpctasker.Exec(ctx, t1)
  27. }
  28. func (c *Rcvr) CheckVcode(ctx context.Context, req *pb_v1.CheckVcodeRequest) (reply *pb_v1.CheckVcodeReply, err error) {
  29. t1 := func() error {
  30. reply, err = vcode.CheckVcode(ctx, req)
  31. return err
  32. }
  33. return reply, rpctasker.Exec(ctx, t1)
  34. }
  35. func (c *Rcvr) SendEmail(ctx context.Context, req *pb_v1.SendEmailRequest) (reply *pb_v1.SendEmailReply, err error) {
  36. t1 := func() error {
  37. reply, err = email.SendEmail(ctx, req)
  38. return err
  39. }
  40. return reply, rpctasker.Exec(ctx, t1)
  41. }
  42. // 发送告警
  43. func (c *Rcvr) SendAlarm(ctx context.Context, req *pb_v1.SendAlarmRequest) (reply *pb_v1.SendAlarmReply, err error) {
  44. t1 := func() error {
  45. reply, err = alarm.SendAlarm(ctx, req)
  46. return err
  47. }
  48. return reply, rpctasker.Exec(ctx, t1)
  49. }
  50. // 发送审核通过通知
  51. func (c *Rcvr) SendThroughVerify(ctx context.Context, req *pb_v1.SendThroughVerifyRequest) (reply *pb_v1.SendThroughVerifyReply, err error) {
  52. t1 := func() error {
  53. reply, err = notify.SendThroughVerify(ctx, req)
  54. return err
  55. }
  56. return reply, rpctasker.Exec(ctx, t1)
  57. }