浏览代码

fix bug: 查历史数据可能查不到且崩溃

zou.yingbin 3 年之前
父节点
当前提交
05442c5fb6
共有 2 个文件被更改,包括 5 次插入5 次删除
  1. 3 3
      controllers/quote/history.go
  2. 2 2
      models/market.go

+ 3 - 3
controllers/quote/history.go

@@ -137,7 +137,7 @@ func QueryHistoryDatas(c *gin.Context) {
 			return
 		}
 		if market == nil {
-			logger.GetLogger().Errorf("QueryHistoryDatas failed: %s", err.Error())
+			logger.GetLogger().Error("QueryHistoryDatas failed: not found goodscode")
 			appG.Response(http.StatusBadRequest, e.ERROR_GET_MARKET_FAILED, nil)
 			return
 		}
@@ -232,7 +232,7 @@ func QueryHistoryDatas(c *gin.Context) {
 	}
 
 	// 查询成功
-	logger.GetLogger().Debugln("QueryHistoryDatas successed, rows:%v", len(rst))
+	logger.GetLogger().Debugln("QueryHistoryDatas successed, rows:", len(rst))
 	appG.Response(http.StatusOK, e.SUCCESS, rst)
 }
 
@@ -422,7 +422,7 @@ func QueryTSData(c *gin.Context) {
 		return
 	}
 	if market == nil {
-		logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
+		logger.GetLogger().Error("QueryTSData failed: not found goodscode")
 		appG.Response(http.StatusBadRequest, e.ERROR_GET_MARKET_FAILED, nil)
 		return
 	}

+ 2 - 2
models/market.go

@@ -205,7 +205,7 @@ func GetMarketByGoodsCode(goodsCode string) (*Market, error) {
 
 	var market Market
 	has, err := engine.Join("LEFT", "GOODS", "GOODS.MARKETID = MARKET.MARKETID").
-		Where("GOODS.GOODSCODE = ?", goodsCode).Get(&market)
+		Where("upper(GOODS.GOODSCODE) = ?", goodsCode).Get(&market)
 	if err != nil {
 		return nil, err
 	}
@@ -497,4 +497,4 @@ func GetAvalidExchangeId(userId int64) []int64 {
 		sId = append(sId, v.EXEXCHANGEID)
 	}
 	return sId
-}
+}