|
@@ -26,6 +26,7 @@ from exceptions import AppException
|
|
router = APIRouter()
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
@router.post('/create')
|
|
@router.post('/create')
|
|
async def create_contact(
|
|
async def create_contact(
|
|
db: Session = Depends(get_db),
|
|
db: Session = Depends(get_db),
|
|
@@ -137,6 +138,7 @@ async def update_contact(
|
|
@router.get('/list')
|
|
@router.get('/list')
|
|
async def get_emergency_contact_list(
|
|
async def get_emergency_contact_list(
|
|
type_parent_id: str = Query(None, description='单位名称'),
|
|
type_parent_id: str = Query(None, description='单位名称'),
|
|
|
|
+ area_code:str = Query(None, description='单位名称'),
|
|
Name: str = Query(None, description='联系人'),
|
|
Name: str = Query(None, description='联系人'),
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
pageSize: int = Query(10, gt=0, description='每页条目数量'),
|
|
pageSize: int = Query(10, gt=0, description='每页条目数量'),
|
|
@@ -153,6 +155,8 @@ async def get_emergency_contact_list(
|
|
query = query.filter(ThreeProofingResponsiblePerson.id.in_(person_list))
|
|
query = query.filter(ThreeProofingResponsiblePerson.id.in_(person_list))
|
|
if Name:
|
|
if Name:
|
|
query = query.filter(ThreeProofingResponsiblePerson.name.like(f'%{Name}%'))
|
|
query = query.filter(ThreeProofingResponsiblePerson.name.like(f'%{Name}%'))
|
|
|
|
+ if area_code:
|
|
|
|
+ query = query.filter(ThreeProofingResponsiblePerson.area_code==area_code)
|
|
|
|
|
|
# 计算总条目数
|
|
# 计算总条目数
|
|
total_items = query.count()
|
|
total_items = query.count()
|
|
@@ -171,16 +175,22 @@ async def get_emergency_contact_list(
|
|
for type_parent in type_parent_id_list:
|
|
for type_parent in type_parent_id_list:
|
|
dict_data = get_dict_data_info(db,'three_proofing',type_parent)
|
|
dict_data = get_dict_data_info(db,'three_proofing',type_parent)
|
|
type_parent_list.append({"type_parent_id":type_parent,"type_parent":dict_data.dict_label})
|
|
type_parent_list.append({"type_parent_id":type_parent,"type_parent":dict_data.dict_label})
|
|
|
|
+ area_info = id_get_area_info(db,info.area_code)
|
|
|
|
+ user_info = user_id_get_user_info(db,info.create_by)
|
|
contact_infos_list.append({
|
|
contact_infos_list.append({
|
|
"id": info.id,
|
|
"id": info.id,
|
|
"unit_id": info.unit_id,
|
|
"unit_id": info.unit_id,
|
|
"unit_name": info.unit_name,
|
|
"unit_name": info.unit_name,
|
|
"name": info.name,
|
|
"name": info.name,
|
|
"area_code": info.area_code,
|
|
"area_code": info.area_code,
|
|
|
|
+ "area_name": area_info.area_name,
|
|
"position": info.position,
|
|
"position": info.position,
|
|
"phone": info.phone,
|
|
"phone": info.phone,
|
|
"order_num":info.order_num,
|
|
"order_num":info.order_num,
|
|
- "create_time": info.create_time.strftime('%Y-%m-%d'),
|
|
|
|
|
|
+ "online_status":'0',
|
|
|
|
+ "create_time": info.create_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
+ "create_by":info.create_by,
|
|
|
|
+ "create_user":user_info.nick_name,
|
|
"type_parent_list":type_parent_list
|
|
"type_parent_list":type_parent_list
|
|
})
|
|
})
|
|
# 返回结果+
|
|
# 返回结果+
|
|
@@ -211,6 +221,8 @@ async def get_emergency_contact_id_info(
|
|
'errmsg': '联系人不存在'
|
|
'errmsg': '联系人不存在'
|
|
})
|
|
})
|
|
# 将查询结果转换为列表形式的字典
|
|
# 将查询结果转换为列表形式的字典
|
|
|
|
+ area_info = id_get_area_info(db,contact.area_code)
|
|
|
|
+ user_info = user_id_get_user_info(db,contact.create_by)
|
|
|
|
|
|
contact_result = {
|
|
contact_result = {
|
|
"id": contact.id,
|
|
"id": contact.id,
|
|
@@ -218,10 +230,14 @@ async def get_emergency_contact_id_info(
|
|
"unit_name": contact.unit_name,
|
|
"unit_name": contact.unit_name,
|
|
"name": contact.name,
|
|
"name": contact.name,
|
|
"area_code":contact.area_code,
|
|
"area_code":contact.area_code,
|
|
|
|
+ "area_name": area_info.area_name,
|
|
"position": contact.position,
|
|
"position": contact.position,
|
|
"phone": contact.phone,
|
|
"phone": contact.phone,
|
|
"order_num":contact.order_num,
|
|
"order_num":contact.order_num,
|
|
- "create_time": contact.create_time.strftime('%Y-%m-%d'),
|
|
|
|
|
|
+ "online_status":'0',
|
|
|
|
+ "create_time": contact.create_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
+ "create_by":contact.create_by,
|
|
|
|
+ "create_user":user_info.nick_name,
|
|
"type_list":[]
|
|
"type_list":[]
|
|
}
|
|
}
|
|
|
|
|