From 63645d248c765244488cd34dbc1bb6528ca6b7c7 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 05 九月 2023 09:58:13 +0800
Subject: [PATCH] 修复编译

---
 system-service/controllers/voice.go |  318 ++++++++++++++++++++++++++--------------------------
 1 files changed, 159 insertions(+), 159 deletions(-)

diff --git a/system-service/controllers/voice.go b/system-service/controllers/voice.go
index 76725ac..53b5657 100644
--- a/system-service/controllers/voice.go
+++ b/system-service/controllers/voice.go
@@ -1,159 +1,159 @@
-package controllers
-
-import (
-	"basic.com/pubsub/protomsg.git"
-	"basic.com/valib/bhomeclient.git"
-	"encoding/json"
-	"github.com/satori/go.uuid"
-	"vamicro/system-service/models"
-	"vamicro/system-service/service"
-)
-
-type VoiceController struct{}
-
-type VoiceMenu struct {
-	Id   string `json:"id"`
-	Name string `json:"name"`
-	Path string `json:"path"`
-}
-
-// @Summary 鏌ユ壘鎵�鏈夋姤璀﹀0闊�
-// @Description 鏌ユ壘鎵�鏈夋姤璀﹀0闊�
-// @Produce json
-// @Tags 鎶ヨ澹伴煶
-// @Success 200 {string} json "{"code":200, msg:"",data:"",success:true}"
-// @Failure 500 {string} json "{"code":500, msg:"",data:"[]",success:false}"
-// @Router /data/api-v/voice/findAll [GET]
-func (vc *VoiceController) FindAll(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
-	var voiceMenus = make([]VoiceMenu, 0)
-	var voice models.Voice
-	voices, err := voice.FindAll()
-	//config.Server.Voices
-	if err == nil {
-		for _, v := range voices {
-			voiceMenus = append(voiceMenus, VoiceMenu{
-				Id:   v.Id,
-				Name: v.Name,
-				Path: v.Path,
-			})
-		}
-	}
-	return &bhomeclient.Reply{Success: true, Data: voiceMenus}
-}
-
-// @Summary 鑾峰彇鎶ヨ澹伴煶鍒楄〃
-// @Description 鑾峰彇鎶ヨ澹伴煶鍒楄〃
-// @Security ApiKeyAuth
-// @Produce json
-// @Tags 鎶ヨ澹伴煶
-// @Param id formData string false "id"
-// @Param name formData string true "鍚嶇О"
-// @Param mp3File formData string true "mp3鏂囦欢鍦板潃"
-// @Param g711aFile formData string true "g711a鏂囦欢鍦板潃"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/voice/add [post]
-func (vc *VoiceController) Add(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
-	id := c.PostForm("id")
-	name := c.PostForm("name")
-	mp3File := c.PostForm("mp3File")
-	//g711aFile := c.PostForm("g711aFile")
-	if name == "" {
-		return &bhomeclient.Reply{Msg: "name涓嶈兘涓虹┖"}
-	}
-	if mp3File == "" {
-		return &bhomeclient.Reply{Msg: "闊抽鏂囦欢涓嶈兘涓虹┖"}
-	}
-	b := false
-	var err error
-	v := models.Voice{
-		Name: name,
-		Path: mp3File,
-	}
-
-	dbMsg := protomsg.DbChangeMessage{
-		Table: protomsg.TableChanged_T_Voice,
-	}
-
-	if id == "" { //鏂板
-		v.Id = uuid.NewV4().String()
-		b, err = v.Insert()
-
-		dbMsg.Action = protomsg.DbAction_Insert
-		dbMsg.Id = v.Id
-	} else { //鏇存柊
-		v.Id = id
-		b, err = v.Update()
-
-		dbMsg.Action = protomsg.DbAction_Update
-		dbMsg.Id = id
-	}
-
-	if err == nil {
-		pb, _ := json.Marshal(dbMsg)
-		h.Bk.Publish(service.ProcName, pb)
-		return &bhomeclient.Reply{Success: b, Msg: "淇濆瓨鎴愬姛"}
-	} else {
-		return &bhomeclient.Reply{Msg: err.Error()}
-	}
-}
-
-// @Summary 鍒犻櫎鎶ヨ澹伴煶
-// @Description 鍒犻櫎鎶ヨ澹伴煶
-// @Security ApiKeyAuth
-// @Produce json
-// @Tags 鎶ヨ澹伴煶
-// @Param id query string true "id"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/voice/del [delete]
-func (vc *VoiceController) Del(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
-	id := c.Query("id")
-	if id == "" {
-		return &bhomeclient.Reply{Msg: "id涓嶈兘涓虹┖"}
-	}
-	var v models.Voice
-	b, err := v.DeleteById(id)
-	if b {
-		dbMsg := protomsg.DbChangeMessage{
-			Table:  protomsg.TableChanged_T_Voice,
-			Id:     id,
-			Action: protomsg.DbAction_Delete,
-		}
-		pb, _ := json.Marshal(dbMsg)
-		h.Bk.Publish(service.ProcName, pb)
-		return &bhomeclient.Reply{Success: true, Msg: "鍒犻櫎鎴愬姛"}
-	} else {
-		return &bhomeclient.Reply{Msg: err.Error()}
-	}
-}
-
-// @Security ApiKeyAuth
-// @Summary 涓婁紶闊抽
-// @Description 涓婁紶闊抽
-// @Accept x-www-form-urlencoded
-// @Produce json
-// @Tags 鎶ヨ澹伴煶
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-v/voice/upload [post]
-func (vc *VoiceController) Upload(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
-	file, err := c.FormFile()
-	if err == nil {
-		var sv service.SysService
-		if file.Name == "" || len(file.Bytes) == 0 {
-			return &bhomeclient.Reply{Msg: "闊抽涓婁紶閿欒"}
-		}
-		filename := file.Name
-		audioPath, err := sv.UploadVoice(file.Bytes, filename)
-		if err != nil {
-			if err.Error() == "audio format error" {
-				return &bhomeclient.Reply{Msg: "澹伴煶鍙厑璁竚p3,wav,wma鐨勬牸寮�"}
-			} else {
-				return &bhomeclient.Reply{Msg: "澹伴煶涓婁紶澶辫触:" + err.Error()}
-			}
-		}
-		return &bhomeclient.Reply{Success: true, Data: audioPath}
-	}
-	return &bhomeclient.Reply{Msg: "鏈壘鍒颁笂浼犲0闊虫枃浠�"}
-}
+package controllers
+
+import (
+	"basic.com/pubsub/protomsg.git"
+	"basic.com/valib/bhomeclient.git"
+	"encoding/json"
+	"github.com/satori/go.uuid"
+	"vamicro/system-service/models"
+	"vamicro/system-service/service"
+)
+
+type VoiceController struct{}
+
+type VoiceMenu struct {
+	Id   string `json:"id"`
+	Name string `json:"name"`
+	Path string `json:"path"`
+}
+
+// @Summary 鏌ユ壘鎵�鏈夋姤璀﹀0闊�
+// @Description 鏌ユ壘鎵�鏈夋姤璀﹀0闊�
+// @Produce json
+// @Tags 鎶ヨ澹伴煶
+// @Success 200 {string} json "{"code":200, msg:"",data:"",success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"",data:"[]",success:false}"
+// @Router /data/api-v/voice/findAll [GET]
+func (vc *VoiceController) FindAll(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
+	var voiceMenus = make([]VoiceMenu, 0)
+	var voice models.Voice
+	voices, err := voice.FindAll()
+	//config.Server.Voices
+	if err == nil {
+		for _, v := range voices {
+			voiceMenus = append(voiceMenus, VoiceMenu{
+				Id:   v.Id,
+				Name: v.Name,
+				Path: v.Path,
+			})
+		}
+	}
+	return &bhomeclient.Reply{Success: true, Data: voiceMenus}
+}
+
+// @Summary 鑾峰彇鎶ヨ澹伴煶鍒楄〃
+// @Description 鑾峰彇鎶ヨ澹伴煶鍒楄〃
+// @Security ApiKeyAuth
+// @Produce json
+// @Tags 鎶ヨ澹伴煶
+// @Param id formData string false "id"
+// @Param name formData string true "鍚嶇О"
+// @Param mp3File formData string true "mp3鏂囦欢鍦板潃"
+// @Param g711aFile formData string true "g711a鏂囦欢鍦板潃"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/voice/add [post]
+func (vc *VoiceController) Add(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
+	id := c.PostForm("id")
+	name := c.PostForm("name")
+	mp3File := c.PostForm("mp3File")
+	//g711aFile := c.PostForm("g711aFile")
+	if name == "" {
+		return &bhomeclient.Reply{Msg: "name涓嶈兘涓虹┖"}
+	}
+	if mp3File == "" {
+		return &bhomeclient.Reply{Msg: "闊抽鏂囦欢涓嶈兘涓虹┖"}
+	}
+	b := false
+	var err error
+	v := models.Voice{
+		Name: name,
+		Path: mp3File,
+	}
+
+	dbMsg := protomsg.DbChangeMessage{
+		Table: protomsg.TableChanged_T_Voice,
+	}
+
+	if id == "" { //鏂板
+		v.Id = uuid.NewV4().String()
+		b, err = v.Insert()
+
+		dbMsg.Action = protomsg.DbAction_Insert
+		dbMsg.Id = v.Id
+	} else { //鏇存柊
+		v.Id = id
+		b, err = v.Update()
+
+		dbMsg.Action = protomsg.DbAction_Update
+		dbMsg.Id = id
+	}
+
+	if err == nil {
+		pb, _ := json.Marshal(dbMsg)
+		h.Bk.Publish(service.ProcName, pb)
+		return &bhomeclient.Reply{Success: b, Msg: "淇濆瓨鎴愬姛"}
+	} else {
+		return &bhomeclient.Reply{Msg: err.Error()}
+	}
+}
+
+// @Summary 鍒犻櫎鎶ヨ澹伴煶
+// @Description 鍒犻櫎鎶ヨ澹伴煶
+// @Security ApiKeyAuth
+// @Produce json
+// @Tags 鎶ヨ澹伴煶
+// @Param id query string true "id"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/voice/del [delete]
+func (vc *VoiceController) Del(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
+	id := c.Query("id")
+	if id == "" {
+		return &bhomeclient.Reply{Msg: "id涓嶈兘涓虹┖"}
+	}
+	var v models.Voice
+	b, err := v.DeleteById(id)
+	if b {
+		dbMsg := protomsg.DbChangeMessage{
+			Table:  protomsg.TableChanged_T_Voice,
+			Id:     id,
+			Action: protomsg.DbAction_Delete,
+		}
+		pb, _ := json.Marshal(dbMsg)
+		h.Bk.Publish(service.ProcName, pb)
+		return &bhomeclient.Reply{Success: true, Msg: "鍒犻櫎鎴愬姛"}
+	} else {
+		return &bhomeclient.Reply{Msg: err.Error()}
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 涓婁紶闊抽
+// @Description 涓婁紶闊抽
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鎶ヨ澹伴煶
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-v/voice/upload [post]
+func (vc *VoiceController) Upload(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
+	file, err := c.FormFile()
+	if err == nil {
+		var sv service.SysService
+		if file.Name == "" || len(file.Bytes) == 0 {
+			return &bhomeclient.Reply{Msg: "闊抽涓婁紶閿欒"}
+		}
+		filename := file.Name
+		audioPath, err := sv.UploadVoice(file.Bytes, filename)
+		if err != nil {
+			if err.Error() == "audio format error" {
+				return &bhomeclient.Reply{Msg: "澹伴煶鍙厑璁竚p3,wav,wma鐨勬牸寮�"}
+			} else {
+				return &bhomeclient.Reply{Msg: "澹伴煶涓婁紶澶辫触:" + err.Error()}
+			}
+		}
+		return &bhomeclient.Reply{Success: true, Data: audioPath}
+	}
+	return &bhomeclient.Reply{Msg: "鏈壘鍒颁笂浼犲0闊虫枃浠�"}
+}

--
Gitblit v1.8.0