2022-04-14 13:32:35 +02:00
|
|
|
from .models import Role
|
|
|
|
|
|
|
|
|
|
|
|
class RoleService:
|
|
|
|
@staticmethod
|
|
|
|
def get_roles():
|
|
|
|
roles = Role.query.all()
|
|
|
|
return [{"id": r.id, "name": r.name} for r in roles]
|
2022-05-18 20:58:00 +02:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_role_by_id(role_id):
|
|
|
|
if role_id is None:
|
|
|
|
role = Role()
|
|
|
|
role.name = 'user'
|
|
|
|
return role
|
|
|
|
|
|
|
|
return Role.query.filter_by(id=role_id).first()
|