Files
ctms/docs/postman/setup-config.postman_collection.json
T
2026-05-25 14:35:24 +08:00

232 lines
8.1 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"info": {
"name": "CTMS Setup Config API (Excel)",
"description": "立项配置接口联调集合(登录 -> 获取 -> 保存 -> 发布 -> 导出Excel -> 导入Excel",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "1. 获取登录公钥",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/api/v1/auth/login-key",
"host": ["{{base_url}}"],
"path": ["api", "v1", "auth", "login-key"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.collectionVariables.set('login_key_id', json.key_id || '');",
"pm.collectionVariables.set('login_challenge', json.challenge || '');",
"pm.collectionVariables.set('login_public_key', json.public_key || '');",
"pm.collectionVariables.set('login_ciphertext', '<请生成 AES-GCM 密文,并用 login_public_key 通过 RSA-OAEP-SHA256 加密 AES key 后填写外层 Base64 envelope>');"
]
}
}
]
},
{
"name": "2. 加密登录(获取 Token",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"key_id\": \"{{login_key_id}}\",\n \"challenge\": \"{{login_challenge}}\",\n \"ciphertext\": \"{{login_ciphertext}}\"\n}"
},
"url": {
"raw": "{{base_url}}/api/v1/auth/login",
"host": ["{{base_url}}"],
"path": ["api", "v1", "auth", "login"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.collectionVariables.set('token', json.access_token || '');"
]
}
}
]
},
{
"name": "2. 获取立项配置",
"request": {
"method": "GET",
"header": [
{ "key": "Authorization", "value": "Bearer {{token}}" }
],
"url": {
"raw": "{{base_url}}/api/v1/studies/{{study_id}}/setup-config",
"host": ["{{base_url}}"],
"path": ["api", "v1", "studies", "{{study_id}}", "setup-config"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.collectionVariables.set('setup_version', String(json.version || 1));"
]
}
}
]
},
{
"name": "3. 保存草稿",
"request": {
"method": "PUT",
"header": [
{ "key": "Authorization", "value": "Bearer {{token}}" },
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"expected_version\": {{setup_version}},\n \"data\": {\n \"projectMilestones\": [],\n \"enrollmentPlan\": {\n \"totalTarget\": {{target_total}},\n \"startDate\": \"{{plan_start_date}}\",\n \"endDate\": \"{{plan_end_date}}\",\n \"monthlyGoalNote\": \"Postman save draft\",\n \"stageBreakdown\": \"phase-1\"\n },\n \"siteMilestones\": [],\n \"siteEnrollmentPlans\": [],\n \"monitoringStrategies\": [],\n \"centerConfirm\": []\n }\n}"
},
"url": {
"raw": "{{base_url}}/api/v1/studies/{{study_id}}/setup-config",
"host": ["{{base_url}}"],
"path": ["api", "v1", "studies", "{{study_id}}", "setup-config"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.collectionVariables.set('setup_version', String(json.version || pm.collectionVariables.get('setup_version') || '1'));"
]
}
}
]
},
{
"name": "4. 发布配置",
"request": {
"method": "POST",
"header": [
{ "key": "Authorization", "value": "Bearer {{token}}" },
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"expected_version\": {{setup_version}}\n}"
},
"url": {
"raw": "{{base_url}}/api/v1/studies/{{study_id}}/setup-config/publish",
"host": ["{{base_url}}"],
"path": ["api", "v1", "studies", "{{study_id}}", "setup-config", "publish"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.test('publish status is PUBLISHED', function () { pm.expect(json.publish_status).to.eql('PUBLISHED'); });",
"pm.collectionVariables.set('setup_version', String(json.version || pm.collectionVariables.get('setup_version') || '1'));"
]
}
}
]
},
{
"name": "5. 导出配置 Excel",
"request": {
"method": "GET",
"header": [
{ "key": "Authorization", "value": "Bearer {{token}}" }
],
"url": {
"raw": "{{base_url}}/api/v1/studies/{{study_id}}/setup-config/export-excel",
"host": ["{{base_url}}"],
"path": ["api", "v1", "studies", "{{study_id}}", "setup-config", "export-excel"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });"
]
}
}
]
},
{
"name": "6. 导入配置 Excel",
"request": {
"method": "POST",
"header": [
{ "key": "Authorization", "value": "Bearer {{token}}" }
],
"body": {
"mode": "formdata",
"formdata": [
{ "key": "expected_version", "value": "{{setup_version}}", "type": "text" },
{ "key": "file", "type": "file", "src": "{{excel_file_path}}" }
]
},
"url": {
"raw": "{{base_url}}/api/v1/studies/{{study_id}}/setup-config/import-excel",
"host": ["{{base_url}}"],
"path": ["api", "v1", "studies", "{{study_id}}", "setup-config", "import-excel"]
}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', function () { pm.response.to.have.status(200); });",
"var json = pm.response.json();",
"pm.collectionVariables.set('setup_version', String(json.version || pm.collectionVariables.get('setup_version') || '1'));"
]
}
}
]
}
],
"variable": [
{ "key": "base_url", "value": "http://localhost:8888" },
{ "key": "email", "value": "admin@huapont.cn" },
{ "key": "password", "value": "admin123" },
{ "key": "study_id", "value": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" },
{ "key": "token", "value": "" },
{ "key": "setup_version", "value": "1" },
{ "key": "target_total", "value": "123" },
{ "key": "plan_start_date", "value": "2026-02-01" },
{ "key": "plan_end_date", "value": "2026-12-31" },
{ "key": "excel_file_path", "value": "" }
]
}