You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package lista_utenti
|
|
|
|
import (
|
|
"git.phc.dm.unipi.it/phc/website/auth"
|
|
"git.phc.dm.unipi.it/phc/website/model"
|
|
"git.phc.dm.unipi.it/phc/website/util"
|
|
)
|
|
|
|
type authListaUtenti struct {
|
|
AuthService auth.Service
|
|
|
|
Macchinisti util.Set[string]
|
|
Rappresentanti util.Set[string]
|
|
}
|
|
|
|
func newAuthListaUtenti(authService auth.Service) (Service, error) {
|
|
macchinisti, err := loadMacchinisti()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
rappresentanti, err := loadRappresentanti()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &authListaUtenti{authService, macchinisti, rappresentanti}, nil
|
|
}
|
|
|
|
func (a *authListaUtenti) GetUtenti() ([]*model.ListUser, error) {
|
|
authUsers, err := a.AuthService.GetUsers()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
users := make([]*model.ListUser, 0, len(authUsers))
|
|
for _, u := range authUsers {
|
|
users = append(users, &model.ListUser{
|
|
Uid: u.Username,
|
|
Nome: u.Name,
|
|
Cognome: u.Surname,
|
|
Tags: []string{},
|
|
})
|
|
}
|
|
|
|
mergeMacchinisti(users, a.Macchinisti)
|
|
mergeRappresentanti(users, a.Rappresentanti)
|
|
|
|
return users, nil
|
|
}
|