feat(api): 长语音 voice_clip 后端(model+migration+scraper+sync+endpoint)
- VoiceClip model (BigInteger PK voice_clip_id, structured cols + raw_json)
- Alembic migration a1b2c3d4e5f6 (chains from 8c4f1d2a9e6b)
- scrape_voice_clips(client, user_id, *, channel, page_size) per-employee scraper
over POST /wechatweb/call/list {pageNum, pageSize, userId}; channel stamped
locally (wechat/whatsapp), startTime/endTime ms-epoch string -> int
- upsert_voice_clip repo + start_time/end_time/mp3_duration int coercion
- sync_voice_clips orchestrator: iterates distinct user_id across
WechatAccount + WhatsappAccount, stamps channel per account table
- scheduler ENTITY_FUNCS['voice_clips'] + added to daily 'all' job
- GET /api/voice-clips (user_id exact beats user_real_name fuzzy; channel;
company_code; start/end window on end_time; ordered end_time desc)
- VoiceClipOut schema + router registered in main.py
- tests: scraper (5) + API (11) = 16 new; full suite 370 green
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -249,6 +249,37 @@ class SmsOut(BaseModel):
|
||||
raw_json: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class VoiceClipOut(BaseModel):
|
||||
"""长语音 (voice_clip) row — a long audio segment from ``/wechatweb/call/list``.
|
||||
|
||||
The structured columns power the VoiceClipModal table (员工姓名 /
|
||||
企业串码 / 文件地址 / 录音开始时间 / 录音结束时间 / 录音时长); the verbatim
|
||||
upstream record is exposed as ``raw_json`` so the frontend can render any
|
||||
extra fields without a second endpoint. Picked up automatically via
|
||||
``from_attributes``.
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
voice_clip_id: int
|
||||
user_id: str
|
||||
channel: str
|
||||
user_real_name: str | None = None
|
||||
wx_id: str | None = None
|
||||
talker: str | None = None
|
||||
status: str | None = None
|
||||
is_send: bool | None = None
|
||||
company_code: str | None = None
|
||||
start_time: int | None = None
|
||||
end_time: int | None = None
|
||||
# OSS recording URL — surfaced so the modal can render an inline
|
||||
# ``<audio controls>`` player (see spec §6).
|
||||
oss_file_name: str | None = None
|
||||
mp3_duration: int | None = None
|
||||
duration_format: str | None = None
|
||||
raw_json: dict[str, Any] | None = None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Sync monitor
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user