25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
import requests, json, sys
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
# First login to get a token
|
|
s = requests.Session()
|
|
r = s.get('http://localhost:18080/healthlink-his/captchaImage')
|
|
captcha = r.json()
|
|
|
|
login_data = {'username': 'admin', 'password': 'admin123', 'code': '1', 'uuid': captcha.get('uuid', ''), 'tenantId': 1}
|
|
r = s.post('http://localhost:18080/healthlink-his/login', json=login_data)
|
|
resp = r.json()
|
|
token = resp.get('token', '')
|
|
print('Login:', resp.get('code'), 'Token:', token[:20] if token else 'none')
|
|
|
|
if token:
|
|
headers = {'Authorization': 'Bearer ' + token}
|
|
# Test discussion page
|
|
r = s.get('http://localhost:18080/healthlink-his/preop-discussion/page', headers=headers, params={'pageNo': 1, 'pageSize': 5})
|
|
resp = r.json()
|
|
print('Discussion page code:', resp.get('code'))
|
|
data = resp.get('data', {})
|
|
print('Records:', len(data.get('records', [])) if data else 0)
|
|
print('Total:', data.get('total', 0) if data else 0)
|
|
if data and data.get('records'):
|
|
print('First record:', json.dumps(data['records'][0], ensure_ascii=False, indent=2)[:500]) |