97d4f0845d
- resolving role name
17 lines
405 B
Python
17 lines
405 B
Python
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()
|