feat: common support i18n
This commit is contained in:
@@ -40,7 +40,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
public AjaxResult(int code, String msg)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(MSG_TAG, MessageUtils.message(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
public AjaxResult(int code, String msg, Object data)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(MSG_TAG, MessageUtils.message(msg));
|
||||
if (StringUtils.isNotNull(data))
|
||||
{
|
||||
super.put(DATA_TAG, data);
|
||||
@@ -88,7 +88,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult success(String msg)
|
||||
{
|
||||
return AjaxResult.success(msg, null);
|
||||
return AjaxResult.success(MessageUtils.message(msg), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult success(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||
return new AjaxResult(HttpStatus.SUCCESS, MessageUtils.message(msg), data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult warn(String msg)
|
||||
{
|
||||
return AjaxResult.warn(msg, null);
|
||||
return AjaxResult.warn(MessageUtils.message(msg), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult warn(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(HttpStatus.WARN, msg, data);
|
||||
return new AjaxResult(HttpStatus.WARN, MessageUtils.message(msg), data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult error(String msg)
|
||||
{
|
||||
return AjaxResult.error(msg, null);
|
||||
return AjaxResult.error(MessageUtils.message(msg), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult error(String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
||||
return new AjaxResult(HttpStatus.ERROR, MessageUtils.message(msg), data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg)
|
||||
{
|
||||
return new AjaxResult(code, msg, null);
|
||||
return new AjaxResult(code, MessageUtils.message(msg), null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,6 +83,13 @@ system.add.dict.failed.dict.exist=Add dictionary ''{0}'' failed, dictionary type
|
||||
system.modify.dict.failed.dict.exist=Modify dictionary ''{0}'' failed, dictionary type already exists
|
||||
system.add.menu.failed.menu.exist=Add menu ''{0}'' failed, menu name already exists
|
||||
system.add.menu.failed.menu.url=Add menu ''{0}'' failed, address must start with http(s)://
|
||||
system.menu.name.not.blank=Menu name cannot be blank
|
||||
system.menu.name.length.valid=Menu name length cannot exceed 50 characters
|
||||
system.menu.order.not.blank=Display order cannot be blank
|
||||
system.menu.url.length.valid=Menu address cannot exceed 200 characters
|
||||
system.menu.component.length.valid=Component path cannot exceed 255 characters
|
||||
system.menu.type.not.blank=Menu type cannot be blank
|
||||
system.menu.permission.length.valid=Permission string cannot exceed 100 characters
|
||||
system.modify.menu.failed.menu.exist=Modify menu ''{0}'' failed, menu name already exists
|
||||
system.modify.menu.failed.menu.url=Modify menu ''{0}'' failed, address must start with http(s)://
|
||||
system.modify.menu.failed.menu.parent=Modify menu ''{0}'' failed, superior menu cannot be selected by itself
|
||||
@@ -157,6 +164,14 @@ auth.password.retry.limit.exceed=Password input error {0} times
|
||||
## wfc-common
|
||||
common.operate.success=Operation successful
|
||||
common.operate.failed=Operation failed
|
||||
common.no.internal.access.permission=No internal access permission, not allowed to access
|
||||
common.no.user.info=No user information set, not allowed to access
|
||||
common.no.token=No token
|
||||
common.invalid.token=Invalid token
|
||||
common.no.permission=No permission, please contact the administrator to add permissions
|
||||
common.request.path.variable.not.blank=Request path variable''{0}'' cannot be blank
|
||||
common.request.parameter.type.not.match=Request parameter''{0}'' requires type: ''{1}'', but the input value is: ''{2}''
|
||||
common.demo.mode=Demo mode, no operation is allowed
|
||||
|
||||
## system portal menu
|
||||
menu.system.management=System Management
|
||||
|
||||
@@ -83,6 +83,13 @@ system.add.dict.failed.dict.exist=Add dictionary ''{0}'' failed, dictionary type
|
||||
system.modify.dict.failed.dict.exist=Modify dictionary ''{0}'' failed, dictionary type already exists
|
||||
system.add.menu.failed.menu.exist=Add menu ''{0}'' failed, menu name already exists
|
||||
system.add.menu.failed.menu.url=Add menu ''{0}'' failed, address must start with http(s)://
|
||||
system.menu.name.not.blank=Menu name cannot be blank
|
||||
system.menu.name.length.valid=Menu name length cannot exceed 50 characters
|
||||
system.menu.order.not.blank=Display order cannot be blank
|
||||
system.menu.url.length.valid=Menu address cannot exceed 200 characters
|
||||
system.menu.component.length.valid=Component path cannot exceed 255 characters
|
||||
system.menu.type.not.blank=Menu type cannot be blank
|
||||
system.menu.permission.length.valid=Permission string cannot exceed 100 characters
|
||||
system.modify.menu.failed.menu.exist=Modify menu ''{0}'' failed, menu name already exists
|
||||
system.modify.menu.failed.menu.url=Modify menu ''{0}'' failed, address must start with http(s)://
|
||||
system.modify.menu.failed.menu.parent=Modify menu ''{0}'' failed, superior menu cannot be selected by itself
|
||||
@@ -157,6 +164,14 @@ auth.password.retry.limit.exceed=Password input error {0} times
|
||||
## wfc-common
|
||||
common.operate.success=Operation successful
|
||||
common.operate.failed=Operation failed
|
||||
common.no.internal.access.permission=No internal access permission, not allowed to access
|
||||
common.no.user.info=No user information set, not allowed to access
|
||||
common.no.token=No token
|
||||
common.invalid.token=Invalid token
|
||||
common.no.permission=No permission, please contact the administrator to add permissions
|
||||
common.request.path.variable.not.blank=Request path variable''{0}'' cannot be blank
|
||||
common.request.parameter.type.not.match=Request parameter''{0}'' requires type: ''{1}'', but the input value is: ''{2}''
|
||||
common.demo.mode=Demo mode, no operation is allowed
|
||||
|
||||
## system portal menu
|
||||
menu.system.management=System Management
|
||||
|
||||
@@ -83,6 +83,13 @@ system.add.dict.failed.dict.exist=新增字典''{0}''失败,字典类型已存
|
||||
system.modify.dict.failed.dict.exist=修改字典''{0}''失败,字典类型已存在
|
||||
system.add.menu.failed.menu.exist=新增菜单''{0}''失败,菜单名称已存在
|
||||
system.add.menu.failed.menu.url=新增菜单''{0}''失败,地址必须以http(s)://开头
|
||||
system.menu.name.not.blank=菜单名称不能为空
|
||||
system.menu.name.length.valid=菜单名称长度不能超过50个字符
|
||||
system.menu.order.not.blank=显示顺序不能为空
|
||||
system.menu.url.length.valid=路由地址不能超过200个字符
|
||||
system.menu.component.length.valid=组件路径不能超过255个字符
|
||||
system.menu.type.not.blank=菜单类型不能为空
|
||||
system.menu.permission.length.valid=权限标识长度不能超过100个字符
|
||||
system.modify.menu.failed.menu.exist=修改菜单''{0}''失败,菜单名称已存在
|
||||
system.modify.menu.failed.menu.url=修改菜单''{0}''失败,地址必须以http(s)://开头
|
||||
system.modify.menu.failed.menu.parent=修改菜单''{0}''失败,上级菜单不能选择自己
|
||||
@@ -159,6 +166,14 @@ auth.password.retry.limit.exceed=密码输入错误{0}次
|
||||
## wfc-common
|
||||
common.operate.success=操作成功
|
||||
common.operate.failed=操作失败
|
||||
common.no.internal.access.permission=没有内部访问权限,不允许访问
|
||||
common.no.user.info=没有设置用户信息,不允许访问
|
||||
common.no.token=未提供token
|
||||
common.invalid.token=无效的token
|
||||
common.no.permission=没有访问权限,请联系管理员授权
|
||||
common.request.path.variable.not.blank=请求路径中缺少必需的路径变量''{0}''
|
||||
common.request.parameter.type.not.match=请求参数类型不匹配,参数''{0}''要求类型为:''{1}'',但输入值为:''{2}''
|
||||
common.demo.mode=演示模式,不允许操作
|
||||
|
||||
## system portal menu
|
||||
menu.system.management=系统管理
|
||||
|
||||
@@ -27,7 +27,7 @@ public class InnerAuthAspect implements Ordered
|
||||
// 内部请求验证
|
||||
if (!StringUtils.equals(SecurityConstants.INNER, source))
|
||||
{
|
||||
throw new InnerAuthException("没有内部访问权限,不允许访问");
|
||||
throw new InnerAuthException("common.no.internal.access.permission");
|
||||
}
|
||||
|
||||
String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID);
|
||||
@@ -35,7 +35,7 @@ public class InnerAuthAspect implements Ordered
|
||||
// 用户信息验证
|
||||
if (innerAuth.isUser() && (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)))
|
||||
{
|
||||
throw new InnerAuthException("没有设置用户信息,不允许访问 ");
|
||||
throw new InnerAuthException("common.no.user.info");
|
||||
}
|
||||
return point.proceed();
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ public class AuthLogic
|
||||
String token = SecurityUtils.getToken();
|
||||
if (token == null)
|
||||
{
|
||||
throw new NotLoginException("未提供token");
|
||||
throw new NotLoginException("common.no.token");
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null)
|
||||
{
|
||||
throw new NotLoginException("无效的token");
|
||||
throw new NotLoginException("common.invalid.token");
|
||||
}
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.wfc.common.core.exception.ServiceException;
|
||||
import org.wfc.common.core.exception.auth.NotPermissionException;
|
||||
import org.wfc.common.core.exception.auth.NotRoleException;
|
||||
import org.wfc.common.core.text.Convert;
|
||||
import org.wfc.common.core.utils.MessageUtils;
|
||||
import org.wfc.common.core.utils.StringUtils;
|
||||
import org.wfc.common.core.utils.html.EscapeUtil;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
@@ -38,8 +39,8 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleNotPermissionException(NotPermissionException e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
log.error("Request address'{}',Permission code verification failed'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "common.no.permission");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,8 +50,8 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleNotRoleException(NotRoleException e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
log.error("Request address'{}',Role permission verification failed'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "common.no.permission");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
log.error("Request address'{}','{}' request not supported", requestURI, e.getMethod());
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -82,8 +83,8 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
|
||||
log.error("The required path variable '{}' is missing from the request path, and a system exception occurred.", requestURI, e);
|
||||
return AjaxResult.error(MessageUtils.message("common.request.path.variable.not.blank", e.getVariableName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,8 +99,8 @@ public class GlobalExceptionHandler
|
||||
{
|
||||
value = EscapeUtil.clean(value);
|
||||
}
|
||||
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), value));
|
||||
log.error("The request parameter type does not match '{}', and a system exception occurred.", requestURI, e);
|
||||
return AjaxResult.error(MessageUtils.message("common.request.parameter.type.not.match", e.getName(), e.getRequiredType().getName(), value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +110,7 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
log.error("Requesting address '{}', an unknown exception occurred.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ public class GlobalExceptionHandler
|
||||
public AjaxResult handleException(Exception e, HttpServletRequest request)
|
||||
{
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
log.error("Requesting address '{}', an unknown exception occurred.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -161,6 +162,6 @@ public class GlobalExceptionHandler
|
||||
@ExceptionHandler(DemoModeException.class)
|
||||
public AjaxResult handleDemoModeException(DemoModeException e)
|
||||
{
|
||||
return AjaxResult.error("演示模式,不允许操作");
|
||||
return AjaxResult.error("common.demo.mode");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TokenService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("获取用户信息异常'{}'", e.getMessage());
|
||||
log.error("Exception in obtaining user information'{}'", e.getMessage());
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ public class SysMenu extends BaseEntity
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
@NotBlank(message = "{system.menu.name.not.blank}")
|
||||
@Size(min = 0, max = 50, message = "{system.menu.name.length.valid}")
|
||||
public String getMenuName()
|
||||
{
|
||||
if (menuName == null || menuName.isEmpty()) {
|
||||
@@ -101,6 +101,8 @@ public class SysMenu extends BaseEntity
|
||||
return MessageUtils.message(menuName);
|
||||
}
|
||||
|
||||
// @NotBlank(message = "{system.menu.name.not.blank}")
|
||||
// @Size(min = 0, max = 50, message = "{system.menu.name.length.valid}")
|
||||
// public String getMenuName() {
|
||||
// return menuName;
|
||||
// }
|
||||
@@ -130,7 +132,7 @@ public class SysMenu extends BaseEntity
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
@NotNull(message = "{system.menu.order.not.blank}")
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
@@ -141,7 +143,7 @@ public class SysMenu extends BaseEntity
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||
@Size(min = 0, max = 200, message = "{system.menu.url.length.valid}")
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
@@ -152,7 +154,7 @@ public class SysMenu extends BaseEntity
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||
@Size(min = 0, max = 200, message = "{system.menu.component.length.valid}")
|
||||
public String getComponent()
|
||||
{
|
||||
return component;
|
||||
@@ -203,7 +205,7 @@ public class SysMenu extends BaseEntity
|
||||
this.isCache = isCache;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
@NotBlank(message = "{system.menu.type.not.blank}")
|
||||
public String getMenuType()
|
||||
{
|
||||
return menuType;
|
||||
@@ -234,7 +236,7 @@ public class SysMenu extends BaseEntity
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||
@Size(min = 0, max = 100, message = "{system.menu.permission.length.valid}")
|
||||
public String getPerms()
|
||||
{
|
||||
return perms;
|
||||
|
||||
Reference in New Issue
Block a user