1
저는 Python 2.7.2와 SQLAlchemy 0.9.3을 사용하고 있습니다. 부서에는 여러 그룹이 있습니다. get_groups 및 방법이 속한 add_group을Python 서비스 레이어
class Department(Base):
id = Column(Integer, primary_key=True)
groups = relationship("Group", backref="department")
...
class Group(Base):
id = Column(Integer, primary_key=True)
department_id = Column(Integer, ForeignKey('departments.id'))
...
? DepartmentService 또는 GroupService에 있습니까?
class DepartmentService(object):
def get_groups(self, dept_id):
...
def add_group(self, dept_id, group):
...
class GroupService(object):
def get_groups(self, dept_id):
...
def add_group(self, dept_id, group):
...
아니면 DepartmentService에서 GroupService를 호출합니까?
하나를 선택해야합니다. 지금은 GroupService에 넣고 DepartmentService에 주입합니다. 예, backref가 훌륭합니다. D – Akash