#!/usr/bin/env bash
set -euo pipefail
ROOT=/Users/lqt/work/zhct/zhctprompt/work/2026-06-04-city-subcenter-tech-solution/test-evidence/20260623-full-functional-retest
API=$ROOT/api
TOKEN=$(jq -r '.data._token' "$API/01-login-response.json")
call(){
  local name="$1" path="$2" data="$3"
  echo "## $name $path" >&2
  curl -sS --max-time 30 "http://8.147.119.215:8080${path}" \
    -X POST \
    -H "token: ${TOKEN}" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data "$data" | tee "$API/${name}.json" >/dev/null
}
call 02-identity-list /p/identity/lists 'page=1&pageSize=10'
call 03-equipment-list /p/equipment/lists 'type=&pageSize=10&page=1'
call 04-equipment-460-list /p/equipment/lists 'type=10&pageSize=10&page=1'
call 05-staff-list /p/staff/lists 'page=1&page_size=10&staff_name=&department_uuid=&mobile=&is_show=1'
call 06-dishes-list /p/dishes/lists 'page=1&page_size=10&name=&status=1'
call 07-consume-order-list /p/order/consume 'page=1&page_size=10&start_date=2026-06-23&end_date=2026-06-23'
call 08-meal-record-list /p/mealRecord/lists 'page=1&page_size=10&start_date=2026-06-23&end_date=2026-06-23'
python3 - <<'PY'
import json, pathlib
api=pathlib.Path('/Users/lqt/work/zhct/zhctprompt/work/2026-06-04-city-subcenter-tech-solution/test-evidence/20260623-full-functional-retest/api')
summary=[]
for p in sorted(api.glob('0[2-8]-*.json')):
    txt=p.read_text(errors='ignore')
    try: data=json.loads(txt)
    except Exception as e: summary.append({'file':p.name,'json':False,'error':str(e),'sample':txt[:200]}); continue
    bad = any(s in txt for s in ['SQLSTATE','没有数据权限','内部服务器错误','Bad Gateway']) or data.get('code') not in (0, None)
    summary.append({'file':p.name,'json':True,'code':data.get('code'),'message':data.get('message'), 'bad':bad, 'trace_id':data.get('trace_id')})
(api/'09-api-smoke-summary.json').write_text(json.dumps(summary,ensure_ascii=False,indent=2))
print(json.dumps(summary,ensure_ascii=False,indent=2))
PY
