First merge from develop to main (WIP) #7

Merged
sugar merged 199 commits from develop into main 2026-01-27 17:47:07 +00:00
5 changed files with 53 additions and 52 deletions
Showing only changes of commit 585ec46282 - Show all commits

View File

@@ -1,4 +1,5 @@
middleware: middleware:
service:
gin_logger: "901" gin_logger: "901"
jwt: "902" jwt: "902"
permission: "903" permission: "903"

View File

@@ -12,10 +12,10 @@ func ApiVersionCheck() gin.HandlerFunc {
apiVersion := c.GetHeader("X-Api-Version") apiVersion := c.GetHeader("X-Api-Version")
if apiVersion == "" { if apiVersion == "" {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.MiddlewareApiVersionService). SetService(exception.MiddlewareServiceApiVersion).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeSpecific). SetType(exception.TypeSpecific).
SetOriginal(exception.ApiVersionNotFound). SetOriginal(exception.ApiVersionNotFound).
Build() Build()
utils.HttpAbort(c, 400, errorCode) utils.HttpAbort(c, 400, errorCode)

View File

@@ -17,10 +17,10 @@ func JWTAuth() gin.HandlerFunc {
uid, err := authtoken.HeaderVerify(auth) uid, err := authtoken.HeaderVerify(auth)
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.MiddlewareJwtService). SetService(exception.MiddlewareServiceJwt).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeSpecific). SetType(exception.TypeSpecific).
SetOriginal(exception.CommonErrorUnauthorized). SetOriginal(exception.CommonErrorUnauthorized).
Build() Build()

View File

@@ -17,10 +17,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
userIdOrig, ok := c.Get("user_id") userIdOrig, ok := c.Get("user_id")
if !ok || userIdOrig.(string) == "" { if !ok || userIdOrig.(string) == "" {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser). SetStatus(exception.StatusUser).
SetService(exception.MiddlewarePermissionService). SetService(exception.MiddlewareServicePermission).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorMissingUserId). SetOriginal(exception.CommonErrorMissingUserId).
Build() Build()
utils.HttpAbort(c, 401, errorCode) utils.HttpAbort(c, 401, errorCode)
@@ -30,10 +30,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
userId, err := uuid.Parse(userIdOrig.(string)) userId, err := uuid.Parse(userIdOrig.(string))
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.MiddlewarePermissionService). SetService(exception.MiddlewareServicePermission).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed). SetOriginal(exception.CommonErrorUuidParseFailed).
Build() Build()
utils.HttpAbort(c, 500, errorCode) utils.HttpAbort(c, 500, errorCode)
@@ -43,10 +43,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
userData, err := new(data.User).GetByUserId(userId) userData, err := new(data.User).GetByUserId(userId)
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser). SetStatus(exception.StatusUser).
SetService(exception.MiddlewarePermissionService). SetService(exception.MiddlewareServicePermission).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUserNotFound). SetOriginal(exception.CommonErrorUserNotFound).
Build() Build()
utils.HttpAbort(c, 404, errorCode) utils.HttpAbort(c, 404, errorCode)
@@ -61,10 +61,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
if permissionLevel < requiredLevel { if permissionLevel < requiredLevel {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser). SetStatus(exception.StatusUser).
SetService(exception.MiddlewarePermissionService). SetService(exception.MiddlewareServicePermission).
SetEndpoint(exception.MiddlewareEndpoint). SetEndpoint(exception.EndpointMiddlewareService).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorPermissionDenied). SetOriginal(exception.CommonErrorPermissionDenied).
Build() Build()
utils.HttpAbort(c, 403, errorCode) utils.HttpAbort(c, 403, errorCode)

View File

@@ -25,10 +25,10 @@ func Exchange(c *gin.Context) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient). SetStatus(exception.StatusClient).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput). SetOriginal(exception.CommonErrorInvalidInput).
Build() Build()
utils.HttpResponse(c, 400, errorCode) utils.HttpResponse(c, 400, errorCode)
@@ -38,10 +38,10 @@ func Exchange(c *gin.Context) {
userIdOrig, ok := c.Get("user_id") userIdOrig, ok := c.Get("user_id")
if !ok { if !ok {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient). SetStatus(exception.StatusClient).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUnauthorized). SetOriginal(exception.CommonErrorUnauthorized).
Build() Build()
utils.HttpResponse(c, 401, errorCode) utils.HttpResponse(c, 401, errorCode)
@@ -51,10 +51,10 @@ func Exchange(c *gin.Context) {
userId, err := uuid.Parse(userIdOrig.(string)) userId, err := uuid.Parse(userIdOrig.(string))
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeCommon). SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed). SetOriginal(exception.CommonErrorUuidParseFailed).
Build() Build()
utils.HttpResponse(c, 500, errorCode) utils.HttpResponse(c, 500, errorCode)
@@ -65,10 +65,10 @@ func Exchange(c *gin.Context) {
user, err := userData.GetByUserId(userId) user, err := userData.GetByUserId(userId)
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeSpecific). SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeGetUserIdFailed). SetOriginal(exception.AuthExchangeGetUserIdFailed).
Build() Build()
utils.HttpResponse(c, 500, errorCode) utils.HttpResponse(c, 500, errorCode)
@@ -78,10 +78,10 @@ func Exchange(c *gin.Context) {
code, err := authcode.NewAuthCode(exchangeReq.ClientId, user.Email) code, err := authcode.NewAuthCode(exchangeReq.ClientId, user.Email)
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer). SetStatus(exception.StatusServer).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeSpecific). SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeCodeGenFailed). SetOriginal(exception.AuthExchangeCodeGenFailed).
Build() Build()
utils.HttpResponse(c, 500, errorCode) utils.HttpResponse(c, 500, errorCode)
@@ -91,10 +91,10 @@ func Exchange(c *gin.Context) {
url, err := url.Parse(exchangeReq.RedirectUri) url, err := url.Parse(exchangeReq.RedirectUri)
if err != nil { if err != nil {
errorCode := new(exception.Builder). errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient). SetStatus(exception.StatusClient).
SetService(exception.AuthService). SetService(exception.ServiceAuth).
SetEndpoint(exception.AuthExchangeEndpoint). SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.ErrorTypeSpecific). SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeInvalidRedirectUri). SetOriginal(exception.AuthExchangeInvalidRedirectUri).
Build() Build()
utils.HttpResponse(c, 400, errorCode) utils.HttpResponse(c, 400, errorCode)