feat:增加考试接口
This commit is contained in:
18
service/exam_service.py
Normal file
18
service/exam_service.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models.library import ExamRecord
|
||||
from schemas.exam import ExamRecordRequest
|
||||
|
||||
|
||||
async def add_record(db: AsyncSession, data: ExamRecordRequest) -> bool:
|
||||
record = ExamRecord(
|
||||
subject=data.subject,
|
||||
total_count=data.totalCount,
|
||||
correct_count=data.correctCount,
|
||||
wrong_count=data.wrongCount,
|
||||
)
|
||||
|
||||
db.add(record)
|
||||
await db.commit()
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user