Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
4d06ad3e8b | |
|
52a81a404e |
|
@ -22,6 +22,11 @@ var (
|
||||||
ErrJsonUnmarshal = NewError(114, "Json Unmarshal Fail")
|
ErrJsonUnmarshal = NewError(114, "Json Unmarshal Fail")
|
||||||
ErrJsonMarshal = NewError(115, "Json Marshal Fail")
|
ErrJsonMarshal = NewError(115, "Json Marshal Fail")
|
||||||
ErrInternal = NewError(116, "Internal Server Error")
|
ErrInternal = NewError(116, "Internal Server Error")
|
||||||
|
ErrPassword = NewError(117, "Password Incorrect")
|
||||||
|
ErrAccountNotFound = NewError(118, "Account Not Found")
|
||||||
|
ErrAccountDisabled = NewError(119, "Account Disabled")
|
||||||
|
ErrDisabled = NewError(120, "Status Disabled")
|
||||||
|
ErrRecordNotFound = NewError(121, "Record Not Found")
|
||||||
)
|
)
|
||||||
|
|
||||||
// jwt error code ,start:130
|
// jwt error code ,start:130
|
||||||
|
|
|
@ -8,29 +8,29 @@ import (
|
||||||
var Response Reply
|
var Response Reply
|
||||||
|
|
||||||
type Reply struct {
|
type Reply struct {
|
||||||
Code int `json:"code"`
|
Code int32 `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Message string `json:"message"`
|
||||||
Data any `json:"data"`
|
Result any `json:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||||
reply.Code = 200
|
reply.Code = 0
|
||||||
reply.Data = data
|
reply.Result = data
|
||||||
reply.Msg = ""
|
reply.Message = ""
|
||||||
if data == nil {
|
if data == nil {
|
||||||
reply.Data = ""
|
reply.Result = ""
|
||||||
}
|
}
|
||||||
ctx.JSON(200, reply)
|
ctx.JSON(200, reply)
|
||||||
}
|
}
|
||||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||||
reply.Code = 500
|
reply.Code = 500
|
||||||
reply.Data = ""
|
reply.Result = ""
|
||||||
// Status code defaults to 500
|
// Status code defaults to 500
|
||||||
e, ok := status.FromError(err)
|
e, ok := status.FromError(err)
|
||||||
if ok {
|
if ok {
|
||||||
reply.Code = int(e.Code())
|
reply.Code = int32(e.Code())
|
||||||
}
|
}
|
||||||
reply.Msg = e.Message()
|
reply.Message = e.Message()
|
||||||
|
|
||||||
// Send error
|
// Send error
|
||||||
ctx.JSON(200, reply)
|
ctx.JSON(200, reply)
|
||||||
|
|
Loading…
Reference in New Issue