30 lines
532 B
Go
30 lines
532 B
Go
package response
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
"net/http"
|
|
)
|
|
|
|
type Body struct {
|
|
Code string `json:"retCode"`
|
|
Data interface{} `json:"apiResult"`
|
|
Msg string `json:"retMsg"`
|
|
}
|
|
|
|
func Err(w http.ResponseWriter, code string, msg string) {
|
|
httpx.OkJson(w, Body{
|
|
Code: code,
|
|
Data: nil,
|
|
Msg: fmt.Sprintf("%s:%s", CodeMsg[code], msg),
|
|
})
|
|
}
|
|
|
|
func Suc(w http.ResponseWriter, code string, data interface{}) {
|
|
httpx.OkJson(w, Body{
|
|
Code: code,
|
|
Data: data,
|
|
Msg: "发送成功",
|
|
})
|
|
}
|