mirror of https://github.com/sunface/rust-course
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
569 B
35 lines
569 B
4 years ago
|
package common
|
||
|
|
||
|
import "github.com/imdotdev/im.dev/server/pkg/errcode"
|
||
|
|
||
|
type Resp struct {
|
||
|
Status string `json:"status"`
|
||
|
Data interface{} `json:"data,omitempty"`
|
||
|
Message string `json:"message,omitempty"`
|
||
|
}
|
||
|
|
||
|
func RespSuccess(data interface{}) *Resp {
|
||
|
r := &Resp{}
|
||
|
r.Status = Success
|
||
|
r.Data = data
|
||
|
|
||
|
return r
|
||
|
}
|
||
|
|
||
|
func RespError(data interface{}, msg string) *Resp {
|
||
|
r := &Resp{}
|
||
|
r.Status = Error
|
||
|
r.Data = data
|
||
|
r.Message = msg
|
||
|
|
||
|
return r
|
||
|
}
|
||
|
|
||
|
func RespInternalError() *Resp {
|
||
|
r := &Resp{}
|
||
|
r.Status = Error
|
||
|
r.Message = errcode.Internal
|
||
|
|
||
|
return r
|
||
|
}
|