generated from pkg/go-template
37 lines
641 B
Go
37 lines
641 B
Go
package handler
|
|
|
|
const (
|
|
ResponseCodeSuccess = 0
|
|
ResponseCodeFail = -1
|
|
ResponseSuccess = "success"
|
|
ResponseFail = "fail"
|
|
)
|
|
|
|
type (
|
|
Response struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data *Data `json:"data,omitempty"`
|
|
}
|
|
Data struct {
|
|
Elements interface{} `json:"elements"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
)
|
|
|
|
func fail(data *Data) Response {
|
|
return Response{
|
|
Code: ResponseCodeFail,
|
|
Message: ResponseFail,
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
func success(data *Data) Response {
|
|
return Response{
|
|
Code: ResponseCodeSuccess,
|
|
Message: ResponseSuccess,
|
|
Data: data,
|
|
}
|
|
}
|