data_supplement.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package ctrl_v1
  4. import (
  5. "gd_management_gateway/errors"
  6. "gd_management_gateway/params/param_base"
  7. "gd_management_gateway/params/param_v1_0"
  8. "gd_management_gateway/rpc_apis"
  9. "gd_management_gateway/rpc_apis/gd_management"
  10. "fmt"
  11. "time"
  12. "gd_management_gateway/common.in/httper"
  13. "gd_management_gateway/common.in/task"
  14. "gd_management_gateway/common.in/utils"
  15. "github.com/astaxie/beego"
  16. "go.uber.org/zap"
  17. )
  18. // Operations about provider
  19. type DataSupplementController struct {
  20. metadata interface{} // 中继元数据
  21. beego.Controller
  22. LogID string
  23. }
  24. // @Title 获取补充数据库
  25. // @Description 获取补充数据库
  26. // @Param token header string true "token"
  27. // @Param uid header int64 true "admin id"
  28. // @Success 200 {object} params.param_v1_0.ManagementGetSupplementDbResp "响应信息"
  29. // @Failure 500 服务器错误
  30. // @router /db [get]
  31. func (u *DataSupplementController) ManagementGetSupplementDb() {
  32. u.LogID = fmt.Sprintf("ManagementGetSuplementDb[%d]", time.Now().UnixNano())
  33. req := &param_v1_0.ManagementGetSupplementDbReq{}
  34. getParamsTask := func() error {
  35. httper.FillRequireParams(u.Ctx, req, u.LogID)
  36. return nil
  37. }
  38. handleDataTask := func() error {
  39. mreq := gd_management.ManagementGetSupplementDbReq{}
  40. mreply, err := rpc_apis.Management.ManagementGetSupplementDb(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
  41. if err != nil {
  42. l.Error("rpc",
  43. zap.String("call", "ManagementGetSupplementDb"),
  44. zap.String("args", utils.MarshalJsonString(req)),
  45. zap.String("error", err.Error()))
  46. return errors.ErrorTransform(err)
  47. }
  48. resp := param_v1_0.ManagementGetSupplementDbResp{
  49. SimpleResp: param_base.SimpleResp{
  50. Code: 0,
  51. Msg: "SUCCESS",
  52. },
  53. }
  54. resp.Data = mreply
  55. httper.JSON(u.Ctx, resp, u.LogID)
  56. return nil
  57. }
  58. // 执行以上定义的任务
  59. task.Do(&task.PanicRecover{
  60. Ctx: u.Ctx,
  61. LogID: u.LogID}, u.Ctx,
  62. getParamsTask, handleDataTask,
  63. )
  64. }
  65. // @Title 数据补充获取标题
  66. // @Description 数据补充获取标题
  67. // @Param token header string true "token"
  68. // @Param uid header int64 true "admin id"
  69. // @Param db_code query string false "数据类型"
  70. // @Success 200 {object} params.param_v1_0.ManagementGetSuplementTitleResp "响应信息"
  71. // @Failure 500 服务器错误
  72. // @router /title [get]
  73. func (u *DataSupplementController) ManagementGetSuplementTitle() {
  74. u.LogID = fmt.Sprintf("ManagementGetSuplementTitle[%d]", time.Now().UnixNano())
  75. req := &param_v1_0.ManagementGetSuplementTitleReq{}
  76. getParamsTask := func() error {
  77. httper.FillRequireParams(u.Ctx, req, u.LogID)
  78. return nil
  79. }
  80. handleDataTask := func() error {
  81. mreq := gd_management.ManagementGetSuplementTitleReq{}
  82. mreq.DbCode = req.DbCode
  83. mreply, err := rpc_apis.Management.ManagementGetSuplementTitle(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
  84. if err != nil {
  85. l.Error("rpc",
  86. zap.String("call", "ManagementGetSuplementTitle"),
  87. zap.String("args", utils.MarshalJsonString(req)),
  88. zap.String("error", err.Error()))
  89. return errors.ErrorTransform(err)
  90. }
  91. resp := param_v1_0.ManagementGetSuplementTitleResp{
  92. SimpleResp: param_base.SimpleResp{
  93. Code: 0,
  94. Msg: "SUCCESS",
  95. },
  96. }
  97. resp.Data = mreply
  98. httper.JSON(u.Ctx, resp, u.LogID)
  99. return nil
  100. }
  101. // 执行以上定义的任务
  102. task.Do(&task.PanicRecover{
  103. Ctx: u.Ctx,
  104. LogID: u.LogID}, u.Ctx,
  105. getParamsTask, handleDataTask,
  106. )
  107. }
  108. // @Title 数据补充获取标题
  109. // @Description 数据补充获取标题
  110. // @Param token header string true "token"
  111. // @Param uid header int64 true "admin id"
  112. // @Param body body rpc_apis.gd_management.ManagementGetDataSupplementReq true "参数"
  113. // @Success 200 {object} params.param_v1_0.ManagementGetDataSupplementResp "响应信息"
  114. // @Failure 500 服务器错误
  115. // @router /data [put]
  116. func (u *DataSupplementController) ManagementGetDataSupplement() {
  117. u.LogID = fmt.Sprintf("ManagementGetDataSupplement[%d]", time.Now().UnixNano())
  118. req := &param_v1_0.ManagementGetDataSupplementReq{}
  119. getParamsTask := func() error {
  120. httper.FillRequireParams(u.Ctx, req, u.LogID)
  121. return nil
  122. }
  123. handleDataTask := func() error {
  124. //mreq := gd_management.ManagementGetDataSupplementReq{}
  125. //mreq.SearchCode = req.SearchCode
  126. //json.Unmarshal([]byte(req.Keys), &mreq.Keys)
  127. mreply, err := rpc_apis.Management.ManagementGetDataSupplement(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
  128. if err != nil {
  129. l.Error("rpc",
  130. zap.String("call", "ManagementGetDataSupplement"),
  131. zap.String("args", utils.MarshalJsonString(req)),
  132. zap.String("error", err.Error()))
  133. return errors.ErrorTransform(err)
  134. }
  135. resp := param_v1_0.ManagementGetDataSupplementResp{
  136. SimpleResp: param_base.SimpleResp{
  137. Code: 0,
  138. Msg: "SUCCESS",
  139. },
  140. }
  141. resp.Data = mreply
  142. httper.JSON(u.Ctx, resp, u.LogID)
  143. return nil
  144. }
  145. // 执行以上定义的任务
  146. task.Do(&task.PanicRecover{
  147. Ctx: u.Ctx,
  148. LogID: u.LogID}, u.Ctx,
  149. getParamsTask, handleDataTask,
  150. )
  151. }
  152. // @Title 数据补充获取标题
  153. // @Description 数据补充获取标题
  154. // @Param token header string true "token"
  155. // @Param uid header int64 true "admin id"
  156. // @Param body body rpc_apis.gd_management.ManagementUpdateDataSupplementReq true "参数"
  157. // @Success 200 {object} params.param_v1_0.ManagementUpdateDataSupplementResp "响应信息"
  158. // @Failure 500 服务器错误
  159. // @router /data [post]
  160. func (u *DataSupplementController) ManagementUpdateDataSupplement() {
  161. u.LogID = fmt.Sprintf("ManagementUpdateDataSupplement[%d]", time.Now().UnixNano())
  162. req := &param_v1_0.ManagementUpdateDataSupplementReq{}
  163. getParamsTask := func() error {
  164. httper.FillRequireParams(u.Ctx, req, u.LogID)
  165. return nil
  166. }
  167. handleDataTask := func() error {
  168. mreply, err := rpc_apis.Management.ManagementUpdateDataSupplement(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
  169. if err != nil {
  170. l.Error("rpc",
  171. zap.String("call", "ManagementUpdateDataSupplement"),
  172. zap.String("args", utils.MarshalJsonString(req)),
  173. zap.String("error", err.Error()))
  174. return errors.ErrorTransform(err)
  175. }
  176. resp := param_v1_0.ManagementUpdateDataSupplementResp{
  177. SimpleResp: param_base.SimpleResp{
  178. Code: 0,
  179. Msg: "SUCCESS",
  180. },
  181. }
  182. resp.Data = mreply
  183. httper.JSON(u.Ctx, resp, u.LogID)
  184. return nil
  185. }
  186. // 执行以上定义的任务
  187. task.Do(&task.PanicRecover{
  188. Ctx: u.Ctx,
  189. LogID: u.LogID}, u.Ctx,
  190. getParamsTask, handleDataTask,
  191. )
  192. }