feat: 关联查询出来报销单的其他费用子数据
This commit is contained in:
@@ -6,6 +6,7 @@ from sqlmodel import Field, Relationship, select
|
||||
|
||||
from app.model.BasicModel import BasicModel
|
||||
from app.model.ProjectModel import ProjectModel
|
||||
from app.model.ReimburseOtherModel import ReimburseOtherModel
|
||||
from app.model.ReimburseTravelModel import ReimburseTravelModel
|
||||
from app.utils.create_module_service import create_model_service
|
||||
|
||||
@@ -62,6 +63,24 @@ class ReimburseModel(BasicModel, table=True):
|
||||
def travel_list(self, value: Optional[List["ReimburseTravelModel"]]) -> None:
|
||||
pass
|
||||
|
||||
# /*---------------------------------------other_list-------------------------------------------*/
|
||||
|
||||
other_list_rel: Optional[List["ReimburseOtherModel"]] = Relationship(
|
||||
sa_relationship_kwargs={
|
||||
"foreign_keys": "ReimburseOtherModel.reimburse_id",
|
||||
"primaryjoin": "ReimburseModel.id == ReimburseOtherModel.reimburse_id",
|
||||
}
|
||||
)
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
def other_list(self) -> Optional[List["ReimburseOtherModel"]]:
|
||||
return self.other_list_rel
|
||||
|
||||
@other_list.setter
|
||||
def other_list(self, value: Optional[List["ReimburseOtherModel"]]) -> None:
|
||||
pass
|
||||
|
||||
|
||||
ReimburseService = create_model_service(
|
||||
Cls=ReimburseModel,
|
||||
@@ -70,7 +89,7 @@ ReimburseService = create_model_service(
|
||||
selectinload(ReimburseModel.proj_rel).
|
||||
selectinload(ProjectModel.leader),
|
||||
|
||||
# 新增:预加载差旅明细
|
||||
selectinload(ReimburseModel.travel_list_rel)
|
||||
selectinload(ReimburseModel.travel_list_rel),
|
||||
selectinload(ReimburseModel.other_list_rel),
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user