liuxiaolong
2020-07-13 468a696bf67400c69f0ece6c35663df51f950ba8
add voice
1个文件已添加
40 ■■■■■ 已修改文件
controllers/voice.go 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/voice.go
New file
@@ -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, "查询失败")
}