nquest/api/mapper.go

39 lines
864 B
Go
Raw Normal View History

2023-11-01 23:21:12 +03:00
package api
import "gitrepo.ru/neonxp/nquest/pkg/models"
var MapTeamRole = map[models.Role]UserTeamRole{
2023-11-01 23:21:12 +03:00
models.Captain: Captain,
models.Member: Member,
}
var MapTeamRoleReverse = map[UserTeamRole]models.Role{
Captain: models.Captain,
Member: models.Member,
}
var MapUserRole = map[models.UserRole]UserRole{
models.RoleNotVerified: NotVerified,
models.RoleUser: User,
models.RoleCreator: Creator,
models.RoleAdmin: Admin,
}
var MapUserRoleReverse = map[UserRole]models.UserRole{
NotVerified: models.RoleNotVerified,
User: models.RoleUser,
Creator: models.RoleCreator,
Admin: models.RoleAdmin,
}
2023-11-01 23:21:12 +03:00
func MapUserTeam(team *models.TeamMember) *UserTeam {
if team == nil || team.Team == nil {
return nil
}
return &UserTeam{
Id: int(team.Team.ID),
Name: team.Team.Name,
Role: MapTeamRole[team.Role],
2023-11-01 23:21:12 +03:00
}
}