204 lines
7.0 KiB
JSON
204 lines
7.0 KiB
JSON
{
|
||
"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. 登录(获取 Token)",
|
||
"request": {
|
||
"method": "POST",
|
||
"header": [
|
||
{ "key": "Content-Type", "value": "application/json" }
|
||
],
|
||
"body": {
|
||
"mode": "raw",
|
||
"raw": "{\n \"email\": \"{{email}}\",\n \"password\": \"{{password}}\"\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" },
|
||
{ "key": "email", "value": "admin@example.com" },
|
||
{ "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": "" }
|
||
]
|
||
}
|