119 lines
4.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
const PORT = 3001;
// 静态文件服务
app.use('/docs', express.static(path.join(__dirname)));
// 主页路由
app.get('/', (req, res) => {
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>营收系统接口文档</title>
<meta charset="utf-8">
<style>
body { font-family: Arial, sans-serif; margin: 40px; line-height: 1.6; }
.header { background: #2c3e50; color: white; padding: 20px; border-radius: 8px; margin-bottom: 30px; }
.card { background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #007bff; }
.btn { display: inline-block; padding: 10px 20px; background: #007bff; color: white; text-decoration: none; border-radius: 5px; margin: 10px 5px; }
.btn:hover { background: #0056b3; }
pre { background: #f4f4f4; padding: 15px; border-radius: 5px; overflow-x: auto; }
.feature { margin: 10px 0; }
.feature strong { color: #2c3e50; }
</style>
</head>
<body>
<div class="header">
<h1>🏦 营收系统接口OpenAPI文档</h1>
<p>银行/第三方支付机构接口交互API文档 - 基于OpenAPI 3.0.3规范</p>
</div>
<div class="card">
<h2>📖 文档访问</h2>
<a href="https://editor.swagger.io/?url=${req.protocol}://${req.get('host')}/docs/main/openapi.yaml" class="btn" target="_blank">
在Swagger Editor中打开
</a>
<a href="/docs/main/openapi.yaml" class="btn" target="_blank">
查看原始YAML
</a>
<a href="/docs/README.md" class="btn" target="_blank">
使用说明
</a>
</div>
<div class="card">
<h2>🚀 主要功能</h2>
<div class="feature"><strong>账单管理:</strong> 查询、缴费、红冲</div>
<div class="feature"><strong>代扣管理:</strong> 签约、解约、送盘、回盘</div>
<div class="feature"><strong>多格式支持:</strong> XML (GBK) 和 JSON (UTF-8)</div>
<div class="feature"><strong>安全认证:</strong> 3DES、SM2、SM4多种加密算法</div>
<div class="feature"><strong>错误处理:</strong> 统一错误码和详细错误信息</div>
</div>
<div class="card">
<h2>📋 API概览</h2>
<ul>
<li><strong>POST</strong> /api/app/billQuery/query - 账单查询</li>
<li><strong>POST</strong> /api/app/billPay/pay - 账单缴费</li>
<li><strong>POST</strong> /api/app/payInvalid/payInvalid - 账单红冲</li>
<li><strong>POST</strong> /api/app/bankWithholding/signing - 代扣签约</li>
<li><strong>POST</strong> /api/app/bankWithholding/termination - 代扣解约</li>
<li><strong>POST</strong> /api/app/bankWithholding/sendDisc - 代扣送盘</li>
<li><strong>POST</strong> /api/app/bankWithholding/backDisc - 代扣回盘</li>
</ul>
</div>
<div class="card">
<h2>🔧 快速测试</h2>
<p>账单查询示例JSON格式:</p>
<pre>{
"Version": "1.0.1",
"InstId": "00001",
"TranCode": "Query",
"TranDate": "20240101",
"TranSeq": "123456789012",
"BillKey": "123456",
"CompanyId": "654321"
}</pre>
</div>
<div class="card">
<h2>🛠️ 开发工具</h2>
<p>推荐使用以下工具进行API开发和测试</p>
<ul>
<li><a href="https://www.postman.com/" target="_blank">Postman</a> - API测试工具</li>
<li><a href="https://insomnia.rest/" target="_blank">Insomnia</a> - REST客户端</li>
<li><a href="https://editor.swagger.io/" target="_blank">Swagger Editor</a> - 在线编辑器</li>
</ul>
</div>
<footer style="text-align: center; margin-top: 50px; color: #666;">
<p>营收系统接口API v1.0.0 | OpenAPI 3.0.3</p>
</footer>
</body>
</html>
`);
});
// 启动服务器
app.listen(PORT, () => {
console.log('🚀 营收系统接口文档服务已启动!');
console.log(`📖 访问地址: http://localhost:${PORT}`);
console.log(`📋 Swagger Editor: https://editor.swagger.io/?url=http://localhost:${PORT}/docs/main/openapi.yaml`);
console.log('');
console.log('📁 文档结构:');
console.log('├── docs/main/openapi.yaml # 主入口文档');
console.log('├── docs/main/components/ # 通用组件');
console.log('└── docs/main/paths/ # API路径定义');
console.log('');
console.log('按 Ctrl+C 停止服务');
});
module.exports = app;