25 lines
741 B
Python
25 lines
741 B
Python
"""问卷域仓储:问卷模板 + 题目。"""
|
|
from __future__ import annotations
|
|
|
|
from sqlalchemy import select
|
|
|
|
from model.ops_question import OpsQuestion
|
|
from model.ops_questionnaire import OpsQuestionnaire
|
|
from repositories.base import BaseRepository
|
|
|
|
|
|
class QuestionnaireRepo(BaseRepository):
|
|
model = OpsQuestionnaire
|
|
|
|
|
|
class QuestionRepo(BaseRepository):
|
|
model = OpsQuestion
|
|
|
|
async def list_by_questionnaire(self, questionnaire_id: int) -> list[OpsQuestion]:
|
|
stmt = (
|
|
select(OpsQuestion)
|
|
.where(OpsQuestion.questionnaire_id == questionnaire_id)
|
|
.order_by(OpsQuestion.question_no.asc(), OpsQuestion.sort.asc())
|
|
)
|
|
return list((await self.db.scalars(stmt)).all())
|