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 --- controllers/voice.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/controllers/voice.go b/controllers/voice.go new file mode 100644 index 0000000..cb2160d --- /dev/null +++ b/controllers/voice.go @@ -0,0 +1,40 @@ +package controllers + +import ( + "basic.com/dbapi.git" + "basic.com/pubsub/protomsg.git" + "bytes" + "encoding/json" + "github.com/gin-gonic/gin" + "webserver/extend/code" + "webserver/extend/util" +) + +type VoiceController struct { + +} + + +func (vc VoiceController) FindAll(c *gin.Context) { + var api dbapi.VoiceApi + b, list := api.FindAll() + if b { + var pd protomsg.VoiceList + if list != nil { + for idx, _ := range list { + pd.List = append(pd.List, &list[idx]) + } + } + var _buffer bytes.Buffer + err := jsonpbMarshaler.Marshal(&_buffer, &pd) + if err == nil { + jsonB := _buffer.Bytes() + var m map[string]interface{} + json.Unmarshal(jsonB, &m) + util.ResponseFormat(c,code.Success, m) + return + } + } + + util.ResponseFormat(c, code.ComError, "鏌ヨ澶辫触") +} \ No newline at end of file -- Gitblit v1.8.0