From caf564d474b20f187dd71e9e33ff4cc05e156bcc Mon Sep 17 00:00:00 2001 From: Iman Mirazimi Date: Sat, 13 Jul 2024 23:13:55 +0330 Subject: [PATCH] fix(niki): refactor `replace pkg/slice with std/slices` --- pkg/slice/admin_permission.go | 15 --------------- repository/mysql/admin/authorization.go | 6 +++--- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 pkg/slice/admin_permission.go diff --git a/pkg/slice/admin_permission.go b/pkg/slice/admin_permission.go deleted file mode 100644 index aac3d86..0000000 --- a/pkg/slice/admin_permission.go +++ /dev/null @@ -1,15 +0,0 @@ -package slice - -import ( - "git.gocasts.ir/ebhomengo/niki/entity" -) - -func DoesExist(list []entity.AdminPermission, value entity.AdminPermission) bool { - for _, item := range list { - if item == value { - return true - } - } - - return false -} diff --git a/repository/mysql/admin/authorization.go b/repository/mysql/admin/authorization.go index cf8ff8f..c4daccd 100644 --- a/repository/mysql/admin/authorization.go +++ b/repository/mysql/admin/authorization.go @@ -1,12 +1,12 @@ package mysqladmin import ( + "slices" "time" "git.gocasts.ir/ebhomengo/niki/entity" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" - "git.gocasts.ir/ebhomengo/niki/pkg/slice" "git.gocasts.ir/ebhomengo/niki/repository/mysql" ) @@ -70,12 +70,12 @@ func (d *DB) GetAdminPermissions(adminID uint, role entity.AdminRole) ([]entity. // merge ACLs by permission adminPermissions := make([]entity.AdminPermission, 0) for _, r := range adminRoleACL { - if !slice.DoesExist(adminPermissions, r.Permission) { + if !slices.Contains(adminPermissions, r.Permission) { adminPermissions = append(adminPermissions, r.Permission) } } for _, a := range adminACL { - if !slice.DoesExist(adminPermissions, a.Permission) { + if !slices.Contains(adminPermissions, a.Permission) { adminPermissions = append(adminPermissions, a.Permission) } }