fix: 国际化
This commit is contained in:
@@ -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<T> implements Serializable
|
||||
|
||||
public static <T> R<T> ok(T data, String msg)
|
||||
{
|
||||
return restResult(data, SUCCESS, msg);
|
||||
return restResult(data, SUCCESS, i18n(msg));
|
||||
}
|
||||
|
||||
public static <T> R<T> fail()
|
||||
@@ -48,7 +50,7 @@ public class R<T> implements Serializable
|
||||
|
||||
public static <T> R<T> fail(String msg)
|
||||
{
|
||||
return restResult(null, FAIL, msg);
|
||||
return restResult(null, FAIL, i18n(msg));
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data)
|
||||
@@ -58,12 +60,12 @@ public class R<T> implements Serializable
|
||||
|
||||
public static <T> R<T> fail(T data, String msg)
|
||||
{
|
||||
return restResult(data, FAIL, msg);
|
||||
return restResult(data, FAIL, i18n(msg));
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg)
|
||||
{
|
||||
return restResult(null, code, msg);
|
||||
return restResult(null, code, i18n(msg));
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg)
|
||||
@@ -71,7 +73,7 @@ public class R<T> implements Serializable
|
||||
R<T> 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<T> implements Serializable
|
||||
{
|
||||
return R.SUCCESS == ret.getCode();
|
||||
}
|
||||
|
||||
private static String i18n(String msg) {
|
||||
if (StrUtil.isNotBlank(msg)) {
|
||||
msg = MessageUtils.message(msg);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user