From 7837eabd56fab7e2af9022890a090c5a8f34d0bf Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Thu, 23 Jan 2025 16:15:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/wfc/common/core/domain/R.java | 21 +++++++++++++------ .../wfc/user/controller/UUserController.java | 7 +++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/domain/R.java b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/domain/R.java index ce42573..caf112a 100644 --- a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/domain/R.java +++ b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/domain/R.java @@ -1,10 +1,12 @@ package org.wfc.common.core.domain; -import java.io.Serializable; +import cn.hutool.core.util.StrUtil; import org.wfc.common.core.constant.Constants; import org.wfc.common.core.utils.MessageUtils; import org.wfc.common.core.utils.StringUtils; +import java.io.Serializable; + /** * 响应信息主体 * @@ -38,7 +40,7 @@ public class R implements Serializable public static R ok(T data, String msg) { - return restResult(data, SUCCESS, msg); + return restResult(data, SUCCESS, i18n(msg)); } public static R fail() @@ -48,7 +50,7 @@ public class R implements Serializable public static R fail(String msg) { - return restResult(null, FAIL, msg); + return restResult(null, FAIL, i18n(msg)); } public static R fail(T data) @@ -58,12 +60,12 @@ public class R implements Serializable public static R fail(T data, String msg) { - return restResult(data, FAIL, msg); + return restResult(data, FAIL, i18n(msg)); } public static R fail(int code, String msg) { - return restResult(null, code, msg); + return restResult(null, code, i18n(msg)); } private static R restResult(T data, int code, String msg) @@ -71,7 +73,7 @@ public class R implements Serializable R apiResult = new R<>(); apiResult.setCode(code); apiResult.setData(data); - apiResult.setMsg(msg); + apiResult.setMsg(i18n(msg)); return apiResult; } @@ -123,4 +125,11 @@ public class R implements Serializable { return R.SUCCESS == ret.getCode(); } + + private static String i18n(String msg) { + if (StrUtil.isNotBlank(msg)) { + msg = MessageUtils.message(msg); + } + return msg; + } } 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 a283d82..2dfb17f 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 @@ -1,5 +1,6 @@ package org.wfc.user.controller; +import cn.hutool.core.util.StrUtil; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -22,8 +23,6 @@ import org.wfc.common.core.utils.poi.ExcelUtil; import org.wfc.common.core.web.controller.BaseController; import org.wfc.common.core.web.domain.AjaxResult; import org.wfc.common.core.web.page.TableDataInfo; -import org.wfc.common.log.annotation.Log; -import org.wfc.common.log.enums.BusinessType; import org.wfc.common.security.annotation.InnerAuth; import org.wfc.common.security.annotation.RequiresPermissions; import org.wfc.common.security.service.TokenService; @@ -190,9 +189,9 @@ public class UUserController extends BaseController return R.fail("user.register.save.error"); } - if (!userService.checkPhoneUnique(uUser)) + if (StrUtil.isNotBlank(uUser.getPhonenumber()) && !userService.checkPhoneUnique(uUser)) { - return R.fail("user.register.phone.save.error " + username); + return R.fail("user.register.phone.save.error"); } if (!userService.checkEmailUnique(uUser))