package base_api import ( "context" "gd_management/apis" "gd_management/errors" "encoding/json" "strconv" "strings" "gd_management/common.in/utils" "github.com/astaxie/beego/orm" "go.uber.org/zap" ) func ManagementGetBaseApiInfo(ctx context.Context, req *apis.ManagementGetBaseApiInfoReq, reply *apis.ManagementGetBaseApiInfoReply) (err error) { o := orm.NewOrm() dbInfo := apis.TGdApi{} err = o.QueryTable("t_gd_api").Filter("id", req.ApiId).One(&dbInfo) if err != nil { l.Error("func", zap.String("call", "ManagementGetBaseApiInfo"), zap.String("args", utils.MarshalJsonString(req)), zap.String("error", err.Error())) if err == orm.ErrNoRows { return errors.DataBaseNoRecord } return errors.DataBaseError } json.Unmarshal([]byte(dbInfo.RequestParam), &reply.BaseApiInfo.RequestParam) json.Unmarshal([]byte(dbInfo.ResponseParam), &reply.BaseApiInfo.ResponseParam) ids := strings.Split(dbInfo.ErrorCodeIds, ",") for _, v := range ids { id, _ := strconv.Atoi(v) reply.BaseApiInfo.ErrorCode = append(reply.BaseApiInfo.ErrorCode, id) } reply.BaseApiInfo.Method = dbInfo.Method reply.BaseApiInfo.Router = dbInfo.Router reply.BaseApiInfo.Name = dbInfo.Name reply.BaseApiInfo.Comment = dbInfo.Comment reply.BaseApiInfo.ThresholdTimeout = dbInfo.ThresholdTimeout reply.BaseApiInfo.ThresholdFailRate = dbInfo.ThresholdFailRate reply.BaseApiInfo.ThresholdNorecordRate = dbInfo.ThresholdNorecordRate reply.BaseApiInfo.Enable = dbInfo.Enable reply.BaseApiInfo.Type = dbInfo.ApiType l.Debug(utils.MarshalJsonString(req, reply)) return }