|
@@ -64,7 +64,7 @@ async def get_inspection_user_list(
|
|
|
for user in InspectionUsers:
|
|
|
user_info = user_id_get_user_info(db,user.user_id)
|
|
|
dept = dept_id_get_dept_info(db,user_info.dept_id)
|
|
|
- print(dept)
|
|
|
+ # print(dept)
|
|
|
ancestors_names = dept_id_get_ancestors_names(db,dept)
|
|
|
area_code = user.area_code
|
|
|
area = area_code_get_area_info(db,area_code)
|
|
@@ -120,20 +120,41 @@ async def get_inspection_user(
|
|
|
detail = "用户不存在"
|
|
|
raise HTTPException(status_code=404, detail="用户不存在")
|
|
|
# 将查询结果转换为列表形式的字典
|
|
|
+ user_info = user_id_get_user_info(db, user.user_id)
|
|
|
+ dept = dept_id_get_dept_info(db, user_info.dept_id)
|
|
|
+ # print(dept)
|
|
|
+ ancestors_names = dept_id_get_ancestors_names(db, dept)
|
|
|
+ area_code = user.area_code
|
|
|
+ area = area_code_get_area_info(db, area_code)
|
|
|
+ area = area_code_get_ancestors_names(db, area)
|
|
|
inspection_user_result = {
|
|
|
- "id": user.id,
|
|
|
- "user_id": user.user_id,
|
|
|
- "dept_id": user.dept_id,
|
|
|
- "dept_name": user.dept_name,
|
|
|
- "ancestors_names": user.ancestors_names,
|
|
|
- "user_name": user.user_name,
|
|
|
- "create_time": user.create_time.strftime('%Y-%m-%d'),
|
|
|
- "phonenumber": user.phonenumber,
|
|
|
- "nick_name": user.nick_name,
|
|
|
- "area_code": user.area_code,
|
|
|
- "area": user.area,
|
|
|
- "yzy_account":user.yzy_account
|
|
|
- }
|
|
|
+ "id": user.id,
|
|
|
+ "user_id": user.user_id,
|
|
|
+ "dept_id": user_info.dept_id,
|
|
|
+ "dept_name": dept.dept_name,
|
|
|
+ "ancestors_names": ancestors_names,
|
|
|
+ "user_name": user_info.user_name,
|
|
|
+ "create_time": user.create_time.strftime('%Y-%m-%d'),
|
|
|
+ "phonenumber": user_info.phonenumber,
|
|
|
+ "nick_name": user_info.nick_name,
|
|
|
+ "area_code": user.area_code,
|
|
|
+ "area": area,
|
|
|
+ "yzy_account": user_info.yzy_account
|
|
|
+ }
|
|
|
+ # inspection_user_result = {
|
|
|
+ # "id": user.id,
|
|
|
+ # "user_id": user.user_id,
|
|
|
+ # "dept_id": user.dept_id,
|
|
|
+ # "dept_name": user.dept_name,
|
|
|
+ # "ancestors_names": user.ancestors_names,
|
|
|
+ # "user_name": user.user_name,
|
|
|
+ # "create_time": user.create_time.strftime('%Y-%m-%d'),
|
|
|
+ # "phonenumber": user.phonenumber,
|
|
|
+ # "nick_name": user.nick_name,
|
|
|
+ # "area_code": user.area_code,
|
|
|
+ # "area": user.area,
|
|
|
+ # "yzy_account":user.yzy_account
|
|
|
+ # }
|
|
|
|
|
|
# 返回结果
|
|
|
return {
|
|
@@ -158,20 +179,33 @@ async def create_inspection_user(
|
|
|
user_id = Depends(valid_access_token)
|
|
|
):
|
|
|
try:
|
|
|
- user_id_1 = body['user_id']
|
|
|
- area_code = body['area_code']
|
|
|
+ # user_id_1 = body['user_id']
|
|
|
+ # area_code = body['area_code']
|
|
|
+ # dept_id = None
|
|
|
+ # ancestors_names=None
|
|
|
+ # if 'dept_id' in body:
|
|
|
+ # dept_id=body['dept_id']
|
|
|
+ # dept = dept_id_get_dept_info(db,dept_id)
|
|
|
+ # # print(dept)
|
|
|
+ # ancestors_names = dept_id_get_ancestors_names(db,dept)
|
|
|
+ # dept_name = None
|
|
|
+ # if 'dept_name' in body:
|
|
|
+ # dept_name=body['dept_name']
|
|
|
+ # phonenumber = None
|
|
|
+ # if 'phonenumber' in body:
|
|
|
+ # phonenumber=body['phonenumber']
|
|
|
# 创建新的预案记录
|
|
|
new_user = RiskManagementInspectionUser(
|
|
|
user_id=body['user_id'],
|
|
|
- dept_id = '',#body['dept_id'],
|
|
|
- dept_name = '',#body['dept_name'],
|
|
|
- ancestors_names = '',#body['ancestors_names'],
|
|
|
- user_name = '',#body['user_name'],
|
|
|
- nick_name = '',#body['nick_name'],
|
|
|
- phonenumber = '',#body['phonenumber'],
|
|
|
+ # dept_id = dept_id,#body['dept_id'],
|
|
|
+ # dept_name = dept_name,#body['dept_name'],
|
|
|
+ # ancestors_names = ancestors_names,#body['ancestors_names'],
|
|
|
+ # user_name = '',#body['user_name'],
|
|
|
+ # nick_name = '',#body['nick_name'],
|
|
|
+ # phonenumber = phonenumber,#body['phonenumber'],
|
|
|
area_code = body['area_code'],
|
|
|
- area = '',#body['area'],
|
|
|
- yzy_account = '',#body['yzy_account'],
|
|
|
+ # area = '',#body['area'],
|
|
|
+ # yzy_account = '',#body['yzy_account'],
|
|
|
create_by = user_id
|
|
|
)
|
|
|
# 添加到数据库会话并提交
|
|
@@ -209,22 +243,22 @@ async def update_inspection_user(
|
|
|
|
|
|
if 'user_id' in body:
|
|
|
user.user_id = body['user_id']
|
|
|
- if 'dept_id' in body:
|
|
|
- user.dept_id = body['dept_id']
|
|
|
- if 'dept_name' in body:
|
|
|
- user.dept_name = body['dept_name']
|
|
|
- if 'ancestors_names' in body:
|
|
|
- user.ancestors_names = body['ancestors_names']
|
|
|
- if 'user_name' in body:
|
|
|
- user.user_name = body['user_name']
|
|
|
- if 'nick_name' in body:
|
|
|
- user.nick_name = body['nick_name']
|
|
|
- if 'phonenumber' in body:
|
|
|
- user.phonenumber = body['phonenumber']
|
|
|
+ # if 'dept_id' in body:
|
|
|
+ # user.dept_id = body['dept_id']
|
|
|
+ # if 'dept_name' in body:
|
|
|
+ # user.dept_name = body['dept_name']
|
|
|
+ # if 'ancestors_names' in body:
|
|
|
+ # user.ancestors_names = body['ancestors_names']
|
|
|
+ # if 'user_name' in body:
|
|
|
+ # user.user_name = body['user_name']
|
|
|
+ # if 'nick_name' in body:
|
|
|
+ # user.nick_name = body['nick_name']
|
|
|
+ # if 'phonenumber' in body:
|
|
|
+ # user.phonenumber = body['phonenumber']
|
|
|
if 'area_code' in body:
|
|
|
user.area_code = body['area_code']
|
|
|
- if 'area' in body:
|
|
|
- user.area = body['area']
|
|
|
+ # if 'area' in body:
|
|
|
+ # user.area = body['area']
|
|
|
|
|
|
if user_id:
|
|
|
user.update_by = user_id
|
|
@@ -257,8 +291,9 @@ async def delete_inspection_users(
|
|
|
# 提取请求数据
|
|
|
query = db.query(RiskManagementInspectionUser)
|
|
|
query = query.filter(RiskManagementInspectionUser.del_flag != '2')
|
|
|
- query = query.filter(RiskManagementInspectionUser.user_id.in_(userIds))
|
|
|
+ query = query.filter(RiskManagementInspectionUser.id.in_(userIds))
|
|
|
users = query.all()
|
|
|
+ print(userIds)
|
|
|
if not users:
|
|
|
detail = "用户不存在"
|
|
|
raise HTTPException(status_code=404, detail="用户不存在")
|