mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-06 20:50:17 -04:00
Fix all Service and Service Tag typos and import entities to init
This commit is contained in:
parent
d9ae511deb
commit
ea8c60f271
|
@ -1,2 +1,9 @@
|
|||
from .entity_base import EntityBase
|
||||
from .sample_entity import SampleEntity
|
||||
from .tag_entity import TagEntity
|
||||
from .user_entity import UserEntity
|
||||
from .resource_entity import ResourceEntity
|
||||
from .resource_tag_entity import ResourceTagEntity
|
||||
from .service_entity import ServiceEntity
|
||||
from .service_tag_entity import ServiceTagEntity
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class ProgramEnum(enum.Enum):
|
|||
COMMUNITY = "COMMUNITY"
|
||||
|
||||
|
||||
class ResourceEntity(EntityBase):
|
||||
class ServiceEntity(EntityBase):
|
||||
|
||||
#set table name
|
||||
__tablename__ = "service"
|
||||
|
|
|
@ -10,7 +10,7 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|||
from .entity_base import EntityBase
|
||||
|
||||
|
||||
class ResourceTagEntity(EntityBase):
|
||||
class ServiceTagEntity(EntityBase):
|
||||
|
||||
# set table name to user in the database
|
||||
__tablename__ = "serviceTag"
|
||||
|
|
|
@ -26,33 +26,37 @@ class TagEntity(EntityBase):
|
|||
resourceTags: Mapped[list["ResourceTagEntity"]] = relationship(back_populates="tag", cascade="all,delete")
|
||||
serviceTags: Mapped[list["ServiceTagEntity"]] = relationship(back_populates="tag", cascade="all,delete")
|
||||
|
||||
|
||||
"""
|
||||
@classmethod
|
||||
def from_model(cls, model: Tag) -> Self:
|
||||
"""
|
||||
|
||||
Create a user entity from model
|
||||
|
||||
Args: model (User): the model to create the entity from
|
||||
|
||||
Returns:
|
||||
self: The entity
|
||||
"""
|
||||
|
||||
|
||||
|
||||
return cls(
|
||||
id=model.id,
|
||||
content=model.id,
|
||||
)
|
||||
|
||||
def to_model(self) -> Tag:
|
||||
"""
|
||||
|
||||
Create a user model from entity
|
||||
|
||||
Returns:
|
||||
User: A User model for API usage
|
||||
"""
|
||||
|
||||
|
||||
return Tag(
|
||||
id=self.id,
|
||||
content=self.id,
|
||||
)
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
@ -56,16 +56,17 @@ class UserEntity(EntityBase):
|
|||
experience: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
group: Mapped[str] = mapped_column(String(50))
|
||||
|
||||
"""
|
||||
@classmethod
|
||||
def from_model(cls, model: User) -> Self:
|
||||
"""
|
||||
|
||||
Create a user entity from model
|
||||
|
||||
Args: model (User): the model to create the entity from
|
||||
|
||||
Returns:
|
||||
self: The entity
|
||||
"""
|
||||
|
||||
|
||||
return cls(
|
||||
id=model.id,
|
||||
|
@ -78,12 +79,12 @@ class UserEntity(EntityBase):
|
|||
)
|
||||
|
||||
def to_model(self) -> User:
|
||||
"""
|
||||
|
||||
Create a user model from entity
|
||||
|
||||
Returns:
|
||||
User: A User model for API usage
|
||||
"""
|
||||
|
||||
|
||||
return User(
|
||||
id=self.id,
|
||||
|
@ -94,3 +95,4 @@ class UserEntity(EntityBase):
|
|||
experience=self.experience,
|
||||
group=self.group,
|
||||
)
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user