rcvr.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Copyright 2019 utimes.cc. All rights reserved.
  2. // Use of this source code is governed by utimes.cc.
  3. // package impl implement all interfaces of micro service in gd_auth_check
  4. package impl
  5. import (
  6. "context"
  7. "gd_auth_check/apis"
  8. "gd_auth_check/impl/data_api_check"
  9. "gd_auth_check/impl/management"
  10. "encoding/json"
  11. "gd_auth_check/common.in/jsonrpc2"
  12. "gd_auth_check/common.in/task"
  13. "github.com/astaxie/beego/orm"
  14. )
  15. // 具体实现
  16. type Rcvr struct {
  17. }
  18. func (c *Rcvr) ManagementCheckApi(ctx context.Context, req *apis.ManagementCheckApiReq, reply *apis.ManagementCheckApiReply) error {
  19. t1 := func() error {
  20. return data_api_check.ManagementCheckApi(ctx, req, reply)
  21. }
  22. err := task.Do(ctx, t1)
  23. if err != nil {
  24. var e jsonrpc2.Error
  25. merr := json.Unmarshal([]byte(err.Error()), &e)
  26. if merr != nil {
  27. reply.ErrCode = int(1001)
  28. reply.ErrMsg = "服务错误"
  29. }
  30. reply.ErrCode = e.Code
  31. reply.ErrMsg = e.Message
  32. }
  33. return nil
  34. }
  35. func (c *Rcvr) ManagementCheckProviderApi(ctx context.Context, req *apis.ManagementCheckProviderApiReq, reply *apis.ManagementCheckProviderApiReply) error {
  36. t1 := func() error {
  37. return data_api_check.ManagementCheckProviderApi(ctx, req, reply)
  38. }
  39. return task.Do(ctx, t1)
  40. }
  41. func (c *Rcvr) ManagementThirdpartCountIncrease(ctx context.Context, req *apis.ManagementThirdpartCountIncreaseReq, reply *apis.ManagementThirdpartCountIncreaseReply) error {
  42. t1 := func() error {
  43. return data_api_check.ManagementThirdpartCountIncrease(ctx, req, reply)
  44. }
  45. return task.Do(ctx, t1)
  46. }
  47. func (c *Rcvr) ManagementCheckCountCode(ctx context.Context, req *apis.ManagementCheckCountCodeReq, reply *apis.ManagementCheckCountCodeReply) error {
  48. t1 := func() error {
  49. return data_api_check.ManagementCheckCountCode(ctx, req, reply)
  50. }
  51. return task.Do(ctx, t1)
  52. }
  53. func (c *Rcvr) MerchantAppLogin(ctx context.Context, req *apis.MerchantAppLoginReq, reply *apis.MerchantAppLoginReply) error {
  54. t1 := func() error {
  55. return data_api_check.MerchantAppLogin(ctx, req, reply)
  56. }
  57. return task.Do(ctx, t1)
  58. }
  59. func (r *Rcvr) ManagementGetProviderApiLimitCount(ctx context.Context, req *apis.ManagementGetProviderApiLimitCountReq, reply *apis.ManagementGetProviderApiLimitCountReply) error {
  60. t1 := func() error {
  61. return management.ManagementGetProviderApiLimitCount(ctx, req, reply)
  62. }
  63. return task.Do(ctx, t1)
  64. }
  65. func (c *Rcvr) ManagementGetName(ctx context.Context, req *apis.ManagementGetNameReq, reply *apis.ManagementGetNameReply) error {
  66. t1 := func() error {
  67. return management.ManagementGetName(ctx, req, reply)
  68. }
  69. return task.Do(ctx, t1)
  70. }
  71. func (c *Rcvr) GetApiThreshold(ctx context.Context, req *apis.GetApiThresholdReq, reply *apis.GetApiThresholdReply) error {
  72. t1 := func() error {
  73. return management.GetApiThreshold(ctx, req, reply)
  74. }
  75. return task.Do(ctx, t1)
  76. }
  77. // 获取商户计数码
  78. func (c *Rcvr) MangementGetUserMerchantCountCode(ctx context.Context, req *apis.MangementGetUserMerchantCountCodeReq, reply *apis.MangementGetUserMerchantCountCodeReply) error {
  79. t1 := func() error {
  80. return management.MangementGetUserMerchantCountCode(ctx, req, reply)
  81. }
  82. return task.Do(ctx, t1)
  83. }
  84. // 获取商户id和名称列表
  85. func (c *Rcvr) ManagementGetMerchantIds(ctx context.Context, req *apis.ManagementGetMerchantIdsReq, reply *apis.ManagementGetMerchantIdsReply) error {
  86. t1 := func() error {
  87. return management.ManagementGetMerchantIds(ctx, req, reply)
  88. }
  89. return task.Do(ctx, t1)
  90. }
  91. func (c *Rcvr) ManagementGetMerchantApiId(ctx context.Context, req *apis.ManagementGetMerchantApiIdReq, reply *apis.ManagementGetMerchantApiIdReply) error {
  92. t1 := func() error {
  93. return management.ManagementGetMerchantApiId(ctx, req, reply)
  94. }
  95. return task.Do(ctx, t1)
  96. }
  97. func (c *Rcvr) ManagementGetProviderCountInfo(ctx context.Context, req *apis.ManagementGetProviderCountInfoReq, reply *apis.ManagementGetProviderCountInfoReply) error {
  98. t1 := func() error {
  99. return management.ManagementGetProviderCountInfo(ctx, req, reply)
  100. }
  101. return task.Do(ctx, t1)
  102. }
  103. func (c *Rcvr) ManagementGetProviderIds(ctx context.Context, req *apis.ManagementGetProviderIdsReq, reply *apis.ManagementGetProviderIdsReply) error {
  104. t1 := func() error {
  105. return management.ManagementGetProviderIds(ctx, req, reply)
  106. }
  107. return task.Do(ctx, t1)
  108. }
  109. func (c *Rcvr) ManagementGetApiShowInfo(ctx context.Context, req *apis.ManagementGetApiShowInfoReq, reply *apis.ManagementGetApiShowInfoReply) error {
  110. t1 := func() error {
  111. return management.ManagementGetApiShowInfo(ctx, req, reply)
  112. }
  113. return task.Do(ctx, t1)
  114. }
  115. func (c *Rcvr) ManagementGetMerchantApiTimeout(ctx context.Context, req *apis.ManagementGetMerchantApiTimeoutReq, reply *apis.ManagementGetMerchantApiTimeoutReply) error {
  116. t1 := func() error {
  117. return management.ManagementGetMerchantApiTimeout(ctx, req, reply)
  118. }
  119. return task.Do(ctx, t1)
  120. }
  121. func (c *Rcvr) ReleaseToken(ctx context.Context, req *apis.RateLimitToken, reply *apis.RateLimitToken) error {
  122. t1 := func() error {
  123. return data_api_check.ReleaseToken(ctx, req, reply)
  124. }
  125. return task.Do(ctx, t1)
  126. }
  127. func RegisterModel() {
  128. orm.RegisterModel(new(apis.TGdApi))
  129. orm.RegisterModel(new(apis.TGdMerchants))
  130. orm.RegisterModel(new(apis.ManagementThirdpartCount))
  131. }