From 468a696bf67400c69f0ece6c35663df51f950ba8 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 13 七月 2020 17:36:09 +0800
Subject: [PATCH] add voice

---
 service/SdkInstall.go |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/service/SdkInstall.go b/service/SdkInstall.go
index ce8c083..9cc0102 100644
--- a/service/SdkInstall.go
+++ b/service/SdkInstall.go
@@ -2,6 +2,7 @@
 
 import (
 	"basic.com/dbapi.git"
+	"basic.com/valib/licence.git"
 	"basic.com/valib/logger.git"
 	"encoding/json"
 	"errors"
@@ -13,10 +14,44 @@
 	"strings"
 	"webserver/extend/config"
 	"webserver/extend/util"
+	reqUtil "webserver/extend/util"
 )
 
 type SdkInstallService struct {
 
+}
+
+func (sv SdkInstallService) Active(cod string) error {
+	//浣跨敤婵�娲荤爜婵�娲荤畻娉�
+	url := "http://"+config.ShopConf.Url+"/data/api-s/sdk/activeByAINode"
+	machineCode := licence.GetMachineCode()
+	if machineCode == "" {
+		logger.Debug("鑾峰彇鏈哄櫒鐮佸け璐�")
+		return errors.New("鑾峰彇鏈哄櫒鐮佸け璐�")
+	}
+	paramBody := map[string]interface{}{
+		"code": cod,
+		"machineCode": machineCode,
+	}
+	header := map[string]string {
+		"Authorization": token,
+	}
+	respBody, err := reqUtil.DoPostRequest(url, reqUtil.CONTENT_TYPE_JSON, paramBody, nil, header)
+	if err != nil {
+		logger.Debug("DoPostRequest err:", err)
+		return err
+	}
+	var res dbapi.Result
+	if err = json.Unmarshal(respBody, &res); err != nil {
+		logger.Debug("unmarshal err:", err)
+		return err
+	}
+	if !res.Success {
+		logger.Debug("res.Data:", res.Data)
+		return errors.New("璇锋眰鍟嗗煄澶辫触")
+	}
+
+	return nil
 }
 
 //绠楁硶瀹夎鍖呭畨瑁�
@@ -351,6 +386,8 @@
 	Env 			string 		`gorm:"column:env" json:"env"` //杩愯鐜鍙婄粨鏋滆鏄庯紝json鏍煎紡锛屽寘鍚玸o_file_path,runtime,param,depends(cuda鐗堟湰锛宱pencv鐗堟湰锛宼ensorflow鐗堟湰绛�)
 	IconBlob 		string 		`gorm:"column:iconBlob;type:text;" json:"iconBlob"` //鍥剧墖
 	Version 		string 		`gorm:"column:version;type:varchar(50);default:'1.0';" json:"version"` //鐗堟湰鍙�
+	Args 			[]SdkArg 	`json:"args"`
+	ArgDef 			string 		`gorm:"column:argDef" json:"argDef"` //绠楁硶鍙傛暟榛樿閰嶇疆
 }
 
 type SdkInsOrUpgrade struct {

--
Gitblit v1.8.0