feat: Users API, ownership transfer and removal of the legacy role string
This commit is contained in:
1 parent
094df63a7f
commit
80f7037d3a
124 files changed
+4644
-824
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"RenewCMS/internal/domain/invite"
|
||||
"RenewCMS/internal/domain/role"
|
||||
)
|
||||
|
||||
type InviteView struct {
|
||||
invite.Invite
|
||||
Role RoleRef
|
||||
}
|
||||
|
||||
type RoleRef struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
BuiltIn bool `json:"built_in"`
|
||||
Locked bool `json:"locked"`
|
||||
}
|
||||
|
||||
func NewRoleRef(found role.Role) RoleRef {
|
||||
return RoleRef{ID: found.ID, Name: found.Name, BuiltIn: found.BuiltIn, Locked: found.Locked}
|
||||
}
|
||||
|
||||
func roleRefsByID(roles role.Repository) (map[uint32]RoleRef, error) {
|
||||
listed, err := roles.List()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
refs := make(map[uint32]RoleRef, len(listed))
|
||||
for _, found := range listed {
|
||||
refs[found.ID] = NewRoleRef(found)
|
||||
}
|
||||
return refs, nil
|
||||
}
|
||||
|
||||
func lookupRoleRef(refs map[uint32]RoleRef, id uint32) *RoleRef {
|
||||
ref, known := refs[id]
|
||||
if !known {
|
||||
return nil
|
||||
}
|
||||
return &ref
|
||||
}
|
||||
Reference in new issue
Block a user