refactor(light): 移除废弃的LightPanel路由端点
移除已注释掉的三个废弃路由端点,这些端点不再使用且功能已被其他路由替代。清理代码以保持代码库整洁。
This commit is contained in:
@@ -11,60 +11,60 @@ from typing import Dict, Any
|
||||
# 创建路由器实例
|
||||
light_router = APIRouter()
|
||||
|
||||
@light_router.get("/scripts", response_model=ResponseModel[List[Dict[str, Any]]])
|
||||
async def get_all_lightpanel_scripts():
|
||||
"""
|
||||
获取所有LightPanel脚本数据
|
||||
# @light_router.get("/scripts", response_model=ResponseModel[List[Dict[str, Any]]])
|
||||
# async def get_all_lightpanel_scripts():
|
||||
# """
|
||||
# 获取所有LightPanel脚本数据
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含所有脚本数据的统一响应格式
|
||||
"""
|
||||
try:
|
||||
scripts = fetch_all_lightpanel_scripts()
|
||||
return success_response(data=scripts, message="成功获取所有LightPanel脚本")
|
||||
except Exception as e:
|
||||
return error_response(message=f"获取LightPanel脚本失败: {str(e)}", code=500)
|
||||
# Returns:
|
||||
# ResponseModel: 包含所有脚本数据的统一响应格式
|
||||
# """
|
||||
# try:
|
||||
# scripts = fetch_all_lightpanel_scripts()
|
||||
# return success_response(data=scripts, message="成功获取所有LightPanel脚本")
|
||||
# except Exception as e:
|
||||
# return error_response(message=f"获取LightPanel脚本失败: {str(e)}", code=500)
|
||||
|
||||
@light_router.get("/script/{code}", response_model=ResponseModel[Dict[str, Any]])
|
||||
async def get_lightpanel_script(code: str):
|
||||
"""
|
||||
根据code获取特定的LightPanel灯牌
|
||||
# @light_router.get("/script/{code}", response_model=ResponseModel[Dict[str, Any]])
|
||||
# async def get_lightpanel_script(code: str):
|
||||
# """
|
||||
# 根据code获取特定的LightPanel灯牌
|
||||
|
||||
Args:
|
||||
code (str): 信息类型
|
||||
# Args:
|
||||
# code (str): 信息类型
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含特定灯牌数据的统一响应格式
|
||||
"""
|
||||
try:
|
||||
script = get_lightpanel_script_by_code(code)
|
||||
if script:
|
||||
return success_response(data=script, message=f"成功获取code为{code}的LightPanel灯牌")
|
||||
else:
|
||||
return error_response(message=f"未找到code为{code}的LightPanel灯牌", code=404)
|
||||
except Exception as e:
|
||||
return error_response(message=f"获取LightPanel灯牌失败: {str(e)}", code=500)
|
||||
# Returns:
|
||||
# ResponseModel: 包含特定灯牌数据的统一响应格式
|
||||
# """
|
||||
# try:
|
||||
# script = get_lightpanel_script_by_code(code)
|
||||
# if script:
|
||||
# return success_response(data=script, message=f"成功获取code为{code}的LightPanel灯牌")
|
||||
# else:
|
||||
# return error_response(message=f"未找到code为{code}的LightPanel灯牌", code=404)
|
||||
# except Exception as e:
|
||||
# return error_response(message=f"获取LightPanel灯牌失败: {str(e)}", code=500)
|
||||
|
||||
@light_router.get("/answers/{user_id}", response_model=ResponseModel[Dict[str, Any]])
|
||||
async def get_answers_by_user(user_id: str):
|
||||
"""
|
||||
根据用户ID获取用户的灯牌数据
|
||||
# @light_router.get("/answers/{user_id}", response_model=ResponseModel[Dict[str, Any]])
|
||||
# async def get_answers_by_user(user_id: str):
|
||||
# """
|
||||
# 根据用户ID获取用户的灯牌数据
|
||||
|
||||
Args:
|
||||
user_id (str): 用户的customer_wechat_id
|
||||
# Args:
|
||||
# user_id (str): 用户的customer_wechat_id
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户灯牌数据的统一响应格式
|
||||
"""
|
||||
try:
|
||||
answers = get_answers_by_user_id(user_id)
|
||||
if answers is not None:
|
||||
return success_response(data=answers, message=f"成功获取用户{user_id}的灯牌数据")
|
||||
else:
|
||||
# 未找到数据时返回空字典而不是空字符串
|
||||
return success_response(data={}, message=f"未找到用户{user_id}的灯牌数据")
|
||||
except Exception as e:
|
||||
return error_response(message=f"获取用户灯牌数据失败: {str(e)}", code=500)
|
||||
# Returns:
|
||||
# ResponseModel: 包含用户灯牌数据的统一响应格式
|
||||
# """
|
||||
# try:
|
||||
# answers = get_answers_by_user_id(user_id)
|
||||
# if answers is not None:
|
||||
# return success_response(data=answers, message=f"成功获取用户{user_id}的灯牌数据")
|
||||
# else:
|
||||
# # 未找到数据时返回空字典而不是空字符串
|
||||
# return success_response(data={}, message=f"未找到用户{user_id}的灯牌数据")
|
||||
# except Exception as e:
|
||||
# return error_response(message=f"获取用户灯牌数据失败: {str(e)}", code=500)
|
||||
|
||||
|
||||
@light_router.get("/user-scripts/{user_id}", response_model=ResponseModel[List[Dict[str, Any]]])
|
||||
|
||||
Reference in New Issue
Block a user