Procházet zdrojové kódy

update add new response

jaryhe před 7 měsíci
rodič
revize
0ddca08e9a
4 změnil soubory, kde provedl 28 přidání a 66 odebrání
  1. 1 0
      apis/common.go
  2. 25 0
      impl/vehicle/center.go
  3. 2 8
      impl/vehicle/group.go
  4. 0 58
      impl/vehicle/x001.go

+ 1 - 0
apis/common.go

@@ -12,6 +12,7 @@ type MerchantApiInfo struct {
 	OriginReuseTime    int    `json:"-"`
 	RandomPercentage   int    `json:"random_percentage"`
 	ApiTimeout         uint64 `json:"api_timeout" description:"商户接口超时时间"`
+	ResponseParamConf    []ManagementBaseApiParam `json:"response_param_conf" description:"响应参数"`
 }
 
 // 数据源原始数据

+ 25 - 0
impl/vehicle/center.go

@@ -62,6 +62,30 @@ func getApiCodeMap(reqCode string) string {
 	return retCode
 }*/
 
+func newResponse(respConf []apis.ManagementBaseApiParam) map[string]interface{}{
+	retMap := make(map[string]interface{})
+	for _,v := range respConf{
+		//if v.Selected{
+			key := v.Name
+			if v.Type == "int"{
+				retMap[key] = 0
+			}else if v.Type == "float"{
+				retMap[key] = 0
+			}else if v.Type == "bool"{
+				retMap[key] = false
+			}else if v.Type == "string"{
+				retMap[key] = ""
+			}else if v.Type == "struct"{
+				retMap[key] = make(map[string]interface{})
+			}else if strings.Contains(v.Type,"list"){
+				retMap[key] = make([]interface{},0)
+			}
+		//}
+	}
+
+	return retMap
+}
+
 func Query(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) (err error) {
 	defer func() {
 		//IsReuse(&reply.IsReuse, &reply.LReq)
@@ -90,6 +114,7 @@ func Query(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) (e
 	err = errors.NoRecord
 	if v, ok := interfaces[strings.ToUpper(req.Code)]; ok {
 		req.NeedVehicleInfo = v.NeedVehicleInfo
+		reply.Data = newResponse(req.ResponseParamConf)
 		err = v.Func(ctx, req, reply)
 		if err == nil {
 			if v.NeedFormat {

+ 2 - 8
impl/vehicle/group.go

@@ -328,15 +328,9 @@ func getIsMatch(respData map[string]interface{}) string {
 
 func group(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
 	reqData := req.Data.(map[string]interface{})
-	/*MerchantProviderLimitInfoList, err := utils.GetProviderInfo(req.MerchantApiInfo.MerchantChildApiId, req.BaseApiId)
-	if err != nil {
-		return errors.ServiceError
-	}
-
-	providerMap, providerGroup := utils.GenProviderInfoMapNew(MerchantProviderLimitInfoList)*/
+	respData := reply.Data.(map[string]interface{})
 	var err error
-	respData := make(map[string]interface{})
-	reply.Data = respData
+	//reply.Data = respData
 	for groupNum, group := range req.ProviderGroup {
 		rangeNo := groupNum + 1
 		for _, v := range group {

+ 0 - 58
impl/vehicle/x001.go

@@ -1,58 +0,0 @@
-// Copyright 2019 getensh.com. All rights reserved.
-// Use of this source code is governed by getensh.com.
-
-package vehicle
-/*
-import (
-	"context"
-	"gd_vehicle/apis"
-	"gd_vehicle/errors"
-	"gd_vehicle/impl/thirdparty_impl"
-	"gd_vehicle/impl/thirdparty_impl/dybd"
-	"gd_vehicle/utils"
-	dutils "gd_vehicle/utils"
-)
-
-// 学位
-func X001(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
-	reqData := req.Data.(map[string]interface{})
-	xwzh := dutils.GetStringParams(reqData, "xwzh")
-	name := dutils.GetStringParams(reqData, "name")
-	if xwzh == "" || name == "" {
-		return errors.ArgsError
-	}
-
-	var err error
-	var ret string
-	respData := make(map[string]string)
-	reply.Data = respData
-	for groupNum, group := range req.ProviderGroup {
-		rangeNo := groupNum + 1
-		for _, v := range group {
-			tReq := &apis.ThirdpartRequest{
-				Ctx:             ctx,
-				ProviderApiCode: v,
-				ProviderMap:     req.ProviderMap,
-				RangeNo:         rangeNo,
-				Req:             req,
-				Reply:           reply,
-			}
-			switch v {
-			// 学位证
-			case utils.DYXW:
-				tReq.Params = map[string]string{
-					"xwzsbh": xwzh,
-					"xm":     name,
-				}
-				ret, err = thirdparty_impl.CallThirdparty(tReq)
-				if err != nil {
-					continue
-				}
-				dybd.GetDybdTwoElementVerifyData(ret,respData)
-				return nil
-			}
-		}
-	}
-
-	return err
-}*/