Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
4d06ad3e8b | |
|
52a81a404e | |
|
6cd06d86bc |
|
@ -15,13 +15,18 @@ var (
|
|||
|
||||
// standard error code ,start:110
|
||||
var (
|
||||
ErrEmpty = NewError(110, "Data Is Empty")
|
||||
ErrRequestParse = NewError(111, "Request Parse Fail")
|
||||
ErrRequestMust = NewError(112, "Request Params Required")
|
||||
ErrPermission = NewError(113, "Permission Denied")
|
||||
ErrJsonUnmarshal = NewError(114, "Json Unmarshal Fail")
|
||||
ErrJsonMarshal = NewError(115, "Json Marshal Fail")
|
||||
ErrInternal = NewError(116, "Internal Server Error")
|
||||
ErrEmpty = NewError(110, "Data Is Empty")
|
||||
ErrRequestParse = NewError(111, "Request Parse Fail")
|
||||
ErrRequestMust = NewError(112, "Request Params Required")
|
||||
ErrPermission = NewError(113, "Permission Denied")
|
||||
ErrJsonUnmarshal = NewError(114, "Json Unmarshal Fail")
|
||||
ErrJsonMarshal = NewError(115, "Json Marshal Fail")
|
||||
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
|
||||
|
|
|
@ -8,29 +8,29 @@ import (
|
|||
var Response Reply
|
||||
|
||||
type Reply struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data any `json:"data"`
|
||||
Code int32 `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Result any `json:"result"`
|
||||
}
|
||||
|
||||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||
reply.Code = 200
|
||||
reply.Data = data
|
||||
reply.Msg = ""
|
||||
reply.Code = 0
|
||||
reply.Result = data
|
||||
reply.Message = ""
|
||||
if data == nil {
|
||||
reply.Data = ""
|
||||
reply.Result = ""
|
||||
}
|
||||
ctx.JSON(200, reply)
|
||||
}
|
||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||
reply.Code = 500
|
||||
reply.Data = ""
|
||||
reply.Result = ""
|
||||
// Status code defaults to 500
|
||||
e, ok := status.FromError(err)
|
||||
if ok {
|
||||
reply.Code = int(e.Code())
|
||||
reply.Code = int32(e.Code())
|
||||
}
|
||||
reply.Msg = e.Message()
|
||||
reply.Message = e.Message()
|
||||
|
||||
// Send error
|
||||
ctx.JSON(200, reply)
|
||||
|
|
10
types/db.go
10
types/db.go
|
@ -51,7 +51,13 @@ type (
|
|||
// standard PassportID,PassportIdentity definition.
|
||||
Std_Passport struct {
|
||||
PassportID uint `gorm:"column:passport_id;Index;" json:"passport_id"`
|
||||
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为ULID
|
||||
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为UUID
|
||||
}
|
||||
|
||||
// standard OwnerID,OwnerIdentity definition.
|
||||
Std_Owner struct {
|
||||
OwnerID uint `gorm:"column:owner_id;Index;" json:"owner_id"`
|
||||
OwnerIdentity string `gorm:"column:owner_identity;type:varchar(36);Index;" json:"owner_identity"` // 用户唯一标识,24位NanoID,36位为UUID
|
||||
}
|
||||
|
||||
// standard ID definition.
|
||||
|
@ -61,7 +67,7 @@ type (
|
|||
|
||||
// standard Identity definition.
|
||||
Std_Identity struct {
|
||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为UUID
|
||||
}
|
||||
|
||||
// standard Status definition.
|
||||
|
|
Loading…
Reference in New Issue