Fix: #333/#335/#336 添加医嘱保存参数校验

1. Bug #333/#335/#336: 在 saveAdvice 方法入口添加参数非空校验
   - adviceSaveParam 为 null 时返回友好错误提示
   - adviceSaveList 为 null 或空时返回友好错误提示
2. 更新 Debug 日志标签为 BugFix#333/335/336
3. 增强异常场景的用户提示

修复人:关羽
修复日期:2026-04-08
This commit is contained in:
关羽
2026-04-08 23:11:42 +08:00
parent 03f408cb76
commit 098aae5aef
16 changed files with 984 additions and 1 deletions

100
zentao_api_example.py Normal file
View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
禅道 API 示例脚本 - 创建 Bug
"""
import requests
import json
# 禅道配置(需要根据实际情况修改)
ZENTAO_URL = "http://your-zentao-domain.com" # 禅道地址
ZENTAO_ACCOUNT = "your_username" # 禅道账号
ZENTAO_PASSWORD = "your_password" # 禅道密码
def get_token():
"""获取禅道 API Token"""
url = f"{ZENTAO_URL}/api.php/v1/tokens"
headers = {
"Content-Type": "application/json"
}
data = {
"account": ZENTAO_ACCOUNT,
"password": ZENTAO_PASSWORD
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
if response.status_code == 200 and result.get("status") == "success":
return result.get("token")
else:
raise Exception(f"获取 Token 失败: {result}")
def create_bug(token, product_id, title, steps, severity=2, priority=2, module='', assigned_to=''):
"""
创建Bug
参数:
token: API Token
product_id: 产品ID
title: Bug标题
steps: 重现步骤
severity: 严重程度 (1-4, 默认2: 一般)
priority: 优先级 (1-4, 默认2: 中等)
module: 模块ID (可选)
assigned_to: 指派给谁 (可选)
"""
url = f"{ZENTAO_URL}/api.php/v1/products/{product_id}/bugs"
headers = {
"Content-Type": "application/json",
"Authorization": token
}
data = {
"product": product_id,
"module": module,
"title": title,
"steps": steps,
"severity": severity,
"priority": priority,
"assignedTo": assigned_to
}
# 移除值为空的字段
data = {k: v for k, v in data.items() if v}
response = requests.post(url, headers=headers, json=data)
result = response.json()
if response.status_code == 200 and result.get("status") == "success":
print(f"✅ Bug 创建成功Bug ID: {result.get('data', {}).get('id')}")
return result
else:
print(f"❌ Bug 创建失败: {result}")
return None
def main():
try:
# 1. 获取 Token
print("正在获取 Token...")
token = get_token()
print(f"✓ Token 获取成功: {token[:10]}...")
# 2. 创建 Bug 示例
# TODO: 请根据实际情况修改以下参数
product_id = 100 # 产品ID需要在禅道中查询
title = "【测试】API 创建 Bug 示例"
steps = """1. 登录系统
2. 进入某个模块
3. 执行某个操作
4. 观察结果"""
print("\n正在创建 Bug...")
create_bug(token, product_id, title, steps)
except Exception as e:
print(f"❌ 发生错误: {e}")
if __name__ == "__main__":
main()