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) } }