From 1ca4109013bb07f7f55093357bf68fcfe435e0f2 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 27 七月 2020 14:57:13 +0800
Subject: [PATCH] fix string array unmarshal and config hikUrl

---
 conf/app.conf         |    3 ++-
 controllers/sys.go    |   15 ++++++---------
 service/carService.go |    5 +++--
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/conf/app.conf b/conf/app.conf
index accb8b5..d73f536 100644
--- a/conf/app.conf
+++ b/conf/app.conf
@@ -18,4 +18,5 @@
 pushBaseUrl = https://restapi.getui.com/v2/
 dbUrl = root:c++java123@tcp(192.168.20.173:3306)/car_yuying?charset=utf8
 redisIp = 192.168.20.10
-redisPort = 6379
\ No newline at end of file
+redisPort = 6379
+hikUrl = https://111.205.161.131:1443
\ No newline at end of file
diff --git a/controllers/sys.go b/controllers/sys.go
index 953a0ae..c4844f0 100644
--- a/controllers/sys.go
+++ b/controllers/sys.go
@@ -36,17 +36,14 @@
 			result.LatestVersion = sv.LatestVersion
 			result.Time = sv.Time
 			result.ForceUpgrade = sv.ForceUpgrade
-			mb, e1 := json.Marshal(sv.Msg)
-			if e1 == nil {
-				var msgArr []string
-				if e1 = json.Unmarshal(mb, &msgArr);e1 ==nil {
-					result.Msg = msgArr
-				} else {
-					fmt.Println("unmarshal err:", e1)
-				}
+			var msgArr []string
+			if e1 := json.Unmarshal([]byte(sv.Msg), &msgArr);e1 ==nil {
+				result.Msg = msgArr
 			} else {
-				fmt.Println("marshal err:", e1)
+				fmt.Println("unmarshal err:", e1)
+				result.Msg = []string{}
 			}
+
 		} else {
 			result.IsUpgrade = false
 		}
diff --git a/service/carService.go b/service/carService.go
index 7476dcb..2be9199 100644
--- a/service/carService.go
+++ b/service/carService.go
@@ -1,10 +1,11 @@
 package service
 
 import (
-	"car-service/models"
 	reqUtil "car-service/extend/util"
+	"car-service/models"
 	"encoding/json"
 	"fmt"
+	"github.com/astaxie/beego"
 	"strconv"
 )
 type CarService struct {
@@ -16,7 +17,7 @@
 		hikUtil: &reqUtil.HikHttpUtil{
 			AppKey: hikAppKey,
 			AppSecret: hikAppSecret,
-			ReqHost: "https://172.16.35.50:1443",
+			ReqHost: beego.AppConfig.String("hikUrl"),
 		},
 	}
 }

--
Gitblit v1.8.0