You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.3 KiB
87 lines
2.3 KiB
from abc import ABC, abstractmethod
|
|
from typing import List, Optional
|
|
from src.models.student import Student
|
|
|
|
|
|
class IStudentDAL(ABC):
|
|
"""学生信息数据访问层接口"""
|
|
|
|
@abstractmethod
|
|
def add_student(self, student: Student) -> bool:
|
|
"""添加学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete_student(self, id_card: str) -> bool:
|
|
"""根据身份证号删除学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def update_student(self, student: Student) -> bool:
|
|
"""更新学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_by_id(self, id_card: str) -> Optional[Student]:
|
|
"""根据身份证号获取学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_by_stu_id(self, stu_id: str) -> Optional[Student]:
|
|
"""根据学号获取学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_all(self) -> List[Student]:
|
|
"""获取所有学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_by_name(self, name: str) -> List[Student]:
|
|
"""根据姓名查询学生信息(模糊查询)"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_by_class(self, class_name: str) -> List[Student]:
|
|
"""根据班级查询学生信息(模糊查询)"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_by_major(self, major: str) -> List[Student]:
|
|
"""根据专业查询学生信息(模糊查询)"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def count_students(self) -> int:
|
|
"""统计学生总数"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def count_by_major(self, major: str) -> int:
|
|
"""统计各专业学生人数"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_avg_height(self, filter_by: Optional[str] = None, filter_value: Optional[str] = None) -> float:
|
|
"""计算平均身高"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_avg_weight(self, filter_by: Optional[str] = None, filter_value: Optional[str] = None) -> float:
|
|
"""计算平均体重"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def clear_all(self) -> bool:
|
|
"""清空所有学生信息"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def import_from_file(self, file_path: str) -> bool:
|
|
"""从文件导入数据"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def export_to_file(self, file_path: str) -> bool:
|
|
"""导出数据到文件"""
|
|
pass |