Ver Fonte

校验入参

xyxie há 1 ano atrás
pai
commit
bf9b458c9a
2 ficheiros alterados com 9 adições e 5 exclusões
  1. 3 4
      models/jiayue/dict.go
  2. 6 1
      services/index_data/jiayue_platform.go

+ 3 - 4
models/jiayue/dict.go

@@ -2,7 +2,6 @@ package jiayue
 
 import (
 	"database/sql"
-	"encoding/json"
 	"eta/eta_bridge/global"
 	"fmt"
 )
@@ -151,7 +150,7 @@ func getDictIndex(sqlStatement string, pars []interface{}) (dictIndexs []DictInd
 	global.LOG.Info("获取列表相关信息")
 	for i := 0; i < len(strings); i++ {
 		fmt.Print(" ", strings[i])
-		global.LOG.Info("显示字段:", strings[i])
+		//global.LOG.Info("显示字段:", strings[i])
 	}
 	fmt.Print("\n")
 	global.LOG.Info("\n")
@@ -206,7 +205,7 @@ func getDictIndex(sqlStatement string, pars []interface{}) (dictIndexs []DictInd
 	}
 	defer stmt.Close()
 
-	data, err := json.Marshal(dictIndexs)
+	/*data, err := json.Marshal(dictIndexs)
 	if err != nil {
 		fmt.Printf("序列化错误 err = %v\n", err)
 		global.LOG.Info("序列化错误 err = %v\n", err)
@@ -214,7 +213,7 @@ func getDictIndex(sqlStatement string, pars []interface{}) (dictIndexs []DictInd
 	}
 	//输出序列化后的结果 json字符串
 	fmt.Printf("序列化后 = %v\n", string(data))
-	global.LOG.Info("序列化后 = %v\n", string(data))
+	global.LOG.Info("序列化后 = %v\n", string(data))*/
 	return
 }
 

+ 6 - 1
services/index_data/jiayue_platform.go

@@ -8,6 +8,7 @@ import (
 	"eta/eta_bridge/services/alarm_msg"
 	"eta/eta_bridge/utils"
 	"fmt"
+	"strconv"
 	"time"
 )
 
@@ -35,8 +36,12 @@ func GetIndexFromJiaYue(indexCode, source, startDate, endDate string) (data *res
 		indexCond += " AND SOURCE_CODE = :1 "
 		indexPars = append(indexPars, indexCode)
 	} else {
+		indexId, e := strconv.Atoi(indexCode)
+		if e != nil {
+			err = fmt.Errorf("类型错误,请输入正确的指标code")
+		}
 		indexCond += " AND ID = :1 "
-		indexPars = append(indexPars, indexCode)
+		indexPars = append(indexPars, indexId)
 	}
 
 	indexList, err := jiayue.GetDictIndex(indexCond, indexPars)