feat: 屏蔽接口3(B端生发)
网关层直接拦截返回 1007,不再转发到 worker 池;worker 侧路由同步标记 deprecated 并短路返回,保留原参数签名避免老客户端裸 404。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -808,6 +808,7 @@ async def hair_grow_v2():
|
||||
"/api/v1/hair/grow-b",
|
||||
summary="接口3 B端生发(医生/操作端)",
|
||||
tags=["生发"],
|
||||
deprecated=True,
|
||||
description="""
|
||||
医生/操作端在用户照片上**手动用马克笔划线标注**目标发际线后,**只需上传这一张划线图**,返回:
|
||||
- 生发后效果图(系统检测划线 → 据此生成「植发 3 个月」效果)
|
||||
@@ -849,34 +850,9 @@ async def hair_grow_b(
|
||||
use_mask: bool = Form(default=True, description="是否画发际线(测试对比用)。false 时跳过划线检测、直接送划线图"),
|
||||
prompt: str = Form(default="填充遮罩区域的头发,皮肤加一点磨皮,再加一点美颜", description="ComfyUI 提示词,会替换工作流节点60的文本"),
|
||||
):
|
||||
# 划线图三选一取图(只需这一张)
|
||||
marked_raw, e = await resolve_image_bytes(marked_image_file, marked_image_url, marked_image_base64)
|
||||
if e is not None:
|
||||
return e
|
||||
|
||||
marked = cv2.imdecode(np.frombuffer(marked_raw, np.uint8), cv2.IMREAD_COLOR)
|
||||
if marked is None:
|
||||
return err(1008, "图片格式不支持(仅 JPG / PNG)")
|
||||
|
||||
try:
|
||||
from fastapi.concurrency import run_in_threadpool
|
||||
from hairline.service import generate_grow_b
|
||||
|
||||
res = await run_in_threadpool(generate_grow_b, marked, use_mask, prompt)
|
||||
if res["status"] == "no_face":
|
||||
return err(1001, "无法识别人像")
|
||||
if res["status"] == "no_line":
|
||||
return err(1001, "未检测到发际线划线,请确认划线图额头有清晰的手绘发际线")
|
||||
|
||||
grown_b64 = _png_to_jpg_b64(res["grown_png"]) if res["grown_png"] else None # 生发图 JPG
|
||||
data = {
|
||||
"hair_growth_image_base64": grown_b64,
|
||||
"hairline_type": "custom",
|
||||
}
|
||||
return ok(data)
|
||||
except Exception as ex: # noqa: BLE001
|
||||
logger.exception("接口3 处理异常")
|
||||
return err(1007, f"处理失败:{ex}")
|
||||
"""接口3 已屏蔽:调用直接返回错误,不再执行生发/ComfyUI 逻辑。
|
||||
保留路由(含原参数签名)避免老客户端裸 404,multipart 入参仍被接受但不处理。"""
|
||||
return err(1007, "接口3(/api/v1/hair/grow-b)已屏蔽,暂不提供服务")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
+8
-3
@@ -539,10 +539,15 @@ async def hair_grow(request: Request):
|
||||
return await _proxy(request, "/api/v1/hair/grow")
|
||||
|
||||
|
||||
@app.post("/api/v1/hair/grow-b", tags=["生发"])
|
||||
@app.post("/api/v1/hair/grow-b", tags=["生发"], deprecated=True)
|
||||
async def hair_grow_b(request: Request):
|
||||
"""接口3:B端生发"""
|
||||
return await _proxy(request, "/api/v1/hair/grow-b")
|
||||
"""接口3:B端生发(已屏蔽)"""
|
||||
# 在网关层直接拦截,不转发到 worker 池——对所有上游 worker 立即生效。
|
||||
import uuid as _uuid
|
||||
return JSONResponse(status_code=200, content={
|
||||
"code": 1007, "message": "接口3(/api/v1/hair/grow-b)已屏蔽,暂不提供服务",
|
||||
"request_id": f"gw-{_uuid.uuid4().hex[:8]}", "data": None,
|
||||
})
|
||||
|
||||
|
||||
@app.post("/api/v1/face/features", tags=["人脸分析"])
|
||||
|
||||
Reference in New Issue
Block a user