backend-api-test-doc-qrcode-channel.md 9.57 KB

鎺ュ彛娴嬭瘯鏂囨。 鈥?qrcode-channel


1. 妯″潡姒傝

瀛楁 鍊?
妯″潡鍚嶇О qrcode-channel
妯″潡璇存槑 娓犻亾娲荤爜閰嶇疆绠$悊 鈥?澧炲垹鏀规煡 + 鍚敤/绂佺敤 + 鎵归噺鎿嶄綔 + 瀵煎嚭
璺敱鍓嶇紑 /api/v1/agent-group/qrcode
鏁版嵁搴撹〃 qrcode_channels
澶栭儴渚濊禆 WeComClient锛堝垱寤烘椿鐮侊級銆丱SSClient锛堝鍑猴級

2. 鎺ュ彛鍒楄〃

搴忓彿 鏂规硶 璺緞 璇存槑
1 POST /api/v1/agent-group/qrcode/create 鍒涘缓娓犻亾娲荤爜
2 PUT /api/v1/agent-group/qrcode/{qrcode_id} 鏇存柊娲荤爜
3 GET /api/v1/agent-group/qrcode/{qrcode_id} 鏌ヨ娲荤爜璇︽儏
4 GET /api/v1/agent-group/qrcode/list 鍒嗛〉鏌ヨ娲荤爜鍒楄〃
5 POST /api/v1/agent-group/qrcode/export 瀵煎嚭娲荤爜
6 PUT /api/v1/agent-group/qrcode/{qrcode_id}/disable 绂佺敤娲荤爜
7 PUT /api/v1/agent-group/qrcode/{qrcode_id}/enable 鍚敤娲荤爜
8 POST /api/v1/agent-group/qrcode/batch-status 鎵归噺鍚敤/绂佺敤

3. 鎺ュ彛璇︾粏璇存槑

3.1 鍒涘缓娓犻亾娲荤爜

璇锋眰鍙傛暟

鍙傛暟鍚? 浣嶇疆 绫诲瀷 蹇呭~ 璇存槑
qrcode_name body string 鏄? 娲荤爜鍚嶇О锛屾渶闀?0
position_code body string 鏄? 宀椾綅缂栫爜
employee_id body string 鏄? 鍛樺伐ID
employee_name body string 鏄? 鍛樺伐濮撳悕
wechat_user_id body string 鏄? 浼佸井鐢ㄦ埛ID
remark body string 鍚? 澶囨敞
welcome_message body string 鍚? 娆㈣繋璇?

鍝嶅簲鍙傛暟

瀛楁璺緞 绫诲瀷 璇存槑
qrcode_id integer 娲荤爜ID
qrcode_name string 娲荤爜鍚嶇О
qrcode_url string 浼佸井娲荤爜URL
channel_code string 娓犻亾缂栫爜锛堟牸寮忥細zdxs_{position_code}_{employee_id}锛?
status string 鐘舵€侊紝榛樿enable
agent_ids integer[] 鍏宠仈Agent ID鍒楄〃
agent_names string[] 鍏宠仈Agent鍚嶇О鍒楄〃
created_at string 鍒涘缓鏃堕棿

*閿欒鐮?

HTTP 鐘舵€佺爜 瑙﹀彂鏉′欢
400 宀椾綅涓嶅瓨鍦?
409 鍚屽矖浣嶅悓鍛樺伐娲荤爜宸插瓨鍦?

3.2 鏇存柊娲荤爜

璇锋眰鍙傛暟

鍙傛暟鍚? 浣嶇疆 绫诲瀷 蹇呭~ 璇存槑
qrcode_name body string 鏄? 娲荤爜鍚嶇О
remark body string 鍚? 澶囨敞
welcome_message body string 鍚? 娆㈣繋璇?

3.3 娲荤爜璇︽儏

鍝嶅簲鍙傛暟

瀛楁璺緞 绫诲瀷 璇存槑
qrcode_id integer 娲荤爜ID
qrcode_name string 娲荤爜鍚嶇О
employee_id string 鍛樺伐ID
employee_name string 鍛樺伐濮撳悕
position_name string 宀椾綅鍚嶇О
channel_code string 娓犻亾缂栫爜
qrcode_url string 娲荤爜URL
agent_ids integer[] Agent ID鍒楄〃
welcome_message string 娆㈣繋璇?
status string 鐘舵€?

3.4 绂佺敤/鍚敤娲荤爜

绂佺敤璇锋眰鍙傛暟

鍙傛暟鍚? 浣嶇疆 绫诲瀷 蹇呭~ 璇存槑
reason body string 鏄? 鍋滅敤鍘熷洜

鍝嶅簲鍙傛暟

瀛楁璺緞 绫诲瀷 璇存槑
success boolean 鏄惁鎴愬姛
previous_status string 鍙樻洿鍓嶇姸鎬?

3.5 鎵归噺鐘舵€佸彉鏇?

璇锋眰鍙傛暟

鍙傛暟鍚? 浣嶇疆 绫诲瀷 蹇呭~ 璇存槑
qrcode_ids body integer[] 鏄? 娲荤爜ID鍒楄〃锛岃嚦灏?涓?
target_status body string 鏄? enable/disable
reason body string 鍚? 鍘熷洜

鍝嶅簲鍙傛暟

瀛楁璺緞 绫诲瀷 璇存槑
success_count integer 鎴愬姛鏁?
failed_count integer 澶辫触鏁?
failed_list array 澶辫触鍒楄〃

4. 娴嬭瘯鍦烘櫙

搴忓彿 鍦烘櫙鍚嶇О 鍒嗙被 棰勬湡缁撴灉
1 鍒涘缓鎴愬姛 姝e父 qrcode_id>0, channel_code鏍煎紡姝g‘, 鍚瀹?宀椾綅Agent
2 宀椾綅涓嶅瓨鍦? 寮傚父 ValueError "宀椾綅涓嶅瓨鍦?
3 閲嶅鍒涘缓杩斿洖鍐茬獊 寮傚父 ValueError "宸插瓨鍦ㄥ悓宀椾綅娲荤爜"
4 channel_code鏍煎紡 姝e父 zdxs_{code}_{emp_id}
5 鑷姩鍖呭惈绠″+宀椾綅Agent 姝e父 agent_ids鍚玸teward鍜宮etric
6 鏇存柊鎴愬姛 姝e父 success=True
7 鏇存柊涓嶅瓨鍦? 寮傚父 ValueError
8 璇︽儏鏌ヨ 姝e父 qrcode_name, welcome_message姝g‘
9 璇︽儏涓嶅瓨鍦? 寮傚父 ValueError
10 鍒楄〃鎸夊憳宸ュ悕绛涢€? 姝e父 total=1
11 鍒楄〃鎸夌姸鎬佺瓫閫? 姝e父 status=enable 鈫?total=1
12 鍒楄〃鍏抽敭璇嶆悳绱? 姝e父 keyword鍖归厤channel_code
13 鍒楄〃绌虹粨鏋? 杈圭晫 total=0, list=[]
14 瀵煎嚭鎴愬姛 姝e父 total_count=1, file_url闈炵┖
15 绂佺敤鎴愬姛 姝e父 success=True, previous_status="enable"
16 鍚敤鎴愬姛 姝e父 previous_status="disable"
17 绂佺敤涓嶅瓨鍦? 寮傚父 ValueError
18 鎵归噺绂佺敤 姝e父 success_count=2, failed_count=0
19 鎵归噺閮ㄥ垎澶辫触 姝e父 success_count=1, failed_count=1
20 闆嗘垚锛氬垱寤衡啋鏌ヨ鈫掓洿鏂扳啋绂佺敤鈫掑惎鐢? 闆嗘垚 鍏ㄦ祦绋嬮€氳繃

5. 瀵瑰簲娴嬭瘯浠g爜

娴嬭瘯鏂囦欢锛歚backend/tests/test_qrcode_channel_api.py`

娴嬭瘯绫? 娴嬭瘯鏂规硶 瀵瑰簲鍦烘櫙
TestCreateQrcode test_create_success 1
TestCreateQrcode test_create_position_not_found 2
TestCreateQrcode test_create_duplicate_returns_409 3
TestCreateQrcode test_create_channel_code_format 4
TestCreateQrcode test_create_auto_includes_steward_and_position_agents 5
TestUpdateQrcode test_update_success 6
TestUpdateQrcode test_update_nonexistent 7
TestGetDetail test_detail_success 8
TestGetDetail test_detail_not_found 9
TestListQrcodes test_list_with_employee_name_filter 10
TestListQrcodes test_list_by_status 11
TestListQrcodes test_list_keyword_search 12
TestListQrcodes test_list_empty 13
TestExport test_export_success 14
TestDisableEnable test_disable_success 15
TestDisableEnable test_enable_success 16
TestDisableEnable test_disable_not_found 17
TestBatchStatus test_batch_disable 18
TestBatchStatus test_batch_with_failures 19
TestIntegrationFlow test_create_query_update_disable_enable 20

附录A 字段说明

A.1 通用响应字段

字段 类型 说明
code integer 业务响应码。200 表示成功,400 表示请求参数错误,401 表示未授权,403 表示无权限,404 表示资源不存在,409 表示资源冲突,500 表示服务器内部错误。
message string 响应说明。成功时固定为 success,失败时为具体错误原因。
data object/null 实际业务数据。成功时返回对象或分页结构,失败时固定为 null。

A.2 分页字段

如果接口是列表查询,则 data 一般使用分页结构:

字段 类型 说明
total integer 总记录数。
page integer 当前页码,默认从 1 开始。
page_size integer 每页数量,默认 20,最大 100。
list array 当前页数据列表。

A.3 常见时间字段

字段类型 格式 说明
created_at ISO 8601 string 创建时间。
updated_at ISO 8601 string 更新时间。
deleted_at ISO 8601 string 删除时间,仅删除类接口出现。
archived_at ISO 8601 string 归档时间,仅归档类接口出现。
triggered_at ISO 8601 string 触发时间,仅任务或同步类接口出现。

A.4 常见布尔与状态字段

字段 类型 说明
success boolean 是否成功,通常用于删除、归档、状态切换等动作接口。
status string 业务状态字段,具体取值以各接口正文说明为准,例如 enable、disable、active、archived、failed。

A.5 ID 与编码字段

字段类型 说明
*_id 业务主键或外部主键。不同模块含义不同,需结合接口正文说明理解。
*_code 业务编码字段,通常用于唯一标识某类对象,稳定性高于展示名称。

A.6 说明约定

  • 具体接口字段的业务含义,以各文档正文中的“请求参数”“响应参数”“示例响应”为准。
  • 本附录用于统一解释所有文档里重复出现的通用字段,避免重复写相同说明。
  • 如果某个接口没有分页能力,则不会返回 total / page / page_size / list。