rcvr.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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/provincial_department"
  10. "smart-thirdparty/impl/v1/vcode"
  11. "smart-thirdparty/impl/v1/weather"
  12. "smart-thirdparty/pb"
  13. pb_v1 "smart-thirdparty/pb/v1"
  14. "github.com/jaryhe/gopkgs/tasker/rpctasker"
  15. "google.golang.org/grpc"
  16. )
  17. // 具体实现
  18. type Rcvr struct {
  19. }
  20. func Register(s *grpc.Server) {
  21. pb.RegisterSmartSiteThirdpartyServer(s, &Rcvr{})
  22. }
  23. func (c *Rcvr) GetVcode(ctx context.Context, req *pb_v1.GetVcodeRequest) (reply *pb_v1.GetVcodeReply, err error) {
  24. t1 := func() error {
  25. reply, err = vcode.GetVcode(ctx, req)
  26. return err
  27. }
  28. return reply, rpctasker.Exec(ctx, t1)
  29. }
  30. func (c *Rcvr) CheckVcode(ctx context.Context, req *pb_v1.CheckVcodeRequest) (reply *pb_v1.CheckVcodeReply, err error) {
  31. t1 := func() error {
  32. reply, err = vcode.CheckVcode(ctx, req)
  33. return err
  34. }
  35. return reply, rpctasker.Exec(ctx, t1)
  36. }
  37. func (c *Rcvr) SendEmail(ctx context.Context, req *pb_v1.SendEmailRequest) (reply *pb_v1.SendEmailReply, err error) {
  38. t1 := func() error {
  39. reply, err = email.SendEmail(ctx, req)
  40. return err
  41. }
  42. return reply, rpctasker.Exec(ctx, t1)
  43. }
  44. // 发送告警
  45. func (c *Rcvr) SendAlarm(ctx context.Context, req *pb_v1.SendAlarmRequest) (reply *pb_v1.SendAlarmReply, err error) {
  46. t1 := func() error {
  47. reply, err = alarm.SendAlarm(ctx, req)
  48. return err
  49. }
  50. return reply, rpctasker.Exec(ctx, t1)
  51. }
  52. // 发送审核通过通知
  53. func (c *Rcvr) SendThroughVerify(ctx context.Context, req *pb_v1.SendThroughVerifyRequest) (reply *pb_v1.SendThroughVerifyReply, err error) {
  54. t1 := func() error {
  55. reply, err = notify.SendThroughVerify(ctx, req)
  56. return err
  57. }
  58. return reply, rpctasker.Exec(ctx, t1)
  59. }
  60. // 获取实时天气
  61. func (c *Rcvr) WeatherCondition(ctx context.Context, req *pb_v1.WeatherConditionRequest) (reply *pb_v1.WeatherConditionReply, err error) {
  62. t1 := func() error {
  63. reply, err = weather.WeatherCondition(ctx, req)
  64. return err
  65. }
  66. return reply, rpctasker.Exec(ctx, t1)
  67. }
  68. // 获取空气质量指数
  69. func (c *Rcvr) WeatherEnviroment(ctx context.Context, req *pb_v1.WeatherEnviromentRequest) (reply *pb_v1.WeatherEnviromentReply, err error) {
  70. t1 := func() error {
  71. reply, err = weather.WeatherEnviroment(ctx, req)
  72. return err
  73. }
  74. return reply, rpctasker.Exec(ctx, t1)
  75. }
  76. // 获取近15天天气预报
  77. func (c *Rcvr) WeatherForecast15(ctx context.Context, req *pb_v1.WeatherForecast15Request) (reply *pb_v1.WeatherForecast15Reply, err error) {
  78. t1 := func() error {
  79. reply, err = weather.WeatherForecast15(ctx, req)
  80. return err
  81. }
  82. return reply, rpctasker.Exec(ctx, t1)
  83. }
  84. // 省厅获取项目编码
  85. func (c *Rcvr) ProvincialGetProjectCode(ctx context.Context, req *pb_v1.ProvincialGetProjectCodeRequest) (reply *pb_v1.ProvincialGetProjectCodeReply, err error) {
  86. t1 := func() error {
  87. reply, err = provincial_department.ProvincialGetProjectCode(ctx, req)
  88. return err
  89. }
  90. return reply, rpctasker.Exec(ctx, t1)
  91. }
  92. // 提交项目信息
  93. func (c *Rcvr) ProvincialPostProject(ctx context.Context, req *pb_v1.ProvincialPostProjectRequest) (reply *pb_v1.ProvincialPostProjectReply, err error) {
  94. t1 := func() error {
  95. reply, err = provincial_department.ProvincialPostProject(ctx, req)
  96. return err
  97. }
  98. return reply, rpctasker.Exec(ctx, t1)
  99. }
  100. // 提交扬尘设备信息
  101. func (c *Rcvr) ProvincialPostDustDevice(ctx context.Context, req *pb_v1.ProvincialPostDustDeviceRequest) (reply *pb_v1.ProvincialPostDustDeviceReply, err error) {
  102. t1 := func() error {
  103. reply, err = provincial_department.ProvincialPostDustDevice(ctx, req)
  104. return err
  105. }
  106. return reply, rpctasker.Exec(ctx, t1)
  107. }
  108. // 提交扬尘监测数据
  109. func (c *Rcvr) ProvincialPostDustData(ctx context.Context, req *pb_v1.ProvincialPostDustDataRequest) (reply *pb_v1.ProvincialPostDustDataReply, err error) {
  110. t1 := func() error {
  111. reply, err = provincial_department.ProvincialPostDustData(ctx, req)
  112. return err
  113. }
  114. return reply, rpctasker.Exec(ctx, t1)
  115. }
  116. func (c *Rcvr) ProvincialVerifyData(ctx context.Context, req *pb_v1.ProvincialVerifyDataRequest) (reply *pb_v1.ProvincialVerifyDataReply, err error) {
  117. t1 := func() error {
  118. reply, err = provincial_department.ProvincialVerifyData(ctx, req)
  119. return err
  120. }
  121. return reply, rpctasker.Exec(ctx, t1)
  122. }
  123. func (c *Rcvr) ProvincialPostTeam(ctx context.Context, req *pb_v1.ProvincialPostTeamRequest) (reply *pb_v1.ProvincialPostTeamReply, err error) {
  124. t1 := func() error {
  125. reply, err = provincial_department.ProvincialPostTeam(ctx, req)
  126. return err
  127. }
  128. return reply, rpctasker.Exec(ctx, t1)
  129. }
  130. func (c *Rcvr) ProvincialPostStaff(ctx context.Context, req *pb_v1.ProvincialPostStaffRequest) (reply *pb_v1.ProvincialPostStaffReply, err error) {
  131. t1 := func() error {
  132. reply, err = provincial_department.ProvincialPostStaff(ctx, req)
  133. return err
  134. }
  135. return reply, rpctasker.Exec(ctx, t1)
  136. }
  137. func (c *Rcvr) ProvincialPostStaffAttendance(ctx context.Context, req *pb_v1.ProvincialPostStaffAttendanceRequest) (reply *pb_v1.ProvincialPostStaffAttendanceReply, err error) {
  138. t1 := func() error {
  139. reply, err = provincial_department.ProvincialPostStaffAttendance(ctx, req)
  140. return err
  141. }
  142. return reply, rpctasker.Exec(ctx, t1)
  143. }