From c04fabedd323cb94ac1d6b1a5a4febd349f5c68a Mon Sep 17 00:00:00 2001 From: zhangsz Date: Tue, 21 Jan 2025 14:45:18 +0800 Subject: [PATCH] feat: user portal support i18n --- .../resources/i18n/messages_en_US.properties | 18 +++++++++++++++ .../resources/i18n/messages_zh_CN.properties | 16 ++++++++++++++ .../java/org/wfc/user/WfcUserApplication.java | 2 +- .../wfc/user/controller/ClientController.java | 5 +++-- .../user/controller/UProfileController.java | 22 ++++++++++--------- .../wfc/user/controller/UUserController.java | 4 ++-- .../wfc-user/src/main/resources/banner.txt | 7 +++++- 7 files changed, 58 insertions(+), 16 deletions(-) diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties index bdc0879..af53a9f 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_en_US.properties @@ -63,3 +63,21 @@ tenant.number.not.blank=Tenant number cannot be blank tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator tenant.blocked=Sorry, your tenant is disabled. Please contact the administrator tenant.expired=Sorry, your tenant has expired. Please contact the administrator. +## wfc-modules-user +user.kyc.birthdate.not.blank=Date of birth cannot be blank +user.kyc.birthdate.not.valid=Date of birth format error +user.client.not.redirect.params=not wanfi redirect params +user.modify.user=Modify user information +user.modify.user.phone.exist=failed, phone number already existss +user.modify.user.email.exist=failed, email already exists +user.modify.user.phone.exist=Modify user ''{0}'' failed, phone number already exists +user.modify.user.email.exist=Modify user ''{0}'' failed, email already exists +user.modify.user.failed.contact.administrator=Modify personal information exception, please contact the administrator +user.modify.password.failed.error.old.password=Failed to modify password, old password error +user.modify.password.failed.new.password.same.old.password=The new password cannot be the same as the old password +user.modify.password.failed.contact.administrator=Modify password exception, please contact the administrator +user.avatar.file.format.error=Avatar fFile format is incorrect, please upload a ''{0}'' format file +user.file.service.error.contact.administrator=File service exception, please contact the administrator +user.avatar.upload.error.contact.administrator=Upload image exception, please contact the administrator +user.not.register=The current system has not enabled the registration function +user.name.or.password.error=Username or password error \ No newline at end of file diff --git a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties index 9a472ca..3cfff53 100644 --- a/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties +++ b/wfc-common/wfc-common-core/src/main/resources/i18n/messages_zh_CN.properties @@ -63,3 +63,19 @@ tenant.number.not.blank=租户编号不能为空 tenant.not.exists=对不起, 您的租户不存在,请联系管理员 tenant.blocked=对不起,您的租户已禁用,请联系管理员 tenant.expired=对不起,您的租户已过期,请联系管理员 +## wfc-modules-user +user.kyc.birthdate.not.blank=出生日期不能为空 +user.kyc.birthdate.not.valid=出生日期格式错误 +user.client.not.redirect.params=WANFi缺失重定向参数 +user.modify.user=修改用户信息 +user.modify.user.phone.exist=修改用户''{0}''失败,手机号已存在 +user.modify.user.email.exist=修改用户''{0}''失败,邮箱已存在 +user.modify.user.failed.contact.administrator=修改个人信息异常,请联系管理员 +user.modify.password.failed.error.old.password=修改密码失败,旧密码错误 +user.modify.password.failed.new.password.same.old.password=新密码不能与旧密码相同 +user.modify.password.failed.contact.administrator=修改密码异常,请联系管理员 +user.avatar.file.format.error=文件格式不正确,请上传''{0}''格式的文件 +user.file.service.error.contact.administrator=文件服务异常,请联系管理员 +user.avatar.upload.error.contact.administrator=上传图片异常,请联系管理员 +user.not.register=当前系统没有开启注册功能 +user.name.or.password.error=用户名或密码错误 diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/WfcUserApplication.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/WfcUserApplication.java index 969bbc6..f078457 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/WfcUserApplication.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/WfcUserApplication.java @@ -16,6 +16,6 @@ public class WfcUserApplication public static void main(String[] args) { SpringApplication.run(WfcUserApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 用户平台模块启动成功 ლ(´ڡ`ლ)゙ \n" ); + System.out.println("(♥◠‿◠)ノ゙ User module startup successfully ლ(´ڡ`ლ)゙ \n" ); } } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/ClientController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/ClientController.java index 741b6bf..055ac21 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/ClientController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/ClientController.java @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.core.utils.MessageUtils; import org.wfc.common.core.utils.StringUtils; import org.wfc.common.core.web.controller.BaseController; import org.wfc.common.core.web.domain.AjaxResult; @@ -41,7 +42,7 @@ public class ClientController extends BaseController { LoginUser loginUser = SecurityUtils.getLoginUser(); WANFiRedirectParams wanFiRedirectParams = loginUser.getWanFiRedirectParams(); if (wanFiRedirectParams == null) { - return error("not wanfi redirect params"); + return error(MessageUtils.message("user.client.not.redirect.params")); } String site = wanFiRedirectParams.getSite(); String clientMac = wanFiRedirectParams.getClientMac(); @@ -62,7 +63,7 @@ public class ClientController extends BaseController { LoginUser loginUser = SecurityUtils.getLoginUser(); WANFiRedirectParams wanFiRedirectParams = loginUser.getWanFiRedirectParams(); if (wanFiRedirectParams == null) { - return error("not wanfi redirect params"); + return error(MessageUtils.message("user.client.not.redirect.params")); } String site = wanFiRedirectParams.getSite(); String clientMac = wanFiRedirectParams.getClientMac(); diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UProfileController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UProfileController.java index 83b1ed2..4abf56c 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UProfileController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UProfileController.java @@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.wfc.common.core.domain.LoginUser; import org.wfc.common.core.domain.R; +import org.wfc.common.core.utils.MessageUtils; import org.wfc.common.core.utils.StringUtils; import org.wfc.common.core.utils.file.FileTypeUtils; import org.wfc.common.core.utils.file.MimeTypeUtils; @@ -76,11 +77,11 @@ public class UProfileController extends BaseController } if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) { - return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在"); + return error(MessageUtils.message("user.modify.user.phone.exist", loginUser.getUsername())); } if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) - { - return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在"); + { + return error(MessageUtils.message("user.modify.user.email.exist", loginUser.getUsername())); } if (userService.updateUserProfile(currentUser)) { @@ -88,7 +89,7 @@ public class UProfileController extends BaseController tokenService.setLoginUser(loginUser); return success(); } - return error("修改个人信息异常,请联系管理员"); + return error(MessageUtils.message("user.modify.user.failed.contact.administrator")); } /** @@ -103,11 +104,11 @@ public class UProfileController extends BaseController String password = user.getPassword(); if (!SecurityUtils.matchesPassword(oldPassword, password)) { - return error("修改密码失败,旧密码错误"); + return error(MessageUtils.message("user.modify.password.failed.error.old.password")); } if (SecurityUtils.matchesPassword(newPassword, password)) { - return error("新密码不能与旧密码相同"); + return error(MessageUtils.message("user.modify.password.failed.new.password.same.old.password")); } newPassword = SecurityUtils.encryptPassword(newPassword); if (userService.resetUserPwd(username, newPassword) > 0) @@ -120,7 +121,7 @@ public class UProfileController extends BaseController tokenService.setLoginUser(loginUser); return success(); } - return error("修改密码异常,请联系管理员"); + return error(MessageUtils.message("user.modify.password.failed.contact.administrator")); } /** @@ -136,12 +137,13 @@ public class UProfileController extends BaseController String extension = FileTypeUtils.getExtension(file); if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { - return error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式"); + return error(MessageUtils.message("user.avatar.file.format.error", + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION))); } R fileResult = remoteUFileService.upload(file); if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData())) { - return error("文件服务异常,请联系管理员"); + return error(MessageUtils.message("user.file.service.error.contact.administrator")); } String url = fileResult.getData().getUrl(); if (userService.updateUserAvatar(loginUser.getUsername(), url)) @@ -156,6 +158,6 @@ public class UProfileController extends BaseController return ajax; } } - return error("上传图片异常,请联系管理员"); + return error(MessageUtils.message("user.avatar.upload.error.contact.administrator")); } } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UUserController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UUserController.java index f79af2d..af0b3a0 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UUserController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UUserController.java @@ -160,7 +160,7 @@ public class UUserController extends BaseController UUser user = userService.selectUserByUserName(username); if (StringUtils.isNull(user)) { - return R.fail("用户名或密码错误"); + return R.fail("user.name.or.password.error"); } // 角色集合 Set roles = permissionService.getRolePermission(user); @@ -183,7 +183,7 @@ public class UUserController extends BaseController String username = uUser.getUserName(); if (!("true".equals(configService.selectConfigByKey("user.register")))) { - return R.fail("当前系统没有开启注册功能!"); + return R.fail("user.not.register"); } if (!userService.checkUserNameUnique(uUser)) { diff --git a/wfc-modules/wfc-user/src/main/resources/banner.txt b/wfc-modules/wfc-user/src/main/resources/banner.txt index cc13de2..f6d051f 100644 --- a/wfc-modules/wfc-user/src/main/resources/banner.txt +++ b/wfc-modules/wfc-user/src/main/resources/banner.txt @@ -1,3 +1,8 @@ Spring Boot Version: ${spring-boot.version} Spring Application Name: ${spring.application.name} - __ _ _ + + __ +__ __ / _| ___ _ _ ___ ___ _ __ +\ \ /\ / /| |_ / __| _____ | | | |/ __| / _ \| '__| + \ V V / | _|| (__ |_____|| |_| |\__ \| __/| | + \_/\_/ |_| \___| \__,_||___/ \___||_| \ No newline at end of file