Commit 0f3b32a6 by baiquan

refactor(get_schema): 修改 get_schema 接口参数

- 将 GetSchemaRequest 中的 category_id 字段改为 json_data
- 移除 get_schema 函数内部的固定 json_data 结构,改为使用传入的参数
parent 6001cdb3
......@@ -51,7 +51,7 @@ class GenerateABogusRequest(BaseModel):
class GetSchemaRequest(BaseModel):
headers: dict
proxy_url: str
category_id: str
json_data: dict[str, any]
class CreateGoodsRequest(BaseModel):
headers: dict
......@@ -175,7 +175,7 @@ def generate_a_bogus_request(req: GenerateABogusRequest):
summary="获取类目参数",
)
def get_schema_request(req: GetSchemaRequest):
return execute_get_schema(req.headers, req.proxy_url, req.category_id)
return execute_get_schema(req.headers, req.proxy_url, req.json_data)
@sync_router.post(
......
......@@ -31,22 +31,22 @@ def generate_a_bogus(params:str | dict,data: dict,ua: str, params_type: int=1):
return result
def get_schema(headers: dict, proxy_url: str, category_id: str):
def get_schema(headers: dict, proxy_url: str, json_data: dict[str, any]):
"""获取商品类目"""
params = {
'appid': '1',
'_bid': 'ffa_goods',
'msToken': 'R-b2DYMiOLeDM9hJGu-ChiFknO18wFgHEk0gAZ6yW_0n3uCmbNRLJjqd_1JOtdmuUqWk_yO6jvOZizNvhhiJV5fyTMhX72vFvcamLeGAmoNoAEnLPWU4QH1pTkDzaeFMsslo5qx_cjx6RuQMWwkMWGhU_mr3xdR9',
}
json_data = {
'context': {
'feature': {},
'operation_type': 'select_normal,normal',
'category_id': category_id,
'ability': [],
},
'appid': 1,
}
# json_data = {
# 'context': {
# 'feature': {},
# 'operation_type': 'select_normal,normal',
# 'category_id': category_id,
# 'ability': [],
# },
# 'appid': 1,
# }
url = 'https://fxg.jinritemai.com/product/tproduct/getSchema'
if headers.get("User-Agent"):
ua = headers['User-Agent']
......
......@@ -183,10 +183,10 @@ def execute_generate_a_bogus(params:str | dict,data: dict,ua: str, params_type:
}
@shared_task(name='get_schema')
def execute_get_schema(headers: dict, proxy_url: str, category_id: str):
def execute_get_schema(headers: dict, proxy_url: str, json_data: dict[str, any]):
"""获取类目参数"""
try:
response = get_schema(headers, proxy_url, category_id)
response = get_schema(headers, proxy_url, json_data)
result = response.get('data', {})
logger.success(f'获取类目参数成功-->{str(result)[:200]}·······{str(result)[-200:]}')
return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment