-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust roles and permission acl lists
- Loading branch information
1 parent
f714c5f
commit efcd810
Showing
8 changed files
with
116 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
services/auth/internal/delivery/http/delivery/acl/get_all_permission.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package acl_handler | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/febrihidayan/go-architecture-monorepo/pkg/exceptions" | ||
"github.com/febrihidayan/go-architecture-monorepo/pkg/utils" | ||
"github.com/febrihidayan/go-architecture-monorepo/services/auth/internal/delivery/http/response" | ||
) | ||
|
||
func (x *aclHttpHandler) GetAllPermission(w http.ResponseWriter, r *http.Request) { | ||
var ( | ||
ctx = context.Background() | ||
) | ||
|
||
results, err := x.aclUsecase.GetAllPermission(ctx) | ||
if err != nil { | ||
utils.RespondWithError(w, exceptions.MapToHttpStatusCode(err.Status), err.Errors.Errors) | ||
return | ||
} | ||
|
||
utils.RespondWithJSON(w, http.StatusOK, response.MapPermissionListResponses(results)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package acl | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/febrihidayan/go-architecture-monorepo/pkg/exceptions" | ||
"github.com/febrihidayan/go-architecture-monorepo/services/auth/domain/entities" | ||
"github.com/hashicorp/go-multierror" | ||
) | ||
|
||
func (x *aclInteractor) GetAllPermission(ctx context.Context) ([]*entities.Permission, *exceptions.CustomError) { | ||
var multilerr *multierror.Error | ||
|
||
permissions, err := x.permissionRepo.All(ctx) | ||
if err != nil { | ||
log.Println("GetAllPermission::error#1:", err) | ||
multilerr = multierror.Append(multilerr, err) | ||
return nil, &exceptions.CustomError{ | ||
Status: exceptions.ERRREPOSITORY, | ||
Errors: multilerr, | ||
} | ||
} | ||
|
||
log.Println("GetAllPermission::success#1:", "successfully") | ||
|
||
return permissions, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package acl | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/febrihidayan/go-architecture-monorepo/pkg/exceptions" | ||
"github.com/febrihidayan/go-architecture-monorepo/services/auth/domain/entities" | ||
"github.com/hashicorp/go-multierror" | ||
) | ||
|
||
func (x *aclInteractor) GetAllRole(ctx context.Context) ([]*entities.Role, *exceptions.CustomError) { | ||
var multilerr *multierror.Error | ||
|
||
roles, err := x.roleRepo.All(ctx) | ||
if err != nil { | ||
log.Println("GetAllRole::error#1:", err) | ||
multilerr = multierror.Append(multilerr, err) | ||
return nil, &exceptions.CustomError{ | ||
Status: exceptions.ERRREPOSITORY, | ||
Errors: multilerr, | ||
} | ||
} | ||
|
||
log.Println("GetAllRole::success#1:", "successfully") | ||
|
||
return roles, nil | ||
} |