Files
dsProject/dsAiTeachingModel/utils/TranslateUtil.py

38 lines
1.5 KiB
Python
Raw Normal View History

2025-08-14 15:45:08 +08:00
from utils.Database import find_by_sql
async def get_stage_map():
select_stage_sql: str = "select * from t_dm_stage where b_use = 1"
select_stage_result = await find_by_sql(select_stage_sql, ())
stage_map = {}
for stage in select_stage_result:
stage_map[str(stage["stage_id"])] = stage["stage_name"]
return stage_map
2025-08-15 08:54:53 +08:00
async def get_stage_map_by_id(stage_id: int):
select_stage_sql: str = f"select stage_id, stage_name from t_dm_stage where b_use = 1 and stage_id = {stage_id}"
select_stage_result = await find_by_sql(select_stage_sql, ())
if select_stage_result is not None:
return select_stage_result[0]["stage_name"]
else:
return "未知学段"
2025-08-14 15:45:08 +08:00
async def get_subject_map():
select_subject_sql: str = "select * from t_dm_subject"
select_subject_result = await find_by_sql(select_subject_sql, ())
subject_map = {}
for subject in select_subject_result:
subject_map[str(subject["subject_id"])] = subject["subject_name"]
return subject_map
async def get_person_map(person_ids: str):
person_id_list = person_ids.split(",")
person_ids = ",".join(person_id_list)
select_person_sql: str = f"select person_id, person_name from t_sys_loginperson where person_id in ({person_ids}) and b_use = 1"
select_person_result = await find_by_sql(select_person_sql, ())
person_map = {}
if select_person_result is not None:
for person in select_person_result:
person_map[str(person["person_id"])] = person["person_name"]
return person_map