Modificato in una REST API con Flask

This commit is contained in:
Fabio Scotto di Santolo
2021-06-20 15:08:59 +02:00
parent 2e1b532e5c
commit cf9ab44d5d
7 changed files with 275 additions and 33 deletions

View File

@@ -19,5 +19,12 @@ class Department:
def location_id(self) -> Location:
return self.__location
def to_json(self):
return {
'department_id': self.__department_id,
'name': self.__name,
'location': self.__location.to_json() if self.__location is not None else None
}
def __str__(self):
return f"Department({self.__department_id}, {self.__name}, {self.__location})"