2
0

feat: user portal support i18n

This commit is contained in:
zhangsz
2025-01-21 14:45:18 +08:00
parent 0016179356
commit c04fabedd3
7 changed files with 58 additions and 16 deletions

View File

@@ -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" );
}
}

View File

@@ -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<UUser> 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<UUser> 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();

View File

@@ -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<UFile> 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"));
}
}

View File

@@ -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<String> 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))
{

View File

@@ -1,3 +1,8 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
__ _ _
__
__ __ / _| ___ _ _ ___ ___ _ __
\ \ /\ / /| |_ / __| _____ | | | |/ __| / _ \| '__|
\ V V / | _|| (__ |_____|| |_| |\__ \| __/| |
\_/\_/ |_| \___| \__,_||___/ \___||_|