sunty
2020-08-20 9d88c7c467f8d93af4aab9ba0b6d6c01c2ffc546
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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, "查询失败")
}