dashboard/areas/roles/role_service.py

18 lines
405 B
Python
Raw Normal View History

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]
@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()