169 lines
6.6 KiB
HTML
169 lines
6.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>出国审批API调试</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
.section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; }
|
|
.result { background: #f5f5f5; padding: 10px; margin: 10px 0; white-space: pre-wrap; }
|
|
button { padding: 8px 16px; margin: 5px; }
|
|
input { padding: 5px; margin: 5px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>出国审批API调试工具</h1>
|
|
|
|
<div class="section">
|
|
<h3>1. 登录获取Token</h3>
|
|
<input type="text" id="username" placeholder="用户名" value="admin">
|
|
<input type="password" id="password" placeholder="密码" value="admin123">
|
|
<button onclick="login()">登录</button>
|
|
<div class="result" id="loginResult"></div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h3>2. 测试待审批API</h3>
|
|
<button onclick="testPendingAPI()">测试待审批列表API</button>
|
|
<div class="result" id="pendingResult"></div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h3>3. 测试直接查询API</h3>
|
|
<button onclick="testDirectQuery()">测试直接查询API</button>
|
|
<div class="result" id="directResult"></div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h3>4. 测试调试API</h3>
|
|
<button onclick="testDebugAPI()">测试调试API</button>
|
|
<div class="result" id="debugResult"></div>
|
|
</div>
|
|
|
|
<script>
|
|
let token = '';
|
|
|
|
async function login() {
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
try {
|
|
// 首先获取加密配置
|
|
const configResponse = await fetch('http://localhost:8080/auth/encrypt/config', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
if (!configResponse.ok) {
|
|
throw new Error('获取加密配置失败');
|
|
}
|
|
|
|
const configData = await configResponse.json();
|
|
document.getElementById('loginResult').textContent =
|
|
'加密配置获取成功:\n' + JSON.stringify(configData, null, 2);
|
|
|
|
// 使用简单登录(如果加密失败的话)
|
|
const loginResponse = await fetch('http://localhost:8080/auth/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
username: username,
|
|
password: password
|
|
})
|
|
});
|
|
|
|
const loginData = await loginResponse.json();
|
|
|
|
if (loginData.code === 200) {
|
|
token = loginData.data.access_token;
|
|
document.getElementById('loginResult').textContent +=
|
|
'\n\n登录成功!\nToken: ' + token.substring(0, 50) + '...';
|
|
} else {
|
|
document.getElementById('loginResult').textContent +=
|
|
'\n\n登录失败: ' + loginData.msg;
|
|
}
|
|
|
|
} catch (error) {
|
|
document.getElementById('loginResult').textContent = '登录错误: ' + error.message;
|
|
}
|
|
}
|
|
|
|
async function testPendingAPI() {
|
|
if (!token) {
|
|
document.getElementById('pendingResult').textContent = '请先登录获取Token';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('http://localhost:8080/rs/overseas/application/pending/list?pageNum=1&pageSize=10&tenantId=000000', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer ' + token
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
document.getElementById('pendingResult').textContent =
|
|
'待审批API响应:\n' + JSON.stringify(data, null, 2);
|
|
|
|
} catch (error) {
|
|
document.getElementById('pendingResult').textContent = '请求错误: ' + error.message;
|
|
}
|
|
}
|
|
|
|
async function testDirectQuery() {
|
|
if (!token) {
|
|
document.getElementById('directResult').textContent = '请先登录获取Token';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('http://localhost:8080/rs/overseas/application/list?pageNum=1&pageSize=10&status=0', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer ' + token
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
document.getElementById('directResult').textContent =
|
|
'直接查询API响应:\n' + JSON.stringify(data, null, 2);
|
|
|
|
} catch (error) {
|
|
document.getElementById('directResult').textContent = '请求错误: ' + error.message;
|
|
}
|
|
}
|
|
|
|
async function testDebugAPI() {
|
|
if (!token) {
|
|
document.getElementById('debugResult').textContent = '请先登录获取Token';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('http://localhost:8080/rs/overseas/application/pending/debug?pageNum=1&pageSize=10', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer ' + token
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
document.getElementById('debugResult').textContent =
|
|
'调试API响应:\n' + JSON.stringify(data, null, 2);
|
|
|
|
} catch (error) {
|
|
document.getElementById('debugResult').textContent = '请求错误: ' + error.message;
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |