forked from ebhomengo/niki
1
0
Fork 0

fix(niki): refactor `replace pkg/slice with std/slices`

This commit is contained in:
Iman Mirazimi 2024-07-13 23:13:55 +03:30
parent 4eadf98c2e
commit caf564d474
2 changed files with 3 additions and 18 deletions

View File

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

View File

@ -1,12 +1,12 @@
package mysqladmin package mysqladmin
import ( import (
"slices"
"time" "time"
"git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/entity"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
"git.gocasts.ir/ebhomengo/niki/pkg/slice"
"git.gocasts.ir/ebhomengo/niki/repository/mysql" "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 // merge ACLs by permission
adminPermissions := make([]entity.AdminPermission, 0) adminPermissions := make([]entity.AdminPermission, 0)
for _, r := range adminRoleACL { for _, r := range adminRoleACL {
if !slice.DoesExist(adminPermissions, r.Permission) { if !slices.Contains(adminPermissions, r.Permission) {
adminPermissions = append(adminPermissions, r.Permission) adminPermissions = append(adminPermissions, r.Permission)
} }
} }
for _, a := range adminACL { for _, a := range adminACL {
if !slice.DoesExist(adminPermissions, a.Permission) { if !slices.Contains(adminPermissions, a.Permission) {
adminPermissions = append(adminPermissions, a.Permission) adminPermissions = append(adminPermissions, a.Permission)
} }
} }