From f529b0fe67d68a4be6e9690043ee5d6837be72df Mon Sep 17 00:00:00 2001
From: 554325746@qq.com <554325746@qq.com>
Date: 星期二, 12 一月 2021 11:05:50 +0800
Subject: [PATCH] getAppInfo and voice add
---
voiceApi.go | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/voiceApi.go b/voiceApi.go
index 57c2b9c..b5bcc11 100644
--- a/voiceApi.go
+++ b/voiceApi.go
@@ -25,20 +25,59 @@
}
//鏌ユ壘鎵�鏈夌畻娉�
-func (api VoiceApi) FindAll()[]protomsg.Voice{
+func (api VoiceApi) FindAll() (bool, []protomsg.Voice) {
var voiceArr []protomsg.Voice
url := api.getBasicUrl() + DATA_URL_PREFIX + "/voice/findAll"
client := NewClient()
respBody, err := client.DoGetRequest(url, nil, nil)
if err !=nil {
- return voiceArr
+ return false, nil
}
var res Result
if err = json.Unmarshal(respBody, &res); err != nil {
logPrint(err)
- return voiceArr
+ return false, nil
}
bytes, _ := json.Marshal(res.Data)
err = json.Unmarshal(bytes, &voiceArr)
- return voiceArr
-}
\ No newline at end of file
+ return res.Success, voiceArr
+}
+
+func (api VoiceApi) Add(id,name,mp3File,g711aFile string) (bool, interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/voice/add"
+ client := NewClient()
+ paramBody := map[string]string{
+ "id": id,
+ "name": name,
+ "mp3File": mp3File,
+ "g711aFile": g711aFile,
+ }
+ respBody, err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody, nil, nil, nil)
+ if err !=nil {
+ return false, nil
+ }
+ var res Result
+ if err = json.Unmarshal(respBody, &res); err != nil {
+ logPrint(err)
+ return false, nil
+ }
+ return res.Success, res.Data
+}
+
+func (api VoiceApi) Del(id string) (bool, interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/voice/add"
+ client := NewClient()
+ paramQuery := map[string]string{
+ "id": id,
+ }
+ respBody, err := client.DoDeleteRequest(url,paramQuery, nil, nil)
+ if err !=nil {
+ return false, nil
+ }
+ var res Result
+ if err = json.Unmarshal(respBody, &res); err != nil {
+ logPrint(err)
+ return false, nil
+ }
+ return res.Success, res.Data
+}
--
Gitblit v1.8.0