chore: 初始化项目结构并添加基础配置文件
添加后端API和前端项目的初始目录结构,包括应用层模块、工具模块和模型定义 配置前后端的.dockerignore文件以排除开发环境文件 添加前端样式文件,包括字体、Tailwind CSS和主题配置 初始化Python虚拟环境中的类型标记文件
This commit is contained in:
0
后端-孕期报告解读-api/app/utils/__init__.py
Normal file
0
后端-孕期报告解读-api/app/utils/__init__.py
Normal file
19
后端-孕期报告解读-api/app/utils/helpers.py
Normal file
19
后端-孕期报告解读-api/app/utils/helpers.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import Optional
|
||||
|
||||
from beanie import PydanticObjectId
|
||||
from fastapi import HTTPException
|
||||
|
||||
|
||||
def parse_object_id(value: str) -> PydanticObjectId:
|
||||
"""Parse a string to PydanticObjectId, raising 400 on invalid format."""
|
||||
try:
|
||||
return PydanticObjectId(value)
|
||||
except Exception:
|
||||
raise HTTPException(status_code=400, detail="无效的ID格式")
|
||||
|
||||
|
||||
def mask_name(name: Optional[str]) -> str:
|
||||
"""隐私脱敏:姓名"""
|
||||
if not name or len(name) < 2:
|
||||
return name or ""
|
||||
return name[0] + "*" * (len(name) - 1)
|
||||
Reference in New Issue
Block a user