# -*- coding: utf-8 -*- """票 06 排障 3:SHOW TRIGGERS + 精细重放实验(正常路径先验,再空表单)。""" import io, sys import pymysql import requests sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') BASE = 'http://localhost:8080' conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456', database='crm', charset='utf8mb4', autocommit=True) cur = conn.cursor() cur.execute("SHOW TRIGGERS") rows = cur.fetchall() print('[triggers]', len(rows)) for r in rows: print(' ', r[:4]) # ---- 精细重放 ---- r = requests.get(f'{BASE}/api/auth/debug/token', params={'userId': '739564171091247104'}, timeout=15) H = {'Authorization': f"Bearer {r.json()['data']}"} def api(method, path, form=None, params=None): headers = dict(H) data = None if form is not None: headers['Content-Type'] = 'application/x-www-form-urlencoded' data = form b = requests.request(method, BASE + path, headers=headers, data=data, params=params, timeout=30).json() print(f" <- {method} {path} code={b.get('code')} msg={str(b.get('message'))[:40]}") return b def db_full(oid, label): cur.execute("SELECT opp_name, opp_source, bid_form, province_code, city_code, locality_type, " "update_time FROM opportunity WHERE id=%s", (int(oid),)) print(f" [DB {label}]", cur.fetchall()) base = {'opportunityName': '票06排障Y', 'oppSource': 'opp_source_02', 'industryCode': 'gov', 'localityType': 'locality_type_01', 'bidForm': 'bid_form_01', 'provinceCode': '510000', 'cityCode': '510100', 'partyAClear': 1, 'partyA': '票06排障', 'remark': '票06排障'} b = api('POST', '/api/opportunity', form=base) y = b.get('data') print('Y id =', y) db_full(y, 'Y1 创建后') print("\n-- Y2: edit 只传 oppName=新名(正常部分更新路径)--") api('POST', '/api/opportunity/edit', form={'id': y, 'oppName': '票06排障Y改名'}) db_full(y, 'Y2 后') print("\n-- Y3: edit 只传 id(空表单)--") api('POST', '/api/opportunity/edit', form={'id': y}) db_full(y, 'Y3 后') # 清理 cur.execute("UPDATE opportunity SET deleted=1 WHERE remark LIKE %s", ('票06排障%',)) print('\nCLEANUP rows=', cur.rowcount) conn.close()