feat: 新增客户管理全模块功能
实现客户信息、客户部门、客户账号三个子模块的完整CRUD,包含: 1. 数据库实体、DTO、控制器、服务层代码 2. RBAC权限映射与菜单种子数据扩展 3. 前端路由与API封装 4. 数据权限隔离与鉴权逻辑 5. 配套工具脚本与测试验证清单
This commit is contained in:
1 parent
026ec34471
commit
1c80a24d1d
31 files changed
+26321
-653
No files matched your search
@@ -0,0 +1,97 @@
|
||||
// 客户管理模块验证脚本
|
||||
const http = require('http');
|
||||
|
||||
function request(options, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = http.request(options, (res) => {
|
||||
let data = '';
|
||||
res.on('data', (chunk) => (data += chunk));
|
||||
res.on('end', () => resolve({ statusCode: res.statusCode, body: data }));
|
||||
});
|
||||
req.on('error', reject);
|
||||
if (body) req.write(body);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
console.log('=== 步骤 1: 登录获取 admin token ===');
|
||||
const loginRes = await request(
|
||||
{
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/auth/login',
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
JSON.stringify({ username: 'admin', password: 'admin123456' })
|
||||
);
|
||||
const loginData = JSON.parse(loginRes.body);
|
||||
console.log('HTTP:', loginRes.statusCode, '| code:', loginData.code, '| message:', loginData.message);
|
||||
console.log('roles:', loginData.data.roles);
|
||||
console.log('menus count:', loginData.data.menus.length);
|
||||
console.log('top menu[0]:', loginData.data.menus[0].menuName, 'type:', loginData.data.menus[0].menuType, 'children:', loginData.data.menus[0].children?.length);
|
||||
|
||||
const token = loginData.data.accessToken;
|
||||
console.log('token 长度:', token.length);
|
||||
console.log('token 前 80 字符:', token.substring(0, 80));
|
||||
const authHeader = `Bearer ${token}`;
|
||||
console.log('Authorization header 长度:', authHeader.length);
|
||||
|
||||
console.log('\n=== 步骤 2: 调用 GET /api/customers 客户列表 ===');
|
||||
console.log('发送的 Authorization:', authHeader.substring(0, 100) + '...');
|
||||
const listRes = await request({
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/customers?page=1&pageSize=10',
|
||||
method: 'GET',
|
||||
headers: { Authorization: authHeader },
|
||||
});
|
||||
console.log('HTTP:', listRes.statusCode);
|
||||
console.log('Body:', listRes.body);
|
||||
|
||||
console.log('\n=== 步骤 3: 调用 GET /api/customers/options/all 精简列表 ===');
|
||||
const optRes = await request({
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/customers/options/all',
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
console.log('HTTP:', optRes.statusCode);
|
||||
console.log('Body:', optRes.body.substring(0, 500));
|
||||
|
||||
console.log('\n=== 步骤 4: 调用 GET /api/customer-departments 部门列表 ===');
|
||||
const depRes = await request({
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/customer-departments?page=1&pageSize=10',
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
console.log('HTTP:', depRes.statusCode);
|
||||
console.log('Body:', depRes.body);
|
||||
|
||||
console.log('\n=== 步骤 5: 调用 GET /api/customer-accounts 账号列表 ===');
|
||||
const accRes = await request({
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/customer-accounts?page=1&pageSize=10',
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
console.log('HTTP:', accRes.statusCode);
|
||||
console.log('Body:', accRes.body);
|
||||
|
||||
console.log('\n=== 步骤 6: 验证无 token 访问 → 401 ===');
|
||||
const noTokenRes = await request({
|
||||
hostname: '127.0.0.1',
|
||||
port: 7001,
|
||||
path: '/api/customers',
|
||||
method: 'GET',
|
||||
});
|
||||
console.log('HTTP:', noTokenRes.statusCode, '| Body:', noTokenRes.body);
|
||||
})().catch((err) => {
|
||||
console.error('脚本异常:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in new issue
Block a user