-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d649d1d
commit 59adfc9
Showing
21 changed files
with
501 additions
and
199 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
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 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 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 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,46 @@ | ||
package models | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ryanfaerman/netctl/internal/dao" | ||
"github.com/ryanfaerman/netctl/internal/models/finders" | ||
) | ||
|
||
func (m Role) Find(ctx context.Context, queries finders.QuerySet) (any, error) { | ||
var ( | ||
raw dao.Role | ||
raws []dao.Role | ||
err error | ||
found []*Role | ||
) | ||
switch { | ||
default: | ||
return nil, finders.ErrInvalidWhere | ||
case queries.HasWhere("id"): | ||
id, ok := finders.EnforceValue[int64](queries, "id") | ||
if ok != nil { | ||
return nil, ok | ||
} | ||
|
||
raw, err = global.dao.GetRole(ctx, id) | ||
raws = append(raws, raw) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
found = make([]*Role, len(raws)) | ||
|
||
for i, raw := range raws { | ||
found[i] = &Role{ | ||
ID: raw.ID, | ||
Name: raw.Name, | ||
Permissions: Permission(raw.Permissions), | ||
Ranking: raw.Ranking, | ||
} | ||
} | ||
|
||
return found, nil | ||
} |
Oops, something went wrong.