123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package ctrl_v1
- import (
- "gd_management_gateway/errors"
- "gd_management_gateway/params/param_base"
- "gd_management_gateway/params/param_v1_0"
- "gd_management_gateway/rpc_apis"
- "gd_management_gateway/rpc_apis/gd_management"
- "fmt"
- "time"
- "gd_management_gateway/common.in/httper"
- "gd_management_gateway/common.in/task"
- "gd_management_gateway/common.in/utils"
- "github.com/astaxie/beego"
- "go.uber.org/zap"
- )
- // Operations about provider
- type DataSupplementController struct {
- metadata interface{} // 中继元数据
- beego.Controller
- LogID string
- }
- // @Title 获取补充数据库
- // @Description 获取补充数据库
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Success 200 {object} params.param_v1_0.ManagementGetSupplementDbResp "响应信息"
- // @Failure 500 服务器错误
- // @router /db [get]
- func (u *DataSupplementController) ManagementGetSupplementDb() {
- u.LogID = fmt.Sprintf("ManagementGetSuplementDb[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ManagementGetSupplementDbReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.ManagementGetSupplementDbReq{}
- mreply, err := rpc_apis.Management.ManagementGetSupplementDb(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ManagementGetSupplementDb"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ManagementGetSupplementDbResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = mreply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 数据补充获取标题
- // @Description 数据补充获取标题
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param db_code query string false "数据类型"
- // @Success 200 {object} params.param_v1_0.ManagementGetSuplementTitleResp "响应信息"
- // @Failure 500 服务器错误
- // @router /title [get]
- func (u *DataSupplementController) ManagementGetSuplementTitle() {
- u.LogID = fmt.Sprintf("ManagementGetSuplementTitle[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ManagementGetSuplementTitleReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.ManagementGetSuplementTitleReq{}
- mreq.DbCode = req.DbCode
- mreply, err := rpc_apis.Management.ManagementGetSuplementTitle(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ManagementGetSuplementTitle"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ManagementGetSuplementTitleResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = mreply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 数据补充获取标题
- // @Description 数据补充获取标题
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.ManagementGetDataSupplementReq true "参数"
- // @Success 200 {object} params.param_v1_0.ManagementGetDataSupplementResp "响应信息"
- // @Failure 500 服务器错误
- // @router /data [put]
- func (u *DataSupplementController) ManagementGetDataSupplement() {
- u.LogID = fmt.Sprintf("ManagementGetDataSupplement[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ManagementGetDataSupplementReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- //mreq := gd_management.ManagementGetDataSupplementReq{}
- //mreq.SearchCode = req.SearchCode
- //json.Unmarshal([]byte(req.Keys), &mreq.Keys)
- mreply, err := rpc_apis.Management.ManagementGetDataSupplement(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ManagementGetDataSupplement"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ManagementGetDataSupplementResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = mreply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 数据补充获取标题
- // @Description 数据补充获取标题
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.ManagementUpdateDataSupplementReq true "参数"
- // @Success 200 {object} params.param_v1_0.ManagementUpdateDataSupplementResp "响应信息"
- // @Failure 500 服务器错误
- // @router /data [post]
- func (u *DataSupplementController) ManagementUpdateDataSupplement() {
- u.LogID = fmt.Sprintf("ManagementUpdateDataSupplement[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ManagementUpdateDataSupplementReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreply, err := rpc_apis.Management.ManagementUpdateDataSupplement(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ManagementUpdateDataSupplement"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ManagementUpdateDataSupplementResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = mreply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
|