[changes] Remove the interface and modify the parameters passed in
This commit is contained in:
@@ -341,14 +341,14 @@ async def get_community_graph_data_api(
|
|||||||
|
|
||||||
@router.get("/end_user_info", response_model=ApiResponse)
|
@router.get("/end_user_info", response_model=ApiResponse)
|
||||||
async def get_end_user_info(
|
async def get_end_user_info(
|
||||||
end_user_info_id: str,
|
end_user_id: str,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""
|
"""
|
||||||
查询终端用户信息记录
|
查询终端用户信息记录
|
||||||
|
|
||||||
根据 end_user_info_id 查询单条终端用户信息记录。
|
根据 end_user_id 查询单条终端用户信息记录。
|
||||||
"""
|
"""
|
||||||
workspace_id = current_user.current_workspace_id
|
workspace_id = current_user.current_workspace_id
|
||||||
|
|
||||||
@@ -357,69 +357,27 @@ async def get_end_user_info(
|
|||||||
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
||||||
|
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"查询终端用户信息请求: end_user_info_id={end_user_info_id}, user={current_user.username}, "
|
f"查询终端用户信息请求: end_user_id={end_user_id}, user={current_user.username}, "
|
||||||
f"workspace={workspace_id}"
|
f"workspace={workspace_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
result = user_memory_service.get_end_user_info(db, end_user_info_id)
|
result = user_memory_service.get_end_user_info(db, end_user_id)
|
||||||
|
|
||||||
if result["success"]:
|
if result["success"]:
|
||||||
api_logger.info(f"成功查询终端用户信息: end_user_info_id={end_user_info_id}")
|
api_logger.info(f"成功查询终端用户信息: end_user_id={end_user_id}")
|
||||||
return success(data=result["data"], msg="查询成功")
|
return success(data=result["data"], msg="查询成功")
|
||||||
else:
|
else:
|
||||||
error_msg = result["error"]
|
error_msg = result["error"]
|
||||||
api_logger.error(f"查询终端用户信息失败: end_user_info_id={end_user_info_id}, error={error_msg}")
|
api_logger.error(f"查询终端用户信息失败: end_user_id={end_user_id}, error={error_msg}")
|
||||||
|
|
||||||
if error_msg == "终端用户信息记录不存在":
|
if error_msg == "终端用户信息记录不存在":
|
||||||
return fail(BizCode.USER_NOT_FOUND, "终端用户信息记录不存在", error_msg)
|
return fail(BizCode.USER_NOT_FOUND, "终端用户信息记录不存在", error_msg)
|
||||||
elif error_msg == "无效的终端用户信息记录ID格式":
|
elif error_msg == "无效的终端用户ID格式":
|
||||||
return fail(BizCode.INVALID_USER_ID, "无效的终端用户信息记录ID格式", error_msg)
|
return fail(BizCode.INVALID_USER_ID, "无效的终端用户ID格式", error_msg)
|
||||||
else:
|
else:
|
||||||
return fail(BizCode.INTERNAL_ERROR, "查询终端用户信息失败", error_msg)
|
return fail(BizCode.INTERNAL_ERROR, "查询终端用户信息失败", error_msg)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/end_user_info/create", response_model=ApiResponse)
|
|
||||||
async def create_end_user_info(
|
|
||||||
info_create: EndUserInfoCreate,
|
|
||||||
current_user: User = Depends(get_current_user),
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
) -> dict:
|
|
||||||
"""
|
|
||||||
创建终端用户信息记录
|
|
||||||
|
|
||||||
为指定用户创建一条新的信息记录,支持多个别名。
|
|
||||||
"""
|
|
||||||
workspace_id = current_user.current_workspace_id
|
|
||||||
end_user_id = info_create.end_user_id
|
|
||||||
|
|
||||||
if workspace_id is None:
|
|
||||||
api_logger.warning(f"用户 {current_user.username} 尝试创建终端用户信息但未选择工作空间")
|
|
||||||
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
|
||||||
|
|
||||||
api_logger.info(
|
|
||||||
f"创建终端用户信息请求: end_user_id={end_user_id}, aliases={info_create.aliases}, "
|
|
||||||
f"user={current_user.username}, workspace={workspace_id}"
|
|
||||||
)
|
|
||||||
|
|
||||||
result = user_memory_service.create_end_user_info(
|
|
||||||
db, end_user_id, info_create.other_name, info_create.aliases, info_create.meta_data
|
|
||||||
)
|
|
||||||
|
|
||||||
if result["success"]:
|
|
||||||
api_logger.info(f"成功创建终端用户信息: end_user_id={end_user_id}")
|
|
||||||
return success(data=result["data"], msg="创建成功")
|
|
||||||
else:
|
|
||||||
error_msg = result["error"]
|
|
||||||
api_logger.error(f"终端用户信息创建失败: end_user_id={end_user_id}, error={error_msg}")
|
|
||||||
|
|
||||||
if error_msg == "终端用户不存在":
|
|
||||||
return fail(BizCode.USER_NOT_FOUND, "终端用户不存在", error_msg)
|
|
||||||
elif error_msg == "无效的用户ID格式":
|
|
||||||
return fail(BizCode.INVALID_USER_ID, "无效的用户ID格式", error_msg)
|
|
||||||
else:
|
|
||||||
return fail(BizCode.INTERNAL_ERROR, "终端用户信息创建失败", error_msg)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/end_user_info/updated", response_model=ApiResponse)
|
@router.post("/end_user_info/updated", response_model=ApiResponse)
|
||||||
async def update_end_user_info(
|
async def update_end_user_info(
|
||||||
info_update: EndUserInfoUpdate,
|
info_update: EndUserInfoUpdate,
|
||||||
@@ -429,86 +387,47 @@ async def update_end_user_info(
|
|||||||
"""
|
"""
|
||||||
更新终端用户信息记录
|
更新终端用户信息记录
|
||||||
|
|
||||||
根据 end_user_info_id 更新终端用户信息记录,支持批量更新多个别名。
|
根据 end_user_id 更新终端用户信息记录,支持批量更新多个别名。
|
||||||
|
|
||||||
示例请求体:
|
示例请求体:
|
||||||
{
|
{
|
||||||
"end_user_info_id": "2d4f57d4-639b-47aa-937a-d461bc2c2d53",
|
"end_user_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||||
"other_name": "张三1",
|
"other_name": "张三1",
|
||||||
"aliases": ["小张", "张工"],
|
"aliases": ["小张", "张工"],
|
||||||
"meta_data": {"position": "工程师", "department": "技术部"}
|
"meta_data": {"position": "工程师", "department": "技术部"}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
workspace_id = current_user.current_workspace_id
|
workspace_id = current_user.current_workspace_id
|
||||||
end_user_info_id = info_update.end_user_info_id
|
end_user_id = info_update.end_user_id
|
||||||
|
|
||||||
if workspace_id is None:
|
if workspace_id is None:
|
||||||
api_logger.warning(f"用户 {current_user.username} 尝试更新终端用户信息但未选择工作空间")
|
api_logger.warning(f"用户 {current_user.username} 尝试更新终端用户信息但未选择工作空间")
|
||||||
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
||||||
|
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"更新终端用户信息请求: end_user_info_id={end_user_info_id}, user={current_user.username}, "
|
f"更新终端用户信息请求: end_user_id={end_user_id}, user={current_user.username}, "
|
||||||
f"workspace={workspace_id}"
|
f"workspace={workspace_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 获取更新数据(排除 end_user_info_id)
|
# 获取更新数据(排除 end_user_id)
|
||||||
update_data = info_update.model_dump(exclude_unset=True, exclude={'end_user_info_id'})
|
update_data = info_update.model_dump(exclude_unset=True, exclude={'end_user_id'})
|
||||||
|
|
||||||
result = user_memory_service.update_end_user_info(db, end_user_info_id, update_data)
|
result = user_memory_service.update_end_user_info(db, end_user_id, update_data)
|
||||||
|
|
||||||
if result["success"]:
|
if result["success"]:
|
||||||
api_logger.info(f"成功更新终端用户信息: end_user_info_id={end_user_info_id}")
|
api_logger.info(f"成功更新终端用户信息: end_user_id={end_user_id}")
|
||||||
return success(data=result["data"], msg="更新成功")
|
return success(data=result["data"], msg="更新成功")
|
||||||
else:
|
else:
|
||||||
error_msg = result["error"]
|
error_msg = result["error"]
|
||||||
api_logger.error(f"终端用户信息更新失败: end_user_info_id={end_user_info_id}, error={error_msg}")
|
api_logger.error(f"终端用户信息更新失败: end_user_id={end_user_id}, error={error_msg}")
|
||||||
|
|
||||||
if error_msg == "终端用户信息记录不存在":
|
if error_msg == "终端用户信息记录不存在":
|
||||||
return fail(BizCode.USER_NOT_FOUND, "终端用户信息记录不存在", error_msg)
|
return fail(BizCode.USER_NOT_FOUND, "终端用户信息记录不存在", error_msg)
|
||||||
elif error_msg == "无效的终端用户信息记录ID格式":
|
elif error_msg == "无效的终端用户ID格式":
|
||||||
return fail(BizCode.INVALID_USER_ID, "无效的终端用户信息记录ID格式", error_msg)
|
return fail(BizCode.INVALID_USER_ID, "无效的终端用户ID格式", error_msg)
|
||||||
else:
|
else:
|
||||||
return fail(BizCode.INTERNAL_ERROR, "终端用户信息更新失败", error_msg)
|
return fail(BizCode.INTERNAL_ERROR, "终端用户信息更新失败", error_msg)
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/end_user_info", response_model=ApiResponse)
|
|
||||||
async def delete_end_user_info(
|
|
||||||
end_user_info_id: str,
|
|
||||||
current_user: User = Depends(get_current_user),
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
) -> dict:
|
|
||||||
"""
|
|
||||||
删除终端用户信息记录
|
|
||||||
|
|
||||||
根据 end_user_info_id 删除指定的终端用户信息记录。
|
|
||||||
"""
|
|
||||||
workspace_id = current_user.current_workspace_id
|
|
||||||
|
|
||||||
if workspace_id is None:
|
|
||||||
api_logger.warning(f"用户 {current_user.username} 尝试删除终端用户信息但未选择工作空间")
|
|
||||||
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
|
||||||
|
|
||||||
api_logger.info(
|
|
||||||
f"删除终端用户信息请求: end_user_info_id={end_user_info_id}, user={current_user.username}, "
|
|
||||||
f"workspace={workspace_id}"
|
|
||||||
)
|
|
||||||
|
|
||||||
result = user_memory_service.delete_end_user_info(db, end_user_info_id)
|
|
||||||
|
|
||||||
if result["success"]:
|
|
||||||
api_logger.info(f"成功删除终端用户信息: end_user_info_id={end_user_info_id}")
|
|
||||||
return success(data=result["data"], msg="删除成功")
|
|
||||||
else:
|
|
||||||
error_msg = result["error"]
|
|
||||||
api_logger.error(f"终端用户信息删除失败: end_user_info_id={end_user_info_id}, error={error_msg}")
|
|
||||||
|
|
||||||
if error_msg == "终端用户信息记录不存在":
|
|
||||||
return fail(BizCode.USER_NOT_FOUND, "终端用户信息记录不存在", error_msg)
|
|
||||||
elif error_msg == "无效的终端用户信息记录ID格式":
|
|
||||||
return fail(BizCode.INVALID_USER_ID, "无效的终端用户信息记录ID格式", error_msg)
|
|
||||||
else:
|
|
||||||
return fail(BizCode.INTERNAL_ERROR, "终端用户信息删除失败", error_msg)
|
|
||||||
|
|
||||||
@router.get("/memory_space/timeline_memories", response_model=ApiResponse)
|
@router.get("/memory_space/timeline_memories", response_model=ApiResponse)
|
||||||
async def memory_space_timeline_of_shared_memories(
|
async def memory_space_timeline_of_shared_memories(
|
||||||
id: str, label: str,
|
id: str, label: str,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class EndUserInfoCreate(EndUserInfoBase):
|
|||||||
|
|
||||||
class EndUserInfoUpdate(BaseModel):
|
class EndUserInfoUpdate(BaseModel):
|
||||||
"""更新终端用户信息请求模型"""
|
"""更新终端用户信息请求模型"""
|
||||||
end_user_info_id: str = Field(description="终端用户信息记录ID")
|
end_user_id: str = Field(description="终端用户ID")
|
||||||
other_name: Optional[str] = Field(description="用户名称", default=None)
|
other_name: Optional[str] = Field(description="用户名称", default=None)
|
||||||
aliases: Optional[List[str]] = Field(description="用户别名列表", default=None)
|
aliases: Optional[List[str]] = Field(description="用户别名列表", default=None)
|
||||||
meta_data: Optional[Dict[str, Any]] = Field(description="用户相关的扩展信息", default=None)
|
meta_data: Optional[Dict[str, Any]] = Field(description="用户相关的扩展信息", default=None)
|
||||||
|
|||||||
@@ -365,14 +365,14 @@ class UserMemoryService:
|
|||||||
def get_end_user_info(
|
def get_end_user_info(
|
||||||
self,
|
self,
|
||||||
db: Session,
|
db: Session,
|
||||||
end_user_info_id: str
|
end_user_id: str
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
查询单个终端用户信息记录
|
查询单个终端用户信息记录
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
db: 数据库会话
|
db: 数据库会话
|
||||||
end_user_info_id: 终端用户信息记录ID (UUID)
|
end_user_id: 终端用户ID (UUID)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
{
|
{
|
||||||
@@ -385,11 +385,11 @@ class UserMemoryService:
|
|||||||
from app.models.end_user_info_model import EndUserInfo
|
from app.models.end_user_info_model import EndUserInfo
|
||||||
|
|
||||||
# 转换为UUID并查询
|
# 转换为UUID并查询
|
||||||
info_uuid = uuid.UUID(end_user_info_id)
|
user_uuid = uuid.UUID(end_user_id)
|
||||||
end_user_info_record = db.query(EndUserInfo).filter(EndUserInfo.id == info_uuid).first()
|
end_user_info_record = db.query(EndUserInfo).filter(EndUserInfo.end_user_id == user_uuid).first()
|
||||||
|
|
||||||
if not end_user_info_record:
|
if not end_user_info_record:
|
||||||
logger.warning(f"终端用户信息记录不存在: end_user_info_id={end_user_info_id}")
|
logger.warning(f"终端用户信息记录不存在: end_user_id={end_user_id}")
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
@@ -408,95 +408,7 @@ class UserMemoryService:
|
|||||||
updated_at=end_user_info_record.updated_at
|
updated_at=end_user_info_record.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"成功查询终端用户信息记录: end_user_info_id={end_user_info_id}")
|
logger.info(f"成功查询终端用户信息记录: end_user_id={end_user_id}")
|
||||||
|
|
||||||
return {
|
|
||||||
"success": True,
|
|
||||||
"data": response_data.model_dump(),
|
|
||||||
"error": None
|
|
||||||
}
|
|
||||||
|
|
||||||
except ValueError:
|
|
||||||
logger.error(f"无效的 end_user_info_id 格式: {end_user_info_id}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": "无效的终端用户信息记录ID格式"
|
|
||||||
}
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"查询终端用户信息记录失败: end_user_info_id={end_user_info_id}, error={str(e)}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": str(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
def create_end_user_info(
|
|
||||||
self,
|
|
||||||
db: Session,
|
|
||||||
end_user_id: str,
|
|
||||||
other_name: str,
|
|
||||||
aliases: List[str] = None,
|
|
||||||
meta_data: dict = None
|
|
||||||
) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
创建终端用户信息记录
|
|
||||||
|
|
||||||
Args:
|
|
||||||
db: 数据库会话
|
|
||||||
end_user_id: 终端用户ID (UUID)
|
|
||||||
other_name: 用户名称
|
|
||||||
aliases: 别名列表
|
|
||||||
meta_data: 扩展信息
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
{
|
|
||||||
"success": bool,
|
|
||||||
"data": dict,
|
|
||||||
"error": Optional[str]
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
from app.models.end_user_info_model import EndUserInfo
|
|
||||||
from app.repositories.end_user_repository import EndUserRepository
|
|
||||||
|
|
||||||
# 转换为UUID并查询用户
|
|
||||||
user_uuid = uuid.UUID(end_user_id)
|
|
||||||
repo = EndUserRepository(db)
|
|
||||||
end_user = repo.get_by_id(user_uuid)
|
|
||||||
|
|
||||||
if not end_user:
|
|
||||||
logger.warning(f"终端用户不存在: end_user_id={end_user_id}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": "终端用户不存在"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 创建新的用户信息记录
|
|
||||||
new_info = EndUserInfo(
|
|
||||||
end_user_id=user_uuid,
|
|
||||||
other_name=other_name,
|
|
||||||
aliases=aliases,
|
|
||||||
meta_data=meta_data
|
|
||||||
)
|
|
||||||
db.add(new_info)
|
|
||||||
db.commit()
|
|
||||||
db.refresh(new_info)
|
|
||||||
|
|
||||||
# 构建响应数据
|
|
||||||
from app.schemas.end_user_info_schema import EndUserInfoResponse
|
|
||||||
response_data = EndUserInfoResponse(
|
|
||||||
end_user_info_id=new_info.id,
|
|
||||||
end_user_id=new_info.end_user_id,
|
|
||||||
other_name=new_info.other_name,
|
|
||||||
aliases=new_info.aliases,
|
|
||||||
meta_data=new_info.meta_data,
|
|
||||||
created_at=new_info.created_at,
|
|
||||||
updated_at=new_info.updated_at
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.info(f"成功创建终端用户信息记录: end_user_id={end_user_id}")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
@@ -509,11 +421,10 @@ class UserMemoryService:
|
|||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
"error": "无效的用户ID格式"
|
"error": "无效的终端用户ID格式"
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.rollback()
|
logger.error(f"查询终端用户信息记录失败: end_user_id={end_user_id}, error={str(e)}")
|
||||||
logger.error(f"创建终端用户信息记录失败: end_user_id={end_user_id}, error={str(e)}")
|
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
@@ -523,7 +434,7 @@ class UserMemoryService:
|
|||||||
def update_end_user_info(
|
def update_end_user_info(
|
||||||
self,
|
self,
|
||||||
db: Session,
|
db: Session,
|
||||||
end_user_info_id: str,
|
end_user_id: str,
|
||||||
update_data: Dict[str, Any]
|
update_data: Dict[str, Any]
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
@@ -531,7 +442,7 @@ class UserMemoryService:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
db: 数据库会话
|
db: 数据库会话
|
||||||
end_user_info_id: 终端用户信息记录ID (UUID)
|
end_user_id: 终端用户ID (UUID)
|
||||||
update_data: 更新数据字典
|
update_data: 更新数据字典
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -545,11 +456,11 @@ class UserMemoryService:
|
|||||||
from app.models.end_user_info_model import EndUserInfo
|
from app.models.end_user_info_model import EndUserInfo
|
||||||
|
|
||||||
# 转换为UUID并查询
|
# 转换为UUID并查询
|
||||||
info_uuid = uuid.UUID(end_user_info_id)
|
user_uuid = uuid.UUID(end_user_id)
|
||||||
end_user_info_record = db.query(EndUserInfo).filter(EndUserInfo.id == info_uuid).first()
|
end_user_info_record = db.query(EndUserInfo).filter(EndUserInfo.end_user_id == user_uuid).first()
|
||||||
|
|
||||||
if not end_user_info_record:
|
if not end_user_info_record:
|
||||||
logger.warning(f"终端用户信息记录不存在: end_user_info_id={end_user_info_id}")
|
logger.warning(f"终端用户信息记录不存在: end_user_id={end_user_id}")
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
@@ -583,7 +494,7 @@ class UserMemoryService:
|
|||||||
updated_at=end_user_info_record.updated_at
|
updated_at=end_user_info_record.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"成功更新终端用户信息记录: end_user_info_id={end_user_info_id}, updated_fields={list(update_data.keys())}")
|
logger.info(f"成功更新终端用户信息记录: end_user_id={end_user_id}, updated_fields={list(update_data.keys())}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
@@ -592,85 +503,15 @@ class UserMemoryService:
|
|||||||
}
|
}
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.error(f"无效的 end_user_info_id 格式: {end_user_info_id}")
|
logger.error(f"无效的 end_user_id 格式: {end_user_id}")
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
"error": "无效的终端用户信息记录ID格式"
|
"error": "无效的终端用户ID格式"
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
logger.error(f"更新终端用户信息记录失败: end_user_info_id={end_user_info_id}, error={str(e)}")
|
logger.error(f"更新终端用户信息记录失败: end_user_id={end_user_id}, error={str(e)}")
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": str(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
def delete_end_user_info(
|
|
||||||
self,
|
|
||||||
db: Session,
|
|
||||||
end_user_info_id: str
|
|
||||||
) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
删除终端用户信息记录
|
|
||||||
|
|
||||||
Args:
|
|
||||||
db: 数据库会话
|
|
||||||
end_user_info_id: 终端用户信息记录ID (UUID)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
{
|
|
||||||
"success": bool,
|
|
||||||
"data": dict,
|
|
||||||
"error": Optional[str]
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
from app.models.end_user_info_model import EndUserInfo
|
|
||||||
|
|
||||||
# 转换为UUID并查询
|
|
||||||
info_uuid = uuid.UUID(end_user_info_id)
|
|
||||||
end_user_info_record = db.query(EndUserInfo).filter(EndUserInfo.id == info_uuid).first()
|
|
||||||
|
|
||||||
if not end_user_info_record:
|
|
||||||
logger.warning(f"终端用户信息记录不存在: end_user_info_id={end_user_info_id}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": "终端用户信息记录不存在"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 删除记录
|
|
||||||
db.delete(end_user_info_record)
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
logger.info(f"成功删除终端用户信息记录: end_user_info_id={end_user_info_id}")
|
|
||||||
|
|
||||||
return {
|
|
||||||
"success": True,
|
|
||||||
"data": {"end_user_info_id": end_user_info_id},
|
|
||||||
"error": None
|
|
||||||
}
|
|
||||||
|
|
||||||
except ValueError:
|
|
||||||
logger.error(f"无效的 end_user_info_id 格式: {end_user_info_id}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": "无效的终端用户信息记录ID格式"
|
|
||||||
}
|
|
||||||
except Exception as e:
|
|
||||||
db.rollback()
|
|
||||||
logger.error(f"删除终端用户信息记录失败: end_user_info_id={end_user_info_id}, error={str(e)}")
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"data": None,
|
|
||||||
"error": str(e)
|
|
||||||
}
|
|
||||||
except Exception as e:
|
|
||||||
db.rollback()
|
|
||||||
logger.error(f"用户别名记录更新失败: user_alias_id={user_alias_id}, error={str(e)}")
|
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"data": None,
|
"data": None,
|
||||||
|
|||||||
Reference in New Issue
Block a user