Fix 200 response exception builder
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
common:
|
common:
|
||||||
|
success: "00000"
|
||||||
error:
|
error:
|
||||||
invalid_input: "00001"
|
invalid_input: "00001"
|
||||||
unauthorized: "00002"
|
unauthorized: "00002"
|
||||||
|
|||||||
@@ -113,5 +113,12 @@ func Exchange(c *gin.Context) {
|
|||||||
RedirectUri string `json:"redirect_uri"`
|
RedirectUri string `json:"redirect_uri"`
|
||||||
}{url.String()}
|
}{url.String()}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", exchangeResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusSuccess).
|
||||||
|
SetService(exception.ServiceAuth).
|
||||||
|
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, exchangeResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,5 +118,12 @@ func Magic(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "magic link sent")
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceAuth).
|
||||||
|
SetEndpoint(exception.EndpointAuthServiceMagic).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,5 +64,12 @@ func Refresh(c *gin.Context) {
|
|||||||
RefreshToken string `json:"refresh_token"`
|
RefreshToken string `json:"refresh_token"`
|
||||||
}{accessToken, refreshToken}
|
}{accessToken, refreshToken}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", tokenResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceAuth).
|
||||||
|
SetEndpoint(exception.EndpointAuthServiceRefresh).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, tokenResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,5 +83,12 @@ func Token(c *gin.Context) {
|
|||||||
RefreshToken string `json:"refresh_token"`
|
RefreshToken string `json:"refresh_token"`
|
||||||
}{accessToken, refreshToken}
|
}{accessToken, refreshToken}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", tokenResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceAuth).
|
||||||
|
SetEndpoint(exception.EndpointAuthServiceToken).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, tokenResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,5 +196,12 @@ func CheckinQuery(c *gin.Context) {
|
|||||||
CheckinAt time.Time `json:"checkin_at"`
|
CheckinAt time.Time `json:"checkin_at"`
|
||||||
}{attendance.CheckinAt}
|
}{attendance.CheckinAt}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", checkInAtResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusUser).
|
||||||
|
SetService(exception.ServiceEvent).
|
||||||
|
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, checkInAtResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,5 +60,12 @@ func Info(c *gin.Context) {
|
|||||||
EndTime time.Time `json:"end_time"`
|
EndTime time.Time `json:"end_time"`
|
||||||
}{event.Name, event.StartTime, event.EndTime}
|
}{event.Name, event.StartTime, event.EndTime}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", eventInfoResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusUser).
|
||||||
|
SetService(exception.ServiceEvent).
|
||||||
|
SetEndpoint(exception.EndpointEventServiceInfo).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, eventInfoResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,5 +67,12 @@ func Full(c *gin.Context) {
|
|||||||
userFullResp := struct {
|
userFullResp := struct {
|
||||||
UserTable *[]data.User `json:"user_table"`
|
UserTable *[]data.User `json:"user_table"`
|
||||||
}{users}
|
}{users}
|
||||||
utils.HttpResponse(c, 200, "", "success", userFullResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceUser).
|
||||||
|
SetEndpoint(exception.EndpointUserServiceFull).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, userFullResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,5 +63,12 @@ func Info(c *gin.Context) {
|
|||||||
PermissionLevel uint `json:"permission_level"`
|
PermissionLevel uint `json:"permission_level"`
|
||||||
}{user.UserId, user.Email, user.Username, user.Nickname, user.Subtitle, user.Avatar, user.Bio, user.PermissionLevel}
|
}{user.UserId, user.Email, user.Username, user.Nickname, user.Subtitle, user.Avatar, user.Bio, user.PermissionLevel}
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success", userInfoResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusUser).
|
||||||
|
SetService(exception.ServiceUser).
|
||||||
|
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, userInfoResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,5 +73,12 @@ func List(c *gin.Context) {
|
|||||||
userListResp := struct {
|
userListResp := struct {
|
||||||
List *[]data.UserSearchDoc `json:"list"`
|
List *[]data.UserSearchDoc `json:"list"`
|
||||||
}{list}
|
}{list}
|
||||||
utils.HttpResponse(c, 200, "", "success", userListResp)
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceUser).
|
||||||
|
SetEndpoint(exception.EndpointUserServiceList).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode, userListResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,5 +159,12 @@ func Update(c *gin.Context) {
|
|||||||
// Update user info
|
// Update user info
|
||||||
userData.UpdateByUserID(userId)
|
userData.UpdateByUserID(userId)
|
||||||
|
|
||||||
utils.HttpResponse(c, 200, "", "success")
|
errorCode := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusUser).
|
||||||
|
SetService(exception.ServiceUser).
|
||||||
|
SetEndpoint(exception.EndpointUserServiceUpdate).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonSuccess).
|
||||||
|
Build()
|
||||||
|
utils.HttpResponse(c, 200, errorCode)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user