33 lines
584 B
Go
33 lines
584 B
Go
package response
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
const (
|
|
NeedLogin = "6018" // 登陆过期
|
|
|
|
)
|
|
|
|
type Response struct {
|
|
Code string
|
|
Result interface{}
|
|
Msg string
|
|
}
|
|
|
|
func Fail(msg string) BaseResponse {
|
|
response := BaseResponse{Code: ErrorCode, Msg: msg}
|
|
return response
|
|
}
|
|
|
|
func Invalid() string {
|
|
response := BaseResponse{Code: NeedLogin, Msg: "用户身份已过期,请重新登录!"}
|
|
str, _ := json.Marshal(response)
|
|
return string(str)
|
|
}
|
|
|
|
func Success(Result interface{}) BaseResponse {
|
|
response := BaseResponse{Code: SuccessCode, Result: Result}
|
|
return response
|
|
}
|