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, "查询失败")
|
}
|