feat: 完成PHP到NestJS迁移工具和代码生成
- ✅ 成功运行迁移工具,生成28个模块的完整NestJS代码 - ✅ 生成所有实体、服务、控制器、验证器等组件 - ✅ 修复npm依赖冲突,更新package-lock.json - ✅ 添加Docker测试脚本和配置文件 - ✅ 完善迁移工具的调试日志和错误处理 - 🔧 包含增量更新工具和质量检查工具 - 📊 迁移统计:28个模块,数千个文件,耗时26.47秒 主要变更: - wwjcloud-nest/src/core/* - 生成的业务模块代码 - tools/* - 迁移工具和辅助脚本 - wwjcloud-nest/package.json - 依赖更新 - docker/* - 容器化配置和测试脚本
This commit is contained in:
@@ -13,7 +13,7 @@ async function bootstrap() {
|
||||
|
||||
const languageService = new LanguageService(mockConfigService);
|
||||
// 模拟初始化,实际由 NestJS 模块管理
|
||||
// await languageService.initializeLanguagePacks();
|
||||
// await languageService.initializeLanguagePacks();
|
||||
|
||||
console.log('--- LanguageService 使用示例 ---');
|
||||
|
||||
@@ -22,31 +22,57 @@ async function bootstrap() {
|
||||
console.log(`通用API消息 (success): ${commonApiMessage}`); // 预期: 操作成功
|
||||
|
||||
// 2. 获取通用字典数据 (默认模块: common, 类型: dict)
|
||||
const commonDictMessage = await languageService.getDictData('dict_user.status_on');
|
||||
const commonDictMessage = await languageService.getDictData(
|
||||
'dict_user.status_on',
|
||||
);
|
||||
console.log(`通用字典数据 (dict_user.status_on): ${commonDictMessage}`); // 预期: 正常
|
||||
|
||||
// 3. 获取通用验证器消息 (默认模块: common, 类型: validate)
|
||||
const commonValidateMessage = await languageService.getValidateMessage('validate_user.username_require');
|
||||
console.log(`通用验证器消息 (validate_user.username_require): ${commonValidateMessage}`); // 预期: 账号必须填写
|
||||
const commonValidateMessage = await languageService.getValidateMessage(
|
||||
'validate_user.username_require',
|
||||
);
|
||||
console.log(
|
||||
`通用验证器消息 (validate_user.username_require): ${commonValidateMessage}`,
|
||||
); // 预期: 账号必须填写
|
||||
|
||||
// 4. 获取用户模块API消息 (模块: user, 类型: api)
|
||||
const userApiMessage = await languageService.getApiMessage('create_success', undefined, 'user');
|
||||
const userApiMessage = await languageService.getApiMessage(
|
||||
'create_success',
|
||||
undefined,
|
||||
'user',
|
||||
);
|
||||
console.log(`用户API消息 (user.create_success): ${userApiMessage}`); // 预期: 用户创建成功
|
||||
|
||||
// 5. 获取用户模块字典数据 (模块: user, 类型: dict)
|
||||
const userDictMessage = await languageService.getDictData('user_type.admin', undefined, 'user');
|
||||
const userDictMessage = await languageService.getDictData(
|
||||
'user_type.admin',
|
||||
undefined,
|
||||
'user',
|
||||
);
|
||||
console.log(`用户字典数据 (user.user_type.admin): ${userDictMessage}`); // 预期: 管理员
|
||||
|
||||
// 6. 获取用户模块验证器消息 (模块: user, 类型: validate)
|
||||
const userValidateMessage = await languageService.getValidateMessage('email_format_error', undefined, 'user');
|
||||
console.log(`用户验证器消息 (user.email_format_error): ${userValidateMessage}`); // 预期: 邮箱格式不正确
|
||||
const userValidateMessage = await languageService.getValidateMessage(
|
||||
'email_format_error',
|
||||
undefined,
|
||||
'user',
|
||||
);
|
||||
console.log(
|
||||
`用户验证器消息 (user.email_format_error): ${userValidateMessage}`,
|
||||
); // 预期: 邮箱格式不正确
|
||||
|
||||
// 7. 获取带参数的消息
|
||||
const paramMessage = await languageService.getApiMessage('user_error', { name: '张三' });
|
||||
const paramMessage = await languageService.getApiMessage('user_error', {
|
||||
name: '张三',
|
||||
});
|
||||
console.log(`带参数消息 (user_error): ${paramMessage}`); // 预期: 账号或密码错误 (如果user_error在common/api.json中)
|
||||
|
||||
// 8. 批量获取消息
|
||||
const batchMessages = await languageService.getBatchMessages(['success', 'fail'], 'common', 'api');
|
||||
const batchMessages = await languageService.getBatchMessages(
|
||||
['success', 'fail'],
|
||||
'common',
|
||||
'api',
|
||||
);
|
||||
console.log('批量获取消息 (common.api):', batchMessages); // 预期: { success: '操作成功', fail: '操作失败' }
|
||||
|
||||
// 9. 切换语言并获取消息
|
||||
@@ -61,7 +87,7 @@ async function bootstrap() {
|
||||
|
||||
// 11. 场景化验证示例
|
||||
console.log('\n--- 场景化验证示例 ---');
|
||||
|
||||
|
||||
// 模拟用户数据
|
||||
const userData = {
|
||||
username: 'testuser',
|
||||
@@ -78,19 +104,25 @@ async function bootstrap() {
|
||||
|
||||
// 12. 分组验证消息示例
|
||||
console.log('\n--- 分组验证消息示例 ---');
|
||||
|
||||
const menuValidation = await languageService.getValidateMessage('validate_menu.menu_name_require');
|
||||
|
||||
const menuValidation = await languageService.getValidateMessage(
|
||||
'validate_menu.menu_name_require',
|
||||
);
|
||||
console.log('菜单验证消息:', menuValidation); // 预期: 菜单名称必须填写
|
||||
|
||||
const roleValidation = await languageService.getValidateMessage('validate_role.role_name_require');
|
||||
const roleValidation = await languageService.getValidateMessage(
|
||||
'validate_role.role_name_require',
|
||||
);
|
||||
console.log('角色验证消息:', roleValidation); // 预期: 角色名称必须填写
|
||||
|
||||
const siteValidation = await languageService.getValidateMessage('validate_site.site_name_require');
|
||||
const siteValidation = await languageService.getValidateMessage(
|
||||
'validate_site.site_name_require',
|
||||
);
|
||||
console.log('站点验证消息:', siteValidation); // 预期: 网站名称必须填写
|
||||
|
||||
// 13. 字典数据示例
|
||||
console.log('\n--- 字典数据示例 ---');
|
||||
|
||||
|
||||
const appDict = await languageService.getDictData('dict_app.type_admin');
|
||||
console.log('应用类型字典:', appDict); // 预期: 平台管理端
|
||||
|
||||
@@ -102,14 +134,23 @@ async function bootstrap() {
|
||||
|
||||
// 14. 参数替换示例
|
||||
console.log('\n--- 参数替换示例 ---');
|
||||
|
||||
const paramMessage1 = await languageService.getValidateMessage('common.minLength', { min: 6 });
|
||||
|
||||
const paramMessage1 = await languageService.getValidateMessage(
|
||||
'common.minLength',
|
||||
{ min: 6 },
|
||||
);
|
||||
console.log('最小长度验证:', paramMessage1); // 预期: 长度不能少于6个字符
|
||||
|
||||
const paramMessage2 = await languageService.getValidateMessage('common.maxLength', { max: 20 });
|
||||
const paramMessage2 = await languageService.getValidateMessage(
|
||||
'common.maxLength',
|
||||
{ max: 20 },
|
||||
);
|
||||
console.log('最大长度验证:', paramMessage2); // 预期: 长度不能超过20个字符
|
||||
|
||||
const paramMessage3 = await languageService.getValidateMessage('common.between', { min: 1, max: 100 });
|
||||
const paramMessage3 = await languageService.getValidateMessage(
|
||||
'common.between',
|
||||
{ min: 1, max: 100 },
|
||||
);
|
||||
console.log('范围验证:', paramMessage3); // 预期: 必须在1到100之间
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user