diff --git a/@rbv b/@rbv index 47b6d0b22..825fdd4e0 160000 --- a/@rbv +++ b/@rbv @@ -1 +1 @@ -Subproject commit 47b6d0b22f0f6e1bdd3cd0439deba63a69f5a7c4 +Subproject commit 825fdd4e0db7ebbf7f89276d3ba97ea615742d1b diff --git a/src/main/java/com/rebuild/api/RespBody.java b/src/main/java/com/rebuild/api/RespBody.java index 198d850fc..827f48c17 100644 --- a/src/main/java/com/rebuild/api/RespBody.java +++ b/src/main/java/com/rebuild/api/RespBody.java @@ -14,8 +14,6 @@ import com.rebuild.utils.JSONUtils; import com.rebuild.utils.JSONable; import lombok.Data; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 统一请求返回消息体 * @@ -86,13 +84,13 @@ public class RespBody implements JSONable { public static RespBody error(String errorMsg, int errorCode) { if (errorMsg == null) { if (errorCode == 401) { - errorMsg = $L("未授权访问"); + errorMsg = Language.L("未授权访问"); } else if (errorCode == 403) { - errorMsg = $L("权限不足,访问被阻止"); + errorMsg = Language.L("权限不足,访问被阻止"); } else if (errorCode == 404) { - errorMsg = $L("访问的页面/资源不存在"); + errorMsg = Language.L("访问的页面/资源不存在"); } else { - errorMsg = $L("系统繁忙,请稍后重试"); + errorMsg = Language.L("系统繁忙,请稍后重试"); } } return new RespBody(errorCode, errorMsg, null); @@ -102,10 +100,10 @@ public class RespBody implements JSONable { * @param errorMsg * @param placeholders * @return - * @see Language#$L(String, Object...) + * @see Language#L(String, Object...) */ public static RespBody errorl(String errorMsg, Object... placeholders) { - return error($L(errorMsg, placeholders), Controller.CODE_ERROR); + return error(Language.L(errorMsg, placeholders), Controller.CODE_ERROR); } /** @@ -120,6 +118,6 @@ public class RespBody implements JSONable { * @return */ public static RespBody ok(Object data) { - return new RespBody(Controller.CODE_OK, $L("调用成功"), data); + return new RespBody(Controller.CODE_OK, Language.L("调用成功"), data); } } diff --git a/src/main/java/com/rebuild/api/user/LoginToken.java b/src/main/java/com/rebuild/api/user/LoginToken.java index 7f6edcda4..00d96cbcf 100644 --- a/src/main/java/com/rebuild/api/user/LoginToken.java +++ b/src/main/java/com/rebuild/api/user/LoginToken.java @@ -16,11 +16,10 @@ import com.rebuild.core.Application; import com.rebuild.core.privileges.bizz.User; import com.rebuild.core.privileges.bizz.ZeroEntry; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.RateLimiters; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 获取登录 Token 可用于单点登录 * @@ -35,7 +34,7 @@ public class LoginToken extends BaseApi { String password = context.getParameterNotBlank("password"); if (RateLimiters.RRL_LOGIN.overLimitWhenIncremented("user:" + user)) { - return formatFailure($L("请求过于频繁,请稍后重试"), ApiInvokeException.ERR_FREQUENCY); + return formatFailure(Language.L("请求过于频繁,请稍后重试"), ApiInvokeException.ERR_FREQUENCY); } String hasError = checkUser(user, password); @@ -63,13 +62,13 @@ public class LoginToken extends BaseApi { */ public static String checkUser(String user, String password) { if (!Application.getUserStore().existsUser(user)) { - return $L("用户名或密码错误"); + return Language.L("用户名或密码错误"); } User loginUser = Application.getUserStore().getUser(user); if (!loginUser.isActive() || !Application.getPrivilegesManager().allow(loginUser.getId(), ZeroEntry.AllowLogin)) { - return $L("用户未激活或不允许登录"); + return Language.L("用户未激活或不允许登录"); } Object[] foundUser = Application.createQueryNoFilter( @@ -81,7 +80,7 @@ public class LoginToken extends BaseApi { // Okay return null; } else { - return $L("用户名或密码错误"); + return Language.L("用户名或密码错误"); } } } diff --git a/src/main/java/com/rebuild/core/configuration/BaseConfigurationService.java b/src/main/java/com/rebuild/core/configuration/BaseConfigurationService.java index ad065131b..4cc44a146 100644 --- a/src/main/java/com/rebuild/core/configuration/BaseConfigurationService.java +++ b/src/main/java/com/rebuild/core/configuration/BaseConfigurationService.java @@ -14,8 +14,7 @@ import com.rebuild.core.UserContextHolder; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.service.BaseService; import com.rebuild.core.service.DataSpecificationException; - -import static com.rebuild.core.support.i18n.Language.$L; +import com.rebuild.core.support.i18n.Language; /** * 配置类的 Service。在增/删/改时调用清理缓存方法 @@ -59,7 +58,7 @@ public abstract class BaseConfigurationService extends BaseService { if (UserHelper.isAdmin(user)) return; if (!UserHelper.isSelf(user, cfgid)) { - throw new DataSpecificationException($L("无权操作他人配置")); + throw new DataSpecificationException(Language.L("无权操作他人配置")); } } diff --git a/src/main/java/com/rebuild/core/configuration/NavBuilder.java b/src/main/java/com/rebuild/core/configuration/NavBuilder.java index 32baaa358..05ec48f73 100644 --- a/src/main/java/com/rebuild/core/configuration/NavBuilder.java +++ b/src/main/java/com/rebuild/core/configuration/NavBuilder.java @@ -22,6 +22,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.privileges.UserService; import com.rebuild.core.service.project.ProjectManager; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.AppUtils; import com.rebuild.utils.JSONUtils; import lombok.extern.slf4j.Slf4j; @@ -33,8 +34,6 @@ import org.jsoup.nodes.Element; import javax.servlet.http.HttpServletRequest; import java.util.Iterator; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 导航渲染 * @@ -56,15 +55,15 @@ public class NavBuilder extends NavManager { private static final JSONArray NAVS_DEFAULT = JSONUtils.toJSONObjectArray( NAV_ITEM_PROPS, new Object[][] { - new Object[] { "chart-donut", $L("动态"), "BUILTIN", NAV_FEEDS }, - new Object[] { "shape", $L("项目"), "BUILTIN", NAV_PROJECT }, - new Object[] { "folder", $L("文件"), "BUILTIN", NAV_FILEMRG } + new Object[] { "chart-donut", Language.L("动态"), "BUILTIN", NAV_FEEDS }, + new Object[] { "shape", Language.L("项目"), "BUILTIN", NAV_PROJECT }, + new Object[] { "folder", Language.L("文件"), "BUILTIN", NAV_FILEMRG } }); // 新建项目 private static final JSONObject NAV_PROJECT__ADD = JSONUtils.toJSONObject( NAV_ITEM_PROPS, - new String[] { "plus", $L("添加项目"), "BUILTIN", NAV_PROJECT + "--add" } + new String[] { "plus", Language.L("添加项目"), "BUILTIN", NAV_PROJECT + "--add" } ); // URL 绑定实体权限 diff --git a/src/main/java/com/rebuild/core/configuration/general/ClassificationService.java b/src/main/java/com/rebuild/core/configuration/general/ClassificationService.java index bffda9836..0b7bef0a1 100644 --- a/src/main/java/com/rebuild/core/configuration/general/ClassificationService.java +++ b/src/main/java/com/rebuild/core/configuration/general/ClassificationService.java @@ -19,11 +19,10 @@ import com.rebuild.core.privileges.AdminGuard; import com.rebuild.core.privileges.UserService; import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.service.general.QuickCodeReindexTask; +import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 分类数据 * @@ -51,7 +50,7 @@ public class ClassificationService extends BaseConfigurationService implements A for (Object[] o : used) { if (StringUtils.contains((String) o[0], recordId.toLiteral())) { String usedEntity = EasyMetaFactory.getLabel((String) o[1]); - throw new DataSpecificationException($L("此分类数据正在被 **%s** 使用,不能删除", usedEntity)); + throw new DataSpecificationException(Language.L("此分类数据正在被 **%s** 使用,不能删除", usedEntity)); } } diff --git a/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java b/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java index 9c80baa0c..988c6afff 100644 --- a/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java +++ b/src/main/java/com/rebuild/core/configuration/general/FormsBuilder.java @@ -29,6 +29,7 @@ import com.rebuild.core.service.NoRecordFoundException; import com.rebuild.core.service.approval.ApprovalState; import com.rebuild.core.service.approval.RobotApprovalManager; import com.rebuild.core.support.general.FieldValueHelper; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.state.StateManager; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -36,8 +37,6 @@ import org.springframework.util.Assert; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 表单构造 * @@ -117,17 +116,17 @@ public class FormsBuilder extends FormsManager { if ((approvalState == ApprovalState.PROCESSING || approvalState == ApprovalState.APPROVED)) { return formatModelError(approvalState == ApprovalState.APPROVED - ? $L("主记录已完成审批,不能添加明细") : $L("主记录正在审批中,不能添加明细")); + ? Language.L("主记录已完成审批,不能添加明细") : Language.L("主记录正在审批中,不能添加明细")); } // 明细无需审批 approvalState = null; if (!Application.getPrivilegesManager().allowUpdate(user, mainId)) { - return formatModelError($L("你没有添加明细权限")); + return formatModelError(Language.L("你没有添加明细权限")); } } else if (!Application.getPrivilegesManager().allowCreate(user, entityMeta.getEntityCode())) { - return formatModelError($L("你没有新建权限" )); + return formatModelError(Language.L("你没有新建权限" )); } else { approvalState = getHadApproval(entityMeta, null); } @@ -135,7 +134,7 @@ public class FormsBuilder extends FormsManager { // 查看(视图) else if (viewMode) { if (!Application.getPrivilegesManager().allowRead(user, record)) { - return formatModelError($L("无权读取此记录或记录已被删除")); + return formatModelError(Language.L("无权读取此记录或记录已被删除")); } approvalState = getHadApproval(entityMeta, record); @@ -144,16 +143,16 @@ public class FormsBuilder extends FormsManager { // 编辑 else { if (!Application.getPrivilegesManager().allowUpdate(user, record)) { - return formatModelError($L("你没有修改此记录的权限")); + return formatModelError(Language.L("你没有修改此记录的权限")); } approvalState = getHadApproval(entityMeta, record); if (approvalState != null) { - String recordType = mainEntity == null ? $L("记录") : $L("主记录"); + String recordType = mainEntity == null ? Language.L("记录") : Language.L("主记录"); if (approvalState == ApprovalState.APPROVED) { - return formatModelError($L("%s已完成审批,禁止操作", recordType)); + return formatModelError(Language.L("%s已完成审批,禁止操作", recordType)); } else if (approvalState == ApprovalState.PROCESSING) { - return formatModelError($L("%s正在审批中,禁止操作", recordType)); + return formatModelError(Language.L("%s正在审批中,禁止操作", recordType)); } } } @@ -161,14 +160,14 @@ public class FormsBuilder extends FormsManager { ConfigBean model = getFormLayout(entity, user); JSONArray elements = (JSONArray) model.getJSON("elements"); if (elements == null || elements.isEmpty()) { - return formatModelError($L("此表单布局尚未配置,请配置后使用")); + return formatModelError(Language.L("此表单布局尚未配置,请配置后使用")); } Record data = null; if (record != null) { data = findRecord(record, user, elements); if (data == null) { - return formatModelError($L("无权读取此记录或记录已被删除")); + return formatModelError(Language.L("无权读取此记录或记录已被删除")); } } @@ -184,7 +183,7 @@ public class FormsBuilder extends FormsManager { buildModelElements(elements, entityMeta, data, user, !viewMode); if (elements.isEmpty()) { - return formatModelError($L("此表单布局尚未配置,请配置后使用")); + return formatModelError(Language.L("此表单布局尚未配置,请配置后使用")); } // 主/明细实体处理 @@ -373,7 +372,7 @@ public class FormsBuilder extends FormsManager { el.put("value", FieldValueHelper.wrapMixValue((ID) dept.getIdentity(), dept.getName())); break; case EntityHelper.ApprovalId: - el.put("value", FieldValueHelper.wrapMixValue(null, $L("未提交"))); + el.put("value", FieldValueHelper.wrapMixValue(null, Language.L("未提交"))); break; case EntityHelper.ApprovalState: el.put("value", ApprovalState.DRAFT.getState()); @@ -386,7 +385,7 @@ public class FormsBuilder extends FormsManager { // 默认值 if (el.get("value") == null) { if (dt == DisplayType.SERIES) { - el.put("value", $L("自动值")); + el.put("value", Language.L("自动值")); } else { Object defaultValue = easyField.exprDefaultValue(); if (defaultValue != null) { @@ -407,7 +406,7 @@ public class FormsBuilder extends FormsManager { || dt == DisplayType.SERIES || dt == DisplayType.TEXT || dt == DisplayType.NTEXT) { - el.put("value", $L("自动值")); + el.put("value", Language.L("自动值")); } } diff --git a/src/main/java/com/rebuild/core/configuration/general/ViewAddonsManager.java b/src/main/java/com/rebuild/core/configuration/general/ViewAddonsManager.java index 1018b9385..4dcce6602 100644 --- a/src/main/java/com/rebuild/core/configuration/general/ViewAddonsManager.java +++ b/src/main/java/com/rebuild/core/configuration/general/ViewAddonsManager.java @@ -20,6 +20,7 @@ import com.rebuild.core.configuration.ConfigBean; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import java.util.HashMap; @@ -27,8 +28,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 视图-相关项/新建相关 * @@ -192,7 +191,7 @@ public class ViewAddonsManager extends BaseLayoutManager { : String.format("%s (%s)", show.getString("entityLabel"), EasyMetaFactory.getLabel(field)); show.put("entityLabel", entityLabel); } else if (fieldEntity.getEntityCode() == EntityHelper.Feeds) { - show.put("entityLabel", $L("动态")); + show.put("entityLabel", Language.L("动态")); } return show; } diff --git a/src/main/java/com/rebuild/core/metadata/EntityHelper.java b/src/main/java/com/rebuild/core/metadata/EntityHelper.java index bb0f027cb..21fbf3512 100644 --- a/src/main/java/com/rebuild/core/metadata/EntityHelper.java +++ b/src/main/java/com/rebuild/core/metadata/EntityHelper.java @@ -20,8 +20,6 @@ import org.springframework.util.Assert; import java.util.Date; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author Zhao Fangfang * @see MetadataHelper @@ -37,14 +35,16 @@ public class EntityHelper { public static Record parse(JSONObject data, ID user) { JSONObject metadata = data.getJSONObject(EntityRecordCreator.META_FIELD); if (metadata == null) { - throw new FieldValueException($L("无效实体数据格式 : %s", data.toJSONString())); + throw new FieldValueException( + com.rebuild.core.support.i18n.Language.L("无效实体数据格式 : %s", data.toJSONString())); } String entityName = metadata.getString("entity"); if (StringUtils.isBlank(entityName)) { String id = metadata.getString("id"); if (!ID.isId(id)) { - throw new FieldValueException($L("无效实体数据格式 : %s", data.toJSONString())); + throw new FieldValueException( + com.rebuild.core.support.i18n.Language.L("无效实体数据格式 : %s", data.toJSONString())); } entityName = MetadataHelper.getEntityName(ID.valueOf(id)); } diff --git a/src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java b/src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java index d29feb23c..21f289f02 100644 --- a/src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java +++ b/src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java @@ -19,6 +19,7 @@ import com.rebuild.core.metadata.easymeta.DisplayType; import com.rebuild.core.metadata.easymeta.EasyField; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.service.DataSpecificationException; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -26,8 +27,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 标准 Record 解析 * @@ -109,7 +108,7 @@ public class EntityRecordCreator extends JsonRecordCreator { if (!notAllowed.isEmpty()) { throw new DataSpecificationException( - $L("%s 不允许为空", StringUtils.join(notAllowed, " / "))); + Language.L("%s 不允许为空", StringUtils.join(notAllowed, " / "))); } } // 更新 @@ -135,7 +134,7 @@ public class EntityRecordCreator extends JsonRecordCreator { if (!notAllowed.isEmpty()) { throw new DataSpecificationException( - $L("%s 不允许修改", StringUtils.join(notAllowed, " / "))); + Language.L("%s 不允许修改", StringUtils.join(notAllowed, " / "))); } } } diff --git a/src/main/java/com/rebuild/core/metadata/MetadataHelper.java b/src/main/java/com/rebuild/core/metadata/MetadataHelper.java index ff98a515d..aa66c4b38 100644 --- a/src/main/java/com/rebuild/core/metadata/MetadataHelper.java +++ b/src/main/java/com/rebuild/core/metadata/MetadataHelper.java @@ -18,6 +18,7 @@ import com.rebuild.core.Application; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.metadata.impl.DynamicMetadataFactory; import com.rebuild.core.metadata.impl.GhostEntity; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.util.Assert; @@ -25,8 +26,6 @@ import org.springframework.util.Assert; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 实体元数据 * @@ -102,7 +101,7 @@ public class MetadataHelper { try { return getMetadataFactory().getEntity(entityName); } catch (MissingMetaExcetion ex) { - throw new MissingMetaExcetion($L("实体 [%s] 已经不存在,请检查配置", entityName.toUpperCase())); + throw new MissingMetaExcetion(Language.L("实体 [%s] 已经不存在,请检查配置", entityName.toUpperCase())); } } @@ -115,7 +114,7 @@ public class MetadataHelper { try { return getMetadataFactory().getEntity(entityCode); } catch (MissingMetaExcetion ex) { - throw new MissingMetaExcetion($L("实体 [%s] 已经不存在,请检查配置", entityCode)); + throw new MissingMetaExcetion(Language.L("实体 [%s] 已经不存在,请检查配置", entityCode)); } } @@ -138,7 +137,7 @@ public class MetadataHelper { return getEntity(entityName).getField(fieldName); } catch (MissingMetaExcetion ex) { throw new MissingMetaExcetion( - $L("字段 [%s] 已经不存在,请检查配置", (entityName + "#" + fieldName).toUpperCase())); + Language.L("字段 [%s] 已经不存在,请检查配置", (entityName + "#" + fieldName).toUpperCase())); } } diff --git a/src/main/java/com/rebuild/core/metadata/easymeta/BaseEasyMeta.java b/src/main/java/com/rebuild/core/metadata/easymeta/BaseEasyMeta.java index cb0df47a0..000be9c0f 100644 --- a/src/main/java/com/rebuild/core/metadata/easymeta/BaseEasyMeta.java +++ b/src/main/java/com/rebuild/core/metadata/easymeta/BaseEasyMeta.java @@ -11,12 +11,11 @@ import cn.devezhao.persist4j.engine.ID; import cn.devezhao.persist4j.metadata.BaseMeta; import com.alibaba.fastjson.JSONObject; import com.rebuild.core.metadata.impl.EasyFieldConfigProps; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.JSONable; import org.apache.commons.lang.StringUtils; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 元数据封装 * @@ -122,10 +121,10 @@ public abstract class BaseEasyMeta implements BaseMeta, JSON /** * @return - * @see com.rebuild.core.support.i18n.Language#$L(BaseMeta) + * @see com.rebuild.core.support.i18n.Language#L(BaseMeta) */ public String getLabel() { - return $L(getRawMeta()); + return Language.L(getRawMeta()); } /** @@ -138,7 +137,7 @@ public abstract class BaseEasyMeta implements BaseMeta, JSON if (getMetaId() != null) { return comments; } - return StringUtils.defaultIfBlank(comments, $L("系统内置")); + return StringUtils.defaultIfBlank(comments, Language.L("系统内置")); } /** diff --git a/src/main/java/com/rebuild/core/metadata/easymeta/EasyBool.java b/src/main/java/com/rebuild/core/metadata/easymeta/EasyBool.java index 738f1ce2a..3941acf9d 100644 --- a/src/main/java/com/rebuild/core/metadata/easymeta/EasyBool.java +++ b/src/main/java/com/rebuild/core/metadata/easymeta/EasyBool.java @@ -9,11 +9,10 @@ package com.rebuild.core.metadata.easymeta; import cn.devezhao.persist4j.Field; import cn.devezhao.persist4j.dialect.editor.BoolEditor; +import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2020/11/17 @@ -51,10 +50,10 @@ public class EasyBool extends EasyField implements MixValue { @Override public Object unpackWrapValue(Object wrappedValue) { if (wrappedValue instanceof Boolean) { - return (Boolean) wrappedValue ? $L("是") : $L("否"); + return (Boolean) wrappedValue ? Language.L("是") : Language.L("否"); } return StringUtils.equals(BoolEditor.TRUE + "", wrappedValue.toString()) - ? $L("是") : $L("否"); + ? Language.L("是") : Language.L("否"); } } diff --git a/src/main/java/com/rebuild/core/metadata/impl/EasyMeta.java b/src/main/java/com/rebuild/core/metadata/impl/EasyMeta.java index ea91a7ebb..485183b18 100644 --- a/src/main/java/com/rebuild/core/metadata/impl/EasyMeta.java +++ b/src/main/java/com/rebuild/core/metadata/impl/EasyMeta.java @@ -19,14 +19,13 @@ import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.metadata.easymeta.DisplayType; import com.rebuild.core.service.trigger.RobotTriggerManager; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import org.apache.commons.lang.StringUtils; import org.springframework.util.Assert; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 元数据(Entity/Field)封装 * @@ -161,7 +160,7 @@ public class EasyMeta implements BaseMeta { if (isField() && ((Field) baseMeta).getType() == FieldType.PRIMARY) { return "ID"; } - return $L(this.baseMeta); + return Language.L(this.baseMeta); } /** @@ -184,7 +183,7 @@ public class EasyMeta implements BaseMeta { if (getMetaId() != null) { return comments; } - return StringUtils.defaultIfBlank(comments, $L("系统内置")); + return StringUtils.defaultIfBlank(comments, Language.L("系统内置")); } @Override diff --git a/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java b/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java index da91cefdc..45924b86d 100644 --- a/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java +++ b/src/main/java/com/rebuild/core/metadata/impl/Entity2Schema.java @@ -25,12 +25,11 @@ import com.rebuild.core.metadata.easymeta.EasyEntity; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.UserService; import com.rebuild.core.support.License; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.RandomUtils; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 创建实体 * @@ -69,7 +68,7 @@ public class Entity2Schema extends Field2Schema { public String createEntity(String entityName, String entityLabel, String comments, String mainEntity, boolean haveNameField) { if (entityName != null) { if (MetadataHelper.containsEntity(entityName)) { - throw new MetadataModificationException($L("实体已存在 : %s", entityName)); + throw new MetadataModificationException(Language.L("实体已存在 : %s", entityName)); } } else { @@ -85,7 +84,7 @@ public class Entity2Schema extends Field2Schema { final boolean isDetail = StringUtils.isNotBlank(mainEntity); if (isDetail && !MetadataHelper.containsEntity(mainEntity)) { - throw new MetadataModificationException($L("无效主实体 : %s", mainEntity)); + throw new MetadataModificationException(Language.L("无效主实体 : %s", mainEntity)); } String physicalName = "T__" + entityName.toUpperCase(); @@ -128,38 +127,38 @@ public class Entity2Schema extends Field2Schema { if (haveNameField) { createUnsafeField( - tempEntity, nameFiled, $L("%s名称", entityLabel), DisplayType.TEXT, false, true, true, true, true, null, null, null, null, null); + tempEntity, nameFiled, Language.L("%s名称", entityLabel), DisplayType.TEXT, false, true, true, true, true, null, null, null, null, null); } - createBuiltinField(tempEntity, EntityHelper.CreatedBy, $L("创建人"), DisplayType.REFERENCE, null, "User", null); - createBuiltinField(tempEntity, EntityHelper.CreatedOn, $L("创建时间"), DisplayType.DATETIME, null, null, null); - createBuiltinField(tempEntity, EntityHelper.ModifiedBy, $L("修改人"), DisplayType.REFERENCE, null, "User", null); - createBuiltinField(tempEntity, EntityHelper.ModifiedOn, $L("修改时间"), DisplayType.DATETIME, null, null, null); + createBuiltinField(tempEntity, EntityHelper.CreatedBy, Language.L("创建人"), DisplayType.REFERENCE, null, "User", null); + createBuiltinField(tempEntity, EntityHelper.CreatedOn, Language.L("创建时间"), DisplayType.DATETIME, null, null, null); + createBuiltinField(tempEntity, EntityHelper.ModifiedBy, Language.L("修改人"), DisplayType.REFERENCE, null, "User", null); + createBuiltinField(tempEntity, EntityHelper.ModifiedOn, Language.L("修改时间"), DisplayType.DATETIME, null, null, null); // 明细实体关联字段 // 明细实体无所属用户或部门,使用主实体的 if (isDetail) { String mainLabel = EasyMetaFactory.valueOf(mainEntity).getLabel(); String mainPrimary = mainEntity + "Id"; - createBuiltinField(tempEntity, mainPrimary, mainLabel, DisplayType.REFERENCE, $L("引用主记录"), mainEntity, CascadeModel.Delete); + createBuiltinField(tempEntity, mainPrimary, mainLabel, DisplayType.REFERENCE, Language.L("引用主记录"), mainEntity, CascadeModel.Delete); } else { // 助记码/搜索码 createUnsafeField( - tempEntity, EntityHelper.QuickCode, $L("助记码"), DisplayType.TEXT, true, false, false, true, false, null, null, null, null, null); + tempEntity, EntityHelper.QuickCode, Language.L("助记码"), DisplayType.TEXT, true, false, false, true, false, null, null, null, null, null); - createBuiltinField(tempEntity, EntityHelper.OwningUser, $L("所属用户"), DisplayType.REFERENCE, null, "User", null); - createBuiltinField(tempEntity, EntityHelper.OwningDept, $L("所属部门"), DisplayType.REFERENCE, null, "Department", null); + createBuiltinField(tempEntity, EntityHelper.OwningUser, Language.L("所属用户"), DisplayType.REFERENCE, null, "User", null); + createBuiltinField(tempEntity, EntityHelper.OwningDept, Language.L("所属部门"), DisplayType.REFERENCE, null, "Department", null); } } catch (Throwable ex) { log.error(null, ex); Application.getCommonsService().delete(tempMetaId.toArray(new ID[0])); - throw new MetadataModificationException($L("无法同步元数据到数据库 : %s", ex.getLocalizedMessage())); + throw new MetadataModificationException(Language.L("无法同步元数据到数据库 : %s", ex.getLocalizedMessage())); } boolean schemaReady = schema2Database(tempEntity); if (!schemaReady) { Application.getCommonsService().delete(tempMetaId.toArray(new ID[0])); - throw new MetadataModificationException($L("无法同步元数据到数据库")); + throw new MetadataModificationException(Language.L("无法同步元数据到数据库")); } MetadataHelper.getMetadataFactory().refresh(false); @@ -181,13 +180,13 @@ public class Entity2Schema extends Field2Schema { */ public boolean dropEntity(Entity entity, boolean force) { if (!user.equals(UserService.ADMIN_USER)) { - throw new MetadataModificationException($L("仅超级管理员可删除实体")); + throw new MetadataModificationException(Language.L("仅超级管理员可删除实体")); } EasyEntity easy = EasyMetaFactory.valueOf(entity); ID metaRecordId = easy.getMetaId(); if (easy.isBuiltin() || metaRecordId == null) { - throw new MetadataModificationException($L("系统内置,不允许删除")); + throw new MetadataModificationException(Language.L("系统内置,不允许删除")); } // 强制删除先删除明细实体 @@ -199,11 +198,11 @@ public class Entity2Schema extends Field2Schema { if (dropDetail) { entity = MetadataHelper.getEntity(entity.getEntityCode()); } else { - throw new MetadataModificationException($L("不能直接删除主实体,请先删除明细实体")); + throw new MetadataModificationException(Language.L("不能直接删除主实体,请先删除明细实体")); } } else { - throw new MetadataModificationException($L("不能直接删除主实体,请先删除明细实体")); + throw new MetadataModificationException(Language.L("不能直接删除主实体,请先删除明细实体")); } } @@ -211,14 +210,14 @@ public class Entity2Schema extends Field2Schema { if (whoRef.getOwnEntity().equals(entity)) continue; if (whoRef.getType() == FieldType.ANY_REFERENCE) continue; throw new MetadataModificationException( - $L("实体已被其他实体引用 (引用实体 : %s)", $L(whoRef.getOwnEntity()))); + Language.L("实体已被其他实体引用 (引用实体 : %s)", Language.L(whoRef.getOwnEntity()))); } // 有记录的强删 if (!force) { long count; if ((count = checkRecordCount(entity)) > 0) { - throw new MetadataModificationException($L("不能删除有数据的实体 (记录数 : %d)", count)); + throw new MetadataModificationException(Language.L("不能删除有数据的实体 (记录数 : %d)", count)); } } diff --git a/src/main/java/com/rebuild/core/metadata/impl/Field2Schema.java b/src/main/java/com/rebuild/core/metadata/impl/Field2Schema.java index 2e5add843..89dd93cc3 100644 --- a/src/main/java/com/rebuild/core/metadata/impl/Field2Schema.java +++ b/src/main/java/com/rebuild/core/metadata/impl/Field2Schema.java @@ -27,6 +27,7 @@ import com.rebuild.core.metadata.easymeta.DisplayType; import com.rebuild.core.metadata.easymeta.EasyField; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.UserHelper; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.setup.Installer; import com.rebuild.utils.BlockList; import com.rebuild.utils.RbAssert; @@ -38,8 +39,6 @@ import org.apache.commons.lang.math.RandomUtils; import java.util.HashSet; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 创建字段 * @@ -59,7 +58,7 @@ public class Field2Schema { * @param user */ public Field2Schema(ID user) { - RbAssert.isAllow(UserHelper.isSuperAdmin(user), $L("仅超级管理员可操作")); + RbAssert.isAllow(UserHelper.isSuperAdmin(user), Language.L("仅超级管理员可操作")); this.user = user; } @@ -75,7 +74,7 @@ public class Field2Schema { public String createField(Entity entity, String fieldLabel, DisplayType type, String comments, String refEntity, JSON extConfig) { long count; if ((count = checkRecordCount(entity)) > 100000) { - throw new MetadataModificationException($L("实体记录过多 (%d),增加/删除字段可能导致表损坏", count)); + throw new MetadataModificationException(Language.L("实体记录过多 (%d),增加/删除字段可能导致表损坏", count)); } String fieldName = toPinyinName(fieldLabel); @@ -93,7 +92,7 @@ public class Field2Schema { boolean schemaReady = schema2Database(entity, new Field[]{field}); if (!schemaReady) { Application.getCommonsService().delete(tempMetaId.toArray(new ID[0])); - throw new MetadataModificationException($L("无法同步元数据到数据库")); + throw new MetadataModificationException(Language.L("无法同步元数据到数据库")); } MetadataHelper.getMetadataFactory().refresh(false); @@ -109,18 +108,18 @@ public class Field2Schema { EasyField easyMeta = EasyMetaFactory.valueOf(field); ID metaRecordId = easyMeta.getMetaId(); if (easyMeta.isBuiltin() || metaRecordId == null) { - throw new MetadataModificationException($L("系统内置,不允许删除")); + throw new MetadataModificationException(Language.L("系统内置,不允许删除")); } Entity entity = field.getOwnEntity(); if (entity.getNameField().equals(field)) { - throw new MetadataModificationException($L("名称字段不允许删除")); + throw new MetadataModificationException(Language.L("名称字段不允许删除")); } if (!force) { long count; if ((count = checkRecordCount(entity)) > 100000) { - throw new MetadataModificationException($L("实体记录过多 (%d),增加/删除字段可能导致表损坏", count)); + throw new MetadataModificationException(Language.L("实体记录过多 (%d),增加/删除字段可能导致表损坏", count)); } } @@ -269,7 +268,7 @@ public class Field2Schema { // 在导入实体时需要,需自行保证引用实体有效性,否则系统会出错 if (!DynamicMetadataContextHolder.isSkipRefentityCheck(false)) { if (!MetadataHelper.containsEntity(refEntity)) { - throw new MetadataModificationException($L("无效引用实体 : %s", refEntity)); + throw new MetadataModificationException(Language.L("无效引用实体 : %s", refEntity)); } } @@ -289,7 +288,7 @@ public class Field2Schema { recordOfField.setInt("maxLength", maxLength); if ((dt == DisplayType.REFERENCE || dt == DisplayType.N2NREFERENCE) && StringUtils.isBlank(refEntity)) { - throw new MetadataModificationException($L("引用字段必须指定引用实体")); + throw new MetadataModificationException(Language.L("引用字段必须指定引用实体")); } recordOfField = Application.getCommonsService().create(recordOfField); diff --git a/src/main/java/com/rebuild/core/privileges/DepartmentService.java b/src/main/java/com/rebuild/core/privileges/DepartmentService.java index f186eb270..201ac350d 100644 --- a/src/main/java/com/rebuild/core/privileges/DepartmentService.java +++ b/src/main/java/com/rebuild/core/privileges/DepartmentService.java @@ -22,8 +22,6 @@ import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * for Department * @@ -64,14 +62,14 @@ public class DepartmentService extends BaseServiceImpl { if (record.hasValue("parentDept", false)) { ID parentDept = record.getID("parentDept"); if (parentDept.equals(record.getPrimary())) { - throw new DataSpecificationException($L("父级部门不能选择自己")); + throw new DataSpecificationException(Language.L("父级部门不能选择自己")); } Department parent = Application.getUserStore().getDepartment(parentDept); Department that = Application.getUserStore().getDepartment(record.getPrimary()); if (that.isChildren(parent, true)) { - throw new DataSpecificationException($L("子级部门不能同时作为父级部门")); + throw new DataSpecificationException(Language.L("子级部门不能同时作为父级部门")); } } @@ -97,10 +95,10 @@ public class DepartmentService extends BaseServiceImpl { Department dept = Application.getUserStore().getDepartment(deptId); if (!dept.getMembers().isEmpty()) { - throw new OperationDeniedException(Language.$L("部门下有用户禁止删除")); + throw new OperationDeniedException(Language.L("部门下有用户禁止删除")); } if (!dept.getChildren().isEmpty()) { - throw new OperationDeniedException(Language.$L("部门下有子部门禁止删除")); + throw new OperationDeniedException(Language.L("部门下有子部门禁止删除")); } super.delete(deptId); @@ -117,7 +115,7 @@ public class DepartmentService extends BaseServiceImpl { if (UserHelper.isAdmin(currentUser)) return; if (action == BizzPermission.CREATE || action == BizzPermission.DELETE) { - throw new PrivilegesException($L("无操作权限")); + throw new PrivilegesException(Language.L("无操作权限")); } // 用户可自己改自己的部门 @@ -125,6 +123,6 @@ public class DepartmentService extends BaseServiceImpl { if (action == BizzPermission.UPDATE && dept.equals(currentDeptOfUser)) { return; } - throw new PrivilegesException($L("无操作权限")); + throw new PrivilegesException(Language.L("无操作权限")); } } diff --git a/src/main/java/com/rebuild/core/privileges/OperationDeniedException.java b/src/main/java/com/rebuild/core/privileges/OperationDeniedException.java index 4ef49e29a..852d8e94a 100644 --- a/src/main/java/com/rebuild/core/privileges/OperationDeniedException.java +++ b/src/main/java/com/rebuild/core/privileges/OperationDeniedException.java @@ -20,7 +20,7 @@ public class OperationDeniedException extends RebuildException { private static final long serialVersionUID = 2670636377089379190L; public OperationDeniedException() { - super(Language.$L("无权操作")); + super(Language.L("无权操作")); } public OperationDeniedException(String msg) { diff --git a/src/main/java/com/rebuild/core/privileges/PrivilegesGuardInterceptor.java b/src/main/java/com/rebuild/core/privileges/PrivilegesGuardInterceptor.java index 97ba171f5..a66674bcc 100644 --- a/src/main/java/com/rebuild/core/privileges/PrivilegesGuardInterceptor.java +++ b/src/main/java/com/rebuild/core/privileges/PrivilegesGuardInterceptor.java @@ -22,6 +22,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.service.CommonsService; import com.rebuild.core.service.general.BulkContext; import com.rebuild.core.service.general.EntityService; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; @@ -31,8 +32,6 @@ import java.lang.reflect.Method; import java.security.Guard; import java.util.Objects; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 权限验证 - 拦截所有 *Service 方法 * @@ -63,7 +62,7 @@ public class PrivilegesGuardInterceptor implements MethodInterceptor, Guard { Class invocationClass = Objects.requireNonNull(invocation.getThis()).getClass(); // 验证管理员操作 if (AdminGuard.class.isAssignableFrom(invocationClass) && !UserHelper.isAdmin(caller)) { - throw new AccessDeniedException($L("权限不足,访问被阻止")); + throw new AccessDeniedException(Language.L("权限不足,访问被阻止")); } // 仅 EntityService 或子类会验证角色权限 if (!EntityService.class.isAssignableFrom(invocationClass)) { @@ -116,7 +115,7 @@ public class PrivilegesGuardInterceptor implements MethodInterceptor, Guard { Field dtmField = MetadataHelper.getDetailToMainField(entity); ID mainid = ((Record) idOrRecord).getID(dtmField.getName()); if (mainid == null || !Application.getPrivilegesManager().allowUpdate(caller, mainid)) { - throw new AccessDeniedException($L("你没有添加明细权限")); + throw new AccessDeniedException(Language.L("你没有添加明细权限")); } allowed = true; @@ -196,23 +195,23 @@ public class PrivilegesGuardInterceptor implements MethodInterceptor, Guard { private String formatHumanMessage(Permission action, Entity entity, ID target) { String actionHuman = null; if (action == BizzPermission.CREATE) { - actionHuman = $L("新建"); + actionHuman = Language.L("新建"); } else if (action == BizzPermission.DELETE) { - actionHuman = $L("删除"); + actionHuman = Language.L("删除"); } else if (action == BizzPermission.UPDATE) { - actionHuman = $L("编辑"); + actionHuman = Language.L("编辑"); } else if (action == BizzPermission.ASSIGN) { - actionHuman = $L("分派"); + actionHuman = Language.L("分派"); } else if (action == BizzPermission.SHARE) { - actionHuman = $L("共享"); + actionHuman = Language.L("共享"); } else if (action == EntityService.UNSHARE) { - actionHuman = $L("取消共享"); + actionHuman = Language.L("取消共享"); } if (target == null) { - return $L("你没有%s%s权限", actionHuman, EasyMetaFactory.getLabel(entity)); + return Language.L("你没有%s%s权限", actionHuman, EasyMetaFactory.getLabel(entity)); } else { - return $L("你没有%s此记录的权限", actionHuman); + return Language.L("你没有%s此记录的权限", actionHuman); } } } diff --git a/src/main/java/com/rebuild/core/privileges/UserService.java b/src/main/java/com/rebuild/core/privileges/UserService.java index 9459662b1..852214c41 100644 --- a/src/main/java/com/rebuild/core/privileges/UserService.java +++ b/src/main/java/com/rebuild/core/privileges/UserService.java @@ -38,8 +38,6 @@ import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * for User * @@ -105,7 +103,7 @@ public class UserService extends BaseServiceImpl { checkAdminGuard(BizzPermission.DELETE, null); if (ADMIN_USER.equals(record) || SYSTEM_USER.equals(record)) { - throw new OperationDeniedException($L("内置用户禁止删除")); + throw new OperationDeniedException(Language.L("内置用户禁止删除")); } Object[] hasLogin = Application.createQueryNoFilter( @@ -113,7 +111,7 @@ public class UserService extends BaseServiceImpl { .setParameter(1, record) .unique(); if (ObjectUtils.toInt(hasLogin[0]) > 0) { - throw new OperationDeniedException($L("已使用过的用户禁止删除")); + throw new OperationDeniedException(Language.L("已使用过的用户禁止删除")); } super.delete(record); @@ -136,7 +134,7 @@ public class UserService extends BaseServiceImpl { } if (record.hasValue("email") && Application.getUserStore().existsUser(record.getString("email"))) { - throw new DataSpecificationException($L("邮箱已存在")); + throw new DataSpecificationException(Language.L("邮箱已存在")); } if (record.getPrimary() == null && !record.hasValue("fullName")) { @@ -158,11 +156,11 @@ public class UserService extends BaseServiceImpl { */ private void checkLoginName(String loginName) throws DataSpecificationException { if (Application.getUserStore().existsUser(loginName)) { - throw new DataSpecificationException($L("用户名已存在")); + throw new DataSpecificationException(Language.L("用户名已存在")); } if (!CommonsUtils.isPlainText(loginName) || BlockList.isBlock(loginName)) { - throw new DataSpecificationException($L("用户名无效")); + throw new DataSpecificationException(Language.L("用户名无效")); } } @@ -176,13 +174,13 @@ public class UserService extends BaseServiceImpl { if (UserHelper.isAdmin(currentUser)) return; if (action == BizzPermission.CREATE || action == BizzPermission.DELETE) { - throw new AccessDeniedException($L("无操作权限")); + throw new AccessDeniedException(Language.L("无操作权限")); } // 用户可自己改自己 if (action == BizzPermission.UPDATE && currentUser.equals(user)) return; - throw new AccessDeniedException($L("无操作权限")); + throw new AccessDeniedException(Language.L("无操作权限")); } /** @@ -193,7 +191,7 @@ public class UserService extends BaseServiceImpl { */ protected void checkPassword(String password) throws DataSpecificationException { if (password.length() < 6) { - throw new DataSpecificationException($L("密码不能小于 6 位")); + throw new DataSpecificationException(Language.L("密码不能小于 6 位")); } int policy = RebuildConfiguration.getInt(ConfigurationItem.PasswordPolicy); @@ -218,10 +216,10 @@ public class UserService extends BaseServiceImpl { } if (countUpper == 0 || countLower == 0 || countDigit == 0) { - throw new DataSpecificationException($L("密码不能小于 6 位,且必须包含数字和大小写字母")); + throw new DataSpecificationException(Language.L("密码不能小于 6 位,且必须包含数字和大小写字母")); } if (policy >= 3 && (countSpecial == 0 || password.length() < 8)) { - throw new DataSpecificationException($L("密码不能小于 8 位,且必须包含数字和大小写字母及特殊字符")); + throw new DataSpecificationException(Language.L("密码不能小于 8 位,且必须包含数字和大小写字母及特殊字符")); } } @@ -239,10 +237,10 @@ public class UserService extends BaseServiceImpl { String homeUrl = RebuildConfiguration.getHomeUrl(); LanguageBundle bundle = Language.getSysDefaultBundle(); - String content = bundle.$L("系统管理员已经为你开通了 %s 账号!以下为你的登录信息,请妥善保管。 [] 登录账号 : **%s** [] 登录密码 : **%s** [] 登录地址 : [%s](%s) [][] 首次登陆,建议你立即修改登陆密码。修改方式 : 登陆后点击右上角头像 - 个人设置 - 安全设置 - 更改密码", + String content = bundle.L("系统管理员已经为你开通了 %s 账号!以下为你的登录信息,请妥善保管。 [] 登录账号 : **%s** [] 登录密码 : **%s** [] 登录地址 : [%s](%s) [][] 首次登陆,建议你立即修改登陆密码。修改方式 : 登陆后点击右上角头像 - 个人设置 - 安全设置 - 更改密码", appName, newUser.getString("loginName"), passwd, homeUrl, homeUrl); - SMSender.sendMailAsync(newUser.getString("email"), $L("你的账号已就绪"), content); + SMSender.sendMailAsync(newUser.getString("email"), Language.L("你的账号已就绪"), content); return true; } @@ -363,7 +361,7 @@ public class UserService extends BaseServiceImpl { // 通知管理员 ID newUserId = record.getPrimary(); String viewUrl = AppUtils.getContextPath() + "/app/list-and-view?id=" + newUserId; - String content = $L("用户 @%s 提交了注册申请。请验证用户有效性后为其指定部门和角色,激活用户登录。如果这是一个无效的申请请忽略。[点击开始激活](%s)", + String content = Language.L("用户 @%s 提交了注册申请。请验证用户有效性后为其指定部门和角色,激活用户登录。如果这是一个无效的申请请忽略。[点击开始激活](%s)", newUserId, viewUrl); Message message = MessageBuilder.createMessage(ADMIN_USER, content, newUserId); diff --git a/src/main/java/com/rebuild/core/rbstore/MetaschemaImporter.java b/src/main/java/com/rebuild/core/rbstore/MetaschemaImporter.java index 801677214..d99a836cc 100644 --- a/src/main/java/com/rebuild/core/rbstore/MetaschemaImporter.java +++ b/src/main/java/com/rebuild/core/rbstore/MetaschemaImporter.java @@ -28,6 +28,7 @@ import com.rebuild.core.metadata.impl.MetadataModificationException; import com.rebuild.core.privileges.UserService; import com.rebuild.core.service.approval.RobotApprovalConfigService; import com.rebuild.core.service.trigger.RobotTriggerConfigService; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.task.HeavyTask; import com.rebuild.utils.JSONUtils; @@ -35,8 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 元数据模型导入 * @@ -84,7 +83,7 @@ public class MetaschemaImporter extends HeavyTask { private String verfiyEntity(JSONObject entity) { String entityName = entity.getString("entity"); if (MetadataHelper.containsEntity(entityName)) { - return $L("实体名称已存在 : %s",entityName); + return Language.L("实体名称已存在 : %s",entityName); } for (Object o : entity.getJSONArray("fields")) { @@ -93,7 +92,7 @@ public class MetaschemaImporter extends HeavyTask { if (DisplayType.REFERENCE.name().equals(dt) || DisplayType.N2NREFERENCE.name().equals(dt)) { String refEntity = field.getString("refEntity"); if (!entityName.equals(refEntity) && !MetadataHelper.containsEntity(refEntity)) { - return $L("缺少必要的引用实体 : %s (%s)", field.getString("fieldLabel"), refEntity); + return Language.L("缺少必要的引用实体 : %s (%s)", field.getString("fieldLabel"), refEntity); } } } diff --git a/src/main/java/com/rebuild/core/service/approval/ApprovalFields2Schema.java b/src/main/java/com/rebuild/core/service/approval/ApprovalFields2Schema.java index df678cd2e..ca905301a 100644 --- a/src/main/java/com/rebuild/core/service/approval/ApprovalFields2Schema.java +++ b/src/main/java/com/rebuild/core/service/approval/ApprovalFields2Schema.java @@ -19,8 +19,7 @@ import com.rebuild.core.metadata.easymeta.DisplayType; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.metadata.impl.Field2Schema; import com.rebuild.core.metadata.impl.MetadataModificationException; - -import static com.rebuild.core.support.i18n.Language.$L; +import com.rebuild.core.support.i18n.Language; /** * 审批流程字段 @@ -47,11 +46,11 @@ public class ApprovalFields2Schema extends Field2Schema { throw new RebuildException("Unsupported entity : " + approvalEntity.getName()); } - Field apporvalId = createUnsafeField(approvalEntity, EntityHelper.ApprovalId, $L("审核流程"), + Field apporvalId = createUnsafeField(approvalEntity, EntityHelper.ApprovalId, Language.L("审核流程"), DisplayType.REFERENCE, true, false, false, true, true, null, "RobotApprovalConfig", CascadeModel.Ignore, null, null); - Field apporvalState = createUnsafeField(approvalEntity, EntityHelper.ApprovalState, $L("审核状态"), + Field apporvalState = createUnsafeField(approvalEntity, EntityHelper.ApprovalState, Language.L("审核状态"), DisplayType.STATE, true, false, false, true, true, null, null, null, null, ApprovalState.DRAFT.getState()); - Field apporvalStepId = createUnsafeField(approvalEntity, EntityHelper.ApprovalStepNode, $L("审核步骤"), + Field apporvalStepId = createUnsafeField(approvalEntity, EntityHelper.ApprovalStepNode, Language.L("审核步骤"), DisplayType.TEXT, true, false, false, true, false, null, null, null, null, null); boolean schemaReady = schema2Database(approvalEntity, @@ -59,7 +58,7 @@ public class ApprovalFields2Schema extends Field2Schema { if (!schemaReady) { Application.getCommonsService().delete(tempMetaId.toArray(new ID[0])); - throw new MetadataModificationException($L("无法同步元数据到数据库")); + throw new MetadataModificationException(Language.L("无法同步元数据到数据库")); } MetadataHelper.getMetadataFactory().refresh(false); diff --git a/src/main/java/com/rebuild/core/service/approval/ApprovalHelper.java b/src/main/java/com/rebuild/core/service/approval/ApprovalHelper.java index f9f9641ce..a8fbd5fca 100644 --- a/src/main/java/com/rebuild/core/service/approval/ApprovalHelper.java +++ b/src/main/java/com/rebuild/core/service/approval/ApprovalHelper.java @@ -15,11 +15,10 @@ import com.rebuild.core.Application; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.service.NoRecordFoundException; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2019/10/23 @@ -64,7 +63,7 @@ public class ApprovalHelper { Object[] o = Application.getQueryFactory().uniqueNoFilter(recordId, EntityHelper.ApprovalId, EntityHelper.ApprovalId + ".name", EntityHelper.ApprovalState, EntityHelper.ApprovalStepNode); if (o == null) { - throw new NoRecordFoundException($L("无权读取此记录或记录已被删除")); + throw new NoRecordFoundException(Language.L("无权读取此记录或记录已被删除")); } return new ApprovalStatus((ID) o[0], (String) o[1], (Integer) o[2], (String) o[3], recordId); } diff --git a/src/main/java/com/rebuild/core/service/approval/ApprovalProcessor.java b/src/main/java/com/rebuild/core/service/approval/ApprovalProcessor.java index 7f753c6d8..9971b636e 100644 --- a/src/main/java/com/rebuild/core/service/approval/ApprovalProcessor.java +++ b/src/main/java/com/rebuild/core/service/approval/ApprovalProcessor.java @@ -20,6 +20,7 @@ import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.service.general.EntityService; import com.rebuild.core.support.SetUser; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -28,8 +29,6 @@ import org.springframework.util.Assert; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 审批处理 * @@ -76,7 +75,7 @@ public class ApprovalProcessor extends SetUser { public boolean submit(JSONObject selectNextUsers) throws ApprovalException { final ApprovalState currentState = ApprovalHelper.getApprovalState(this.record); if (currentState == ApprovalState.PROCESSING || currentState == ApprovalState.APPROVED) { - throw new ApprovalException($L("无效审批状态 (%s) ,请刷新后重试", currentState)); + throw new ApprovalException(Language.L("无效审批状态 (%s) ,请刷新后重试", currentState)); } FlowNodeGroup nextNodes = getNextNodes(FlowNode.NODE_ROOT); @@ -134,7 +133,7 @@ public class ApprovalProcessor extends SetUser { final ApprovalStatus status = ApprovalHelper.getApprovalStatus(this.record); ApprovalState currentState = status.getCurrentState(); if (currentState != ApprovalState.PROCESSING) { - throw new ApprovalException($L("无效审批状态 (%s) ,请刷新后重试", currentState)); + throw new ApprovalException(Language.L("无效审批状态 (%s) ,请刷新后重试", currentState)); } final Object[] stepApprover = Application.createQueryNoFilter( @@ -144,8 +143,8 @@ public class ApprovalProcessor extends SetUser { .setParameter(3, getCurrentNodeId(status)) .unique(); if (stepApprover == null || (Integer) stepApprover[1] != ApprovalState.DRAFT.getState()) { - throw new ApprovalException($L(stepApprover == null - ? $L("当前流程已经被他人审批") : $L("你已经审批过当前流程"))); + throw new ApprovalException(Language.L(stepApprover == null + ? Language.L("当前流程已经被他人审批") : Language.L("你已经审批过当前流程"))); } Record approvedStep = EntityHelper.forUpdate((ID) stepApprover[0], approver); @@ -164,7 +163,7 @@ public class ApprovalProcessor extends SetUser { if (state == ApprovalState.APPROVED && !nextNodes.isLastStep()) { nextApprovers = nextNodes.getApproveUsers(this.getUser(), this.record, selectNextUsers); if (nextApprovers.isEmpty()) { - throw new ApprovalException($L("下一流程无审批人可用,请联系管理员配置")); + throw new ApprovalException(Language.L("下一流程无审批人可用,请联系管理员配置")); } FlowNode nextApprovalNode = nextNodes.getApprovalNode(); @@ -191,7 +190,7 @@ public class ApprovalProcessor extends SetUser { final ApprovalStatus status = ApprovalHelper.getApprovalStatus(this.record); ApprovalState currentState = status.getCurrentState(); if (currentState != ApprovalState.PROCESSING) { - throw new ApprovalException($L("无效审批状态 (%s) ,请刷新后重试", currentState)); + throw new ApprovalException(Language.L("无效审批状态 (%s) ,请刷新后重试", currentState)); } Application.getBean(ApprovalStepService.class).txCancel( @@ -206,7 +205,7 @@ public class ApprovalProcessor extends SetUser { public void revoke() throws ApprovalException { final ApprovalStatus status = ApprovalHelper.getApprovalStatus(this.record); if (status.getCurrentState() != ApprovalState.APPROVED) { - throw new ApprovalException($L("无效审批状态 (%s) ,请刷新后重试", status.getCurrentState())); + throw new ApprovalException(Language.L("无效审批状态 (%s) ,请刷新后重试", status.getCurrentState())); } Object[] count = Application.createQueryNoFilter( @@ -215,7 +214,7 @@ public class ApprovalProcessor extends SetUser { .setParameter(2, ApprovalState.REVOKED.getState()) .unique(); if (ObjectUtils.toInt(count[0]) >= MAX_REVOKED) { - throw new ApprovalException($L("记录撤销次数已达 %d 次,不能再次撤销", MAX_REVOKED)); + throw new ApprovalException(Language.L("记录撤销次数已达 %d 次,不能再次撤销", MAX_REVOKED)); } Application.getBean(ApprovalStepService.class).txCancel( @@ -388,7 +387,7 @@ public class ApprovalProcessor extends SetUser { stepGroup.add(o); } if (firstStep == null) { - throw new ConfigurationException($L("无效审批记录 (%s)", this.record)); + throw new ConfigurationException(Language.L("无效审批记录 (%s)", this.record)); } JSONArray steps = new JSONArray(); diff --git a/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java b/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java index 2b3aa06a7..f37ea006d 100644 --- a/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java +++ b/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java @@ -20,12 +20,11 @@ import com.rebuild.core.service.BaseService; import com.rebuild.core.service.DataSpecificationNoRollbackException; import com.rebuild.core.service.general.GeneralEntityServiceContextHolder; import com.rebuild.core.service.notification.MessageBuilder; +import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 审批流程。此类所有方法不应直接调用,而是通过 ApprovalProcessor *

@@ -70,7 +69,7 @@ public class ApprovalStepService extends BaseService { String entityLabel = EasyMetaFactory.getLabel(recordOfMain.getEntity()); // 审批人 - String approvalMsg = $L("有一条 %s 记录请你审批", entityLabel); + String approvalMsg = Language.L("有一条 %s 记录请你审批", entityLabel); Record step = EntityHelper.forNew(EntityHelper.RobotApprovalStep, submitter); step.setID("recordId", recordId); @@ -87,7 +86,7 @@ public class ApprovalStepService extends BaseService { // 抄送人 if (cc != null && !cc.isEmpty()) { - String ccMsg = $L("用户 @%s 提交了一条 %s 审批,请知晓", submitter, entityLabel); + String ccMsg = Language.L("用户 @%s 提交了一条 %s 审批,请知晓", submitter, entityLabel); for (ID to : cc) { Application.getNotifications().send(MessageBuilder.createApproval(to, ccMsg, recordId)); } @@ -128,7 +127,7 @@ public class ApprovalStepService extends BaseService { ApprovalProcessor approvalProcessor = new ApprovalProcessor((ID) stepObject[0], (ID) stepObject[1]); FlowNodeGroup nextNodes = approvalProcessor.getNextNodes(); if (!nextNodes.getGroupId().equals(checkUseGroup)) { - throw new DataSpecificationNoRollbackException($L("由于更改数据导致流程变化,你需要重新审批")); + throw new DataSpecificationNoRollbackException(Language.L("由于更改数据导致流程变化,你需要重新审批")); } } } @@ -151,8 +150,8 @@ public class ApprovalStepService extends BaseService { // 抄送人 if (cc != null && !cc.isEmpty()) { - String ccMsg = $L("用户 @%s 提交的 %s 审批已由 @%s %s,请知晓", - submitter, entityLabel, approver, $L(state)); + String ccMsg = Language.L("用户 @%s 提交的 %s 审批已由 @%s %s,请知晓", + submitter, entityLabel, approver, Language.L(state)); for (ID c : cc) { Application.getNotifications().send(MessageBuilder.createApproval(c, ccMsg, recordId)); } @@ -168,7 +167,7 @@ public class ApprovalStepService extends BaseService { recordOfMain.setInt(EntityHelper.ApprovalState, ApprovalState.REJECTED.getState()); super.update(recordOfMain); - String rejectedMsg = $L("@%s 驳回了你的 %s 审批", approver, entityLabel); + String rejectedMsg = Language.L("@%s 驳回了你的 %s 审批", approver, entityLabel); Application.getNotifications().send(MessageBuilder.createApproval(submitter, rejectedMsg, recordId)); return; } @@ -176,7 +175,7 @@ public class ApprovalStepService extends BaseService { // 或签/会签 boolean goNextNode = true; - String approvalMsg = $L("有一条 %s 记录请你审批", entityLabel); + String approvalMsg = Language.L("有一条 %s 记录请你审批", entityLabel); // 或签。一人通过其他作废 if (FlowNode.SIGN_OR.equals(signMode)) { @@ -391,7 +390,7 @@ public class ApprovalStepService extends BaseService { FlowNode.NODE_AUTOAPPROVAL, useApprover, false, FlowNode.NODE_ROOT); Record step = EntityHelper.forUpdate(stepId, useApprover, false); step.setInt("state", ApprovalState.APPROVED.getState()); - step.setString("remark", $L("自动审批")); + step.setString("remark", Language.L("自动审批")); super.update(step); // 更新记录审批状态 diff --git a/src/main/java/com/rebuild/core/service/approval/FlowParser.java b/src/main/java/com/rebuild/core/service/approval/FlowParser.java index 4c08c3acf..e56a0c24e 100644 --- a/src/main/java/com/rebuild/core/service/approval/FlowParser.java +++ b/src/main/java/com/rebuild/core/service/approval/FlowParser.java @@ -10,13 +10,12 @@ package com.rebuild.core.service.approval; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import org.apache.commons.lang.StringUtils; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 流程解析 * @@ -125,7 +124,7 @@ public class FlowParser { if (nodeMap.containsKey(nodeId)) { return nodeMap.get(nodeId); } - throw new ApprovalException($L("无效审核步骤节点 (%s)", nodeId)); + throw new ApprovalException(Language.L("无效审核步骤节点 (%s)", nodeId)); } /** diff --git a/src/main/java/com/rebuild/core/service/approval/RobotApprovalConfigService.java b/src/main/java/com/rebuild/core/service/approval/RobotApprovalConfigService.java index ac2527077..6dbdf2006 100644 --- a/src/main/java/com/rebuild/core/service/approval/RobotApprovalConfigService.java +++ b/src/main/java/com/rebuild/core/service/approval/RobotApprovalConfigService.java @@ -23,8 +23,6 @@ import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 审批流程 * @@ -56,7 +54,7 @@ public class RobotApprovalConfigService extends BaseConfigurationService impleme if (record.hasValue("flowDefinition")) { int inUsed = ApprovalHelper.checkInUsed(record.getPrimary()); if (inUsed > 0) { - throw new DataSpecificationException($L("有 %d 条记录正在使用此流程,禁止修改", inUsed)); + throw new DataSpecificationException(Language.L("有 %d 条记录正在使用此流程,禁止修改", inUsed)); } } return super.update(record); @@ -75,7 +73,7 @@ public class RobotApprovalConfigService extends BaseConfigurationService impleme } if (inUsed > 0) { - throw new DataSpecificationException($L("有 %d 条记录正在使用此流程,禁止删除", inUsed)); + throw new DataSpecificationException(Language.L("有 %d 条记录正在使用此流程,禁止删除", inUsed)); } return super.delete(recordId); } diff --git a/src/main/java/com/rebuild/core/service/dashboard/DashboardManager.java b/src/main/java/com/rebuild/core/service/dashboard/DashboardManager.java index 967cfbc86..1e01edd59 100644 --- a/src/main/java/com/rebuild/core/service/dashboard/DashboardManager.java +++ b/src/main/java/com/rebuild/core/service/dashboard/DashboardManager.java @@ -21,8 +21,6 @@ import com.rebuild.utils.JSONUtils; import java.util.Arrays; import java.util.Comparator; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 首页仪表盘 * @@ -58,7 +56,7 @@ public class DashboardManager extends ShareToManager { if (detected == null) { Record record = EntityHelper.forNew(EntityHelper.DashboardConfig, user); record.setString("config", JSONUtils.EMPTY_ARRAY_STR); - record.setString("title", UserHelper.isAdmin(user) ? $L("默认仪表盘") : $L("我的仪表盘")); + record.setString("title", UserHelper.isAdmin(user) ? Language.L("默认仪表盘") : Language.L("我的仪表盘")); record.setString("shareTo", UserHelper.isAdmin(user) ? SHARE_ALL : SHARE_SELF); Application.getBean(DashboardConfigService.class).create(record); } diff --git a/src/main/java/com/rebuild/core/service/dashboard/charts/ChartData.java b/src/main/java/com/rebuild/core/service/dashboard/charts/ChartData.java index 11f404295..5f2801ced 100644 --- a/src/main/java/com/rebuild/core/service/dashboard/charts/ChartData.java +++ b/src/main/java/com/rebuild/core/service/dashboard/charts/ChartData.java @@ -34,8 +34,6 @@ import java.text.DecimalFormat; import java.text.MessageFormat; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 图表数据 * @@ -157,7 +155,7 @@ public abstract class ChartData extends SetUser implements ChartSpec { private Field[] getValidFields(JSONObject item) { String fieldName = item.getString("field"); if (MetadataHelper.getLastJoinField(getSourceEntity(), fieldName) == null) { - throw new DefinedException($L("字段 [%s] 已不存在,请调整图表配置", fieldName.toUpperCase())); + throw new DefinedException(Language.L("字段 [%s] 已不存在,请调整图表配置", fieldName.toUpperCase())); } Field[] fields = new Field[2]; diff --git a/src/main/java/com/rebuild/core/service/dashboard/charts/ChartsFactory.java b/src/main/java/com/rebuild/core/service/dashboard/charts/ChartsFactory.java index a0f2ec51e..7cd62b994 100644 --- a/src/main/java/com/rebuild/core/service/dashboard/charts/ChartsFactory.java +++ b/src/main/java/com/rebuild/core/service/dashboard/charts/ChartsFactory.java @@ -22,8 +22,6 @@ import com.rebuild.core.service.dashboard.charts.builtin.BuiltinChart; import com.rebuild.core.service.dashboard.charts.builtin.FeedsSchedule; import com.rebuild.core.support.i18n.Language; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 12/15/2018 @@ -38,7 +36,7 @@ public class ChartsFactory { public static ChartData create(ID chartId) throws ChartsException { ConfigBean chart = ChartManager.instance.getChart(chartId); if (chart == null) { - throw new ChartsException($L("无效图表")); + throw new ChartsException(Language.L("无效图表")); } JSONObject config = (JSONObject) chart.getJSON("config"); @@ -55,12 +53,12 @@ public class ChartsFactory { public static ChartData create(JSONObject config, ID user) throws ChartsException { String entityName = config.getString("entity"); if (!MetadataHelper.containsEntity(entityName)) { - throw new ChartsException($L("源实体 [%s] 已不存在", entityName.toUpperCase())); + throw new ChartsException(Language.L("源实体 [%s] 已不存在", entityName.toUpperCase())); } Entity entity = MetadataHelper.getEntity(entityName); if (user == null || !Application.getPrivilegesManager().allowRead(user, entity.getEntityCode())) { - throw new DefinedException($L("没有读取 %s 的权限", EasyMetaFactory.getLabel(entity))); + throw new DefinedException(Language.L("没有读取 %s 的权限", EasyMetaFactory.getLabel(entity))); } String type = config.getString("type"); diff --git a/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/ApprovalList.java b/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/ApprovalList.java index 8c0ce3c4f..b4f6baa1f 100644 --- a/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/ApprovalList.java +++ b/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/ApprovalList.java @@ -48,7 +48,7 @@ public class ApprovalList extends ChartData implements BuiltinChart { @Override public String getChartTitle() { - return Language.$L("我的审批"); + return Language.L("我的审批"); } @Override diff --git a/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/FeedsSchedule.java b/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/FeedsSchedule.java index c4ae4eb6c..825c8f115 100644 --- a/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/FeedsSchedule.java +++ b/src/main/java/com/rebuild/core/service/dashboard/charts/builtin/FeedsSchedule.java @@ -44,7 +44,7 @@ public class FeedsSchedule extends ChartData implements BuiltinChart { @Override public String getChartTitle() { - return Language.$L("我的日程"); + return Language.L("我的日程"); } @Override diff --git a/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java b/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java index 25343d6ef..3f7956207 100644 --- a/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java +++ b/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java @@ -23,17 +23,11 @@ import com.rebuild.core.support.general.DataListWrapper; import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.StringUtils; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; +import java.io.*; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 数据导出 * @@ -162,13 +156,13 @@ public class DataExporter extends SetUser { } if (cellVal.toString().equals(DataListWrapper.NO_READ_PRIVILEGES)) { - cellVal = $L("[无权限]"); + cellVal = Language.L("[无权限]"); } else if (dt == DisplayType.FILE || dt == DisplayType.IMAGE || dt == DisplayType.AVATAR || dt == DisplayType.BARCODE) { - cellVal = $L("[暂不支持]"); + cellVal = Language.L("[暂不支持]"); } else if (dt == DisplayType.DECIMAL || dt == DisplayType.NUMBER) { cellVal = cellVal.toString().replace(",", ""); // 移除千分位 diff --git a/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java b/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java index 6be37404d..3f1a2eebb 100644 --- a/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java +++ b/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java @@ -29,8 +29,6 @@ import org.springframework.util.Assert; import java.io.File; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 报表生成 easyexcel * https://alibaba-easyexcel.github.io/quickstart/fill.html @@ -180,8 +178,8 @@ public class EasyExcelGenerator extends SetUser { protected Map buildData(Record record, Map varsMap, boolean isDetail) { final Entity entity = record.getEntity(); - final String badFieldTip = $L("[无效字段]"); - final String unsupportFieldTip = $L("[暂不支持]"); + final String badFieldTip = Language.L("[无效字段]"); + final String unsupportFieldTip = Language.L("[暂不支持]"); final Map data = new HashMap<>(); // 无效字段填充 diff --git a/src/main/java/com/rebuild/core/service/feeds/FeedsScheduleJob.java b/src/main/java/com/rebuild/core/service/feeds/FeedsScheduleJob.java index 5eab880ca..57251524b 100644 --- a/src/main/java/com/rebuild/core/service/feeds/FeedsScheduleJob.java +++ b/src/main/java/com/rebuild/core/service/feeds/FeedsScheduleJob.java @@ -86,7 +86,7 @@ public class FeedsScheduleJob extends DistributedJobLock { // 消息通知 if (!notifications.isEmpty()) { - String subject = bundle.$L("你有 %d 条日程提醒", notifications.size()); + String subject = bundle.L("你有 %d 条日程提醒", notifications.size()); String contents = subject + mergeContents(notifications, false); Application.getNotifications().send( MessageBuilder.createMessage(toUser, contents, Message.TYPE_FEEDS)); @@ -95,7 +95,7 @@ public class FeedsScheduleJob extends DistributedJobLock { // 邮件 final String emailAddr = Application.getUserStore().getUser(toUser).getEmail(); if (SMSender.availableMail() && RegexUtils.isEMail(emailAddr) && !emails.isEmpty()) { - String subject = bundle.$L("你有 %d 条日程提醒", emails.size()); + String subject = bundle.L("你有 %d 条日程提醒", emails.size()); String contents = mergeContents(emails, true); contents = MessageBuilder.formatMessage(contents, true, false); SMSender.sendMailAsync(emailAddr, subject, contents); @@ -104,7 +104,7 @@ public class FeedsScheduleJob extends DistributedJobLock { // 短信(考虑短信字数,内容简化了) final String mobileAddr = Application.getUserStore().getUser(toUser).getWorkphone(); if (SMSender.availableSMS() && RegexUtils.isCNMobile(mobileAddr) && !smss.isEmpty()) { - String subject = bundle.$L("你有 %d 条日程提醒", smss.size()); + String subject = bundle.L("你有 %d 条日程提醒", smss.size()); SMSender.sendSMSAsync(mobileAddr, subject); } } diff --git a/src/main/java/com/rebuild/core/service/feeds/FeedsService.java b/src/main/java/com/rebuild/core/service/feeds/FeedsService.java index 00cf56fb8..c15e15148 100644 --- a/src/main/java/com/rebuild/core/service/feeds/FeedsService.java +++ b/src/main/java/com/rebuild/core/service/feeds/FeedsService.java @@ -39,7 +39,7 @@ public class FeedsService extends BaseFeedsService { Integer type = record.getInt("type"); if (type != null && type == FeedsType.ANNOUNCEMENT.getMask() && !UserHelper.isAdmin(UserContextHolder.getUser())) { - throw new OperationDeniedException(Language.$L("仅管理员可发布公告")); + throw new OperationDeniedException(Language.L("仅管理员可发布公告")); } return super.createOrUpdate(record); diff --git a/src/main/java/com/rebuild/core/service/files/AttachmentFolderService.java b/src/main/java/com/rebuild/core/service/files/AttachmentFolderService.java index 123cb6470..5189da027 100644 --- a/src/main/java/com/rebuild/core/service/files/AttachmentFolderService.java +++ b/src/main/java/com/rebuild/core/service/files/AttachmentFolderService.java @@ -18,8 +18,6 @@ import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 文件目录 * @@ -45,7 +43,7 @@ public class AttachmentFolderService extends BaseService { .setParameter(1, recordId) .unique(); if (inFolder != null) { - throw new DataSpecificationException($L("目录内有文件不能删除")); + throw new DataSpecificationException(Language.L("目录内有文件不能删除")); } Object parent = Application.createQueryNoFilter( @@ -53,7 +51,7 @@ public class AttachmentFolderService extends BaseService { .setParameter(1, recordId) .unique(); if (parent != null) { - throw new DataSpecificationException($L("目录下有子目录不能删除")); + throw new DataSpecificationException(Language.L("目录下有子目录不能删除")); } ID user = UserContextHolder.getUser(); @@ -63,7 +61,7 @@ public class AttachmentFolderService extends BaseService { .setParameter(1, recordId) .unique(); if (!user.equals(createdBy[0])) { - throw new DataSpecificationException($L("无权删除他人目录")); + throw new DataSpecificationException(Language.L("无权删除他人目录")); } } diff --git a/src/main/java/com/rebuild/core/service/general/GeneralEntityService.java b/src/main/java/com/rebuild/core/service/general/GeneralEntityService.java index b4aa34bc5..5d28aae07 100644 --- a/src/main/java/com/rebuild/core/service/general/GeneralEntityService.java +++ b/src/main/java/com/rebuild/core/service/general/GeneralEntityService.java @@ -34,6 +34,7 @@ import com.rebuild.core.service.trigger.RobotTriggerManual; import com.rebuild.core.service.trigger.RobotTriggerObserver; import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.task.TaskExecutors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -42,8 +43,6 @@ import org.springframework.util.Assert; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 业务实体核心服务,所有业务实体都应该使用此类(或子类) *
- 有业务验证 @@ -399,7 +398,7 @@ public class GeneralEntityService extends ObservableService implements EntitySer if (state == ApprovalState.APPROVED || state == ApprovalState.PROCESSING) { throw new DataSpecificationException(state == ApprovalState.APPROVED - ? $L("主记录已完成审批,不能添加明细") : $L("主记录正在审批中,不能添加明细")); + ? Language.L("主记录已完成审批,不能添加明细") : Language.L("主记录正在审批中,不能添加明细")); } } @@ -409,10 +408,10 @@ public class GeneralEntityService extends ObservableService implements EntitySer if (checkEntity.containsField(EntityHelper.ApprovalId)) { // 需要验证主记录 - String recordType = $L("记录"); + String recordType = Language.L("记录"); if (mainEntity != null) { recordId = getMainId(entity, recordId); - recordType = $L("主记录"); + recordType = Language.L("主记录"); } ApprovalState currentState; @@ -438,11 +437,11 @@ public class GeneralEntityService extends ObservableService implements EntitySer if (rejected) { if (RobotTriggerObserver.getTriggerSource() != null) { - recordType = $L("关联记录"); + recordType = Language.L("关联记录"); } throw new DataSpecificationException(currentState == ApprovalState.APPROVED - ? $L("%s已完成审批,禁止操作", recordType) : $L("%s正在审批中,禁止操作", recordType)); + ? Language.L("%s已完成审批,禁止操作", recordType) : Language.L("%s正在审批中,禁止操作", recordType)); } } } diff --git a/src/main/java/com/rebuild/core/service/general/QuickCodeReindexTask.java b/src/main/java/com/rebuild/core/service/general/QuickCodeReindexTask.java index 242b4bade..8d219967c 100644 --- a/src/main/java/com/rebuild/core/service/general/QuickCodeReindexTask.java +++ b/src/main/java/com/rebuild/core/service/general/QuickCodeReindexTask.java @@ -134,7 +134,7 @@ public class QuickCodeReindexTask extends HeavyTask { nameValue = PickListManager.instance.getLabel((ID) nameValue); } else if (dt == DisplayType.STATE) { StateSpec state = StateManager.instance.findState(nameField, nameValue); - nameValue = Language.$L(state); + nameValue = Language.L(state); } else if (dt == DisplayType.CLASSIFICATION) { nameValue = ClassificationManager.instance.getFullName((ID) nameValue); } else if (dt == DisplayType.DATE || dt == DisplayType.DATETIME) { diff --git a/src/main/java/com/rebuild/core/service/general/recyclebin/RecycleRestore.java b/src/main/java/com/rebuild/core/service/general/recyclebin/RecycleRestore.java index 67b0466e6..b65fa583c 100644 --- a/src/main/java/com/rebuild/core/service/general/recyclebin/RecycleRestore.java +++ b/src/main/java/com/rebuild/core/service/general/recyclebin/RecycleRestore.java @@ -134,7 +134,7 @@ public class RecycleRestore { */ private List conver2Record(JSONObject content, ID recordId) { if (!MetadataHelper.containsEntity(recordId.getEntityCode())) { - throw new DefinedException(Language.$L("所属实体已经不存在,无法恢复")); + throw new DefinedException(Language.L("所属实体已经不存在,无法恢复")); } JSONArray detailList = content.getJSONArray(RecycleBean.NAME_DETAILLIST); diff --git a/src/main/java/com/rebuild/core/service/project/BaseTaskService.java b/src/main/java/com/rebuild/core/service/project/BaseTaskService.java index 888c36010..196f585eb 100644 --- a/src/main/java/com/rebuild/core/service/project/BaseTaskService.java +++ b/src/main/java/com/rebuild/core/service/project/BaseTaskService.java @@ -45,6 +45,6 @@ public abstract class BaseTaskService extends ObservableService { : ProjectManager.instance.getProject(taskOrProject, null); if (c != null && c.get("members", Set.class).contains(user)) return true; - throw new DataSpecificationException(Language.$L("非项目成员禁止操作")); + throw new DataSpecificationException(Language.L("非项目成员禁止操作")); } } diff --git a/src/main/java/com/rebuild/core/service/project/ProjectCommentService.java b/src/main/java/com/rebuild/core/service/project/ProjectCommentService.java index 5751c2bdc..e725c492a 100644 --- a/src/main/java/com/rebuild/core/service/project/ProjectCommentService.java +++ b/src/main/java/com/rebuild/core/service/project/ProjectCommentService.java @@ -21,8 +21,6 @@ import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2020/7/27 @@ -73,7 +71,7 @@ public class ProjectCommentService extends BaseTaskService { private int checkAtUserAndNotification(Record record, String content) { if (StringUtils.isBlank(content)) return 0; - final String msg = $L("@%s 在任务中提到了你", record.getEditor()) + " \n> " + content; + final String msg = Language.L("@%s 在任务中提到了你", record.getEditor()) + " \n> " + content; ID[] atUsers = FeedsHelper.findMentions(content); int send = 0; diff --git a/src/main/java/com/rebuild/core/service/project/ProjectConfigService.java b/src/main/java/com/rebuild/core/service/project/ProjectConfigService.java index f43448be8..869328163 100644 --- a/src/main/java/com/rebuild/core/service/project/ProjectConfigService.java +++ b/src/main/java/com/rebuild/core/service/project/ProjectConfigService.java @@ -20,8 +20,6 @@ import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 项目管理 * @@ -60,7 +58,7 @@ public class ProjectConfigService extends BaseConfigurationService implements Ad .setParameter(1, projectId) .unique(); if ((Long) count[0] > 0) { - throw new DataSpecificationException($L("项目下有 %d 个任务,不能删除", count[0])); + throw new DataSpecificationException(Language.L("项目下有 %d 个任务,不能删除", count[0])); } return super.delete(projectId); } @@ -79,9 +77,9 @@ public class ProjectConfigService extends BaseConfigurationService implements Ad // 使用模板 if (useTemplate == TEMPLATE_DEFAULT) { - ID id1 = createPlan(project.getPrimary(), $L("待处理"), 1000, ProjectPlanConfigService.FLOW_STATUS_START, null); - ID id2 = createPlan(project.getPrimary(), $L("进行中"), 2000, ProjectPlanConfigService.FLOW_STATUS_PROCESSING, null); - ID id3 = createPlan(project.getPrimary(), $L("已完成"), 3000, ProjectPlanConfigService.FLOW_STATUS_END, new ID[]{id1, id2}); + ID id1 = createPlan(project.getPrimary(), Language.L("待处理"), 1000, ProjectPlanConfigService.FLOW_STATUS_START, null); + ID id2 = createPlan(project.getPrimary(), Language.L("进行中"), 2000, ProjectPlanConfigService.FLOW_STATUS_PROCESSING, null); + ID id3 = createPlan(project.getPrimary(), Language.L("已完成"), 3000, ProjectPlanConfigService.FLOW_STATUS_END, new ID[]{id1, id2}); updateFlowNexts(id1, new ID[]{id2, id3}); updateFlowNexts(id2, new ID[]{id1, id3}); } diff --git a/src/main/java/com/rebuild/core/service/project/ProjectManager.java b/src/main/java/com/rebuild/core/service/project/ProjectManager.java index 3117ebebe..f667889f3 100644 --- a/src/main/java/com/rebuild/core/service/project/ProjectManager.java +++ b/src/main/java/com/rebuild/core/service/project/ProjectManager.java @@ -24,8 +24,6 @@ import org.springframework.util.Assert; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 项目管理 * @@ -147,7 +145,7 @@ public class ProjectManager implements ConfigManager { return e.clone(); } } - throw new ConfigurationException($L("无权访问该项目或项目已删除")); + throw new ConfigurationException(Language.L("无权访问该项目或项目已删除")); } /** @@ -174,13 +172,13 @@ public class ProjectManager implements ConfigManager { } if (projectId == null) { - throw new ConfigurationException($L("任务不存在或已被删除")); + throw new ConfigurationException(Language.L("任务不存在或已被删除")); } try { return getProject(projectId, user); } catch (ConfigurationException ex) { - throw new AccessDeniedException($L("无权访问该任务"), ex); + throw new AccessDeniedException(Language.L("无权访问该任务"), ex); } } @@ -239,7 +237,7 @@ public class ProjectManager implements ConfigManager { for (ConfigBean e : getPlansOfProject(projectId)) { if (e.getID("id").equals(planId)) return e; } - throw new ConfigurationException($L("无效任务面板 (%s)", planId)); + throw new ConfigurationException(Language.L("无效任务面板 (%s)", planId)); } @Override diff --git a/src/main/java/com/rebuild/core/service/project/ProjectPlanConfigService.java b/src/main/java/com/rebuild/core/service/project/ProjectPlanConfigService.java index bf1613169..f5cd9c4d2 100644 --- a/src/main/java/com/rebuild/core/service/project/ProjectPlanConfigService.java +++ b/src/main/java/com/rebuild/core/service/project/ProjectPlanConfigService.java @@ -14,10 +14,9 @@ import com.rebuild.core.configuration.BaseConfigurationService; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.privileges.AdminGuard; import com.rebuild.core.service.DataSpecificationException; +import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 项目/任务面板 * @@ -56,7 +55,7 @@ public class ProjectPlanConfigService extends BaseConfigurationService implement .setParameter(1, planId) .unique(); if ((Long) count[0] > 0) { - throw new DataSpecificationException($L("任务面板下有 %d 个任务,不能删除", count[0])); + throw new DataSpecificationException(Language.L("任务面板下有 %d 个任务,不能删除", count[0])); } return super.delete(planId); } diff --git a/src/main/java/com/rebuild/core/service/project/ProjectTaskService.java b/src/main/java/com/rebuild/core/service/project/ProjectTaskService.java index bad085b65..2505287ee 100644 --- a/src/main/java/com/rebuild/core/service/project/ProjectTaskService.java +++ b/src/main/java/com/rebuild/core/service/project/ProjectTaskService.java @@ -18,10 +18,9 @@ import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.privileges.OperationDeniedException; import com.rebuild.core.service.notification.Message; import com.rebuild.core.service.notification.MessageBuilder; +import com.rebuild.core.support.i18n.Language; import org.springframework.stereotype.Service; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @see ProjectConfigService @@ -184,7 +183,7 @@ public class ProjectTaskService extends BaseTaskService { */ private void sendNotification(ID taskId) { Object[] task = Application.getQueryFactory().uniqueNoFilter(taskId, "executor", "taskName"); - String msg = $L("有一个新任务分派给你") + " \n> " + task[1]; + String msg = Language.L("有一个新任务分派给你") + " \n> " + task[1]; Application.getNotifications().send( MessageBuilder.createMessage((ID) task[0], msg, Message.TYPE_PROJECT, taskId)); } diff --git a/src/main/java/com/rebuild/core/service/query/AdvFilterParser.java b/src/main/java/com/rebuild/core/service/query/AdvFilterParser.java index 437d50a2e..9dfb35285 100644 --- a/src/main/java/com/rebuild/core/service/query/AdvFilterParser.java +++ b/src/main/java/com/rebuild/core/service/query/AdvFilterParser.java @@ -24,6 +24,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.privileges.bizz.Department; import com.rebuild.core.support.SetUser; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringEscapeUtils; @@ -36,7 +37,6 @@ import java.util.*; import static cn.devezhao.commons.CalendarUtils.addDay; import static cn.devezhao.commons.CalendarUtils.addMonth; import static cn.devezhao.commons.DateFormatUtils.getUTCDateFormat; -import static com.rebuild.core.support.i18n.Language.$L; /** * 高级查询解析器 @@ -127,7 +127,7 @@ public class AdvFilterParser extends SetUser { String equationHold = equation; if ((equation = validEquation(equation)) == null) { - throw new FilterParseException($L("无效的高级表达式 : %s", equationHold)); + throw new FilterParseException(Language.L("无效的高级表达式 : %s", equationHold)); } if ("OR".equalsIgnoreCase(equation)) { diff --git a/src/main/java/com/rebuild/core/service/trigger/RobotTriggerObserver.java b/src/main/java/com/rebuild/core/service/trigger/RobotTriggerObserver.java index f548add49..27d89b37e 100644 --- a/src/main/java/com/rebuild/core/service/trigger/RobotTriggerObserver.java +++ b/src/main/java/com/rebuild/core/service/trigger/RobotTriggerObserver.java @@ -13,13 +13,12 @@ import com.rebuild.core.RebuildException; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.service.general.OperatingContext; import com.rebuild.core.service.general.OperatingObserver; +import com.rebuild.core.support.i18n.Language; import lombok.extern.slf4j.Slf4j; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 触发器 * @@ -126,7 +125,7 @@ public class RobotTriggerObserver extends OperatingObserver { // FIXME 触发器执行失败是否抛出 if (ex instanceof MissingMetaExcetion) { - throw new TriggerException($L("触发器执行失败 : %s", ex.getLocalizedMessage())); + throw new TriggerException(Language.L("触发器执行失败 : %s", ex.getLocalizedMessage())); } else if (ex instanceof TriggerException) { throw (TriggerException) ex; } else { diff --git a/src/main/java/com/rebuild/core/support/CheckDangers.java b/src/main/java/com/rebuild/core/support/CheckDangers.java index 99b57e09a..54523f1dd 100644 --- a/src/main/java/com/rebuild/core/support/CheckDangers.java +++ b/src/main/java/com/rebuild/core/support/CheckDangers.java @@ -11,12 +11,11 @@ import com.alibaba.fastjson.JSONObject; import com.rebuild.core.Application; import com.rebuild.core.ServerStatus; import com.rebuild.core.cache.CommonsCache; +import com.rebuild.core.support.i18n.Language; import java.util.Collection; import java.util.LinkedHashMap; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2020/12/7 @@ -79,7 +78,7 @@ public class CheckDangers { if (License.isCommercial() && !License.isRbvAttached()) { if (dangers == null) dangers = new LinkedHashMap<>(); - dangers.put(CommercialNoRbv, $L("系统检测到增值功能包未安装,相关增值功能可能无法使用。请联系 REBUILD 服务人员获取")); + dangers.put(CommercialNoRbv, Language.L("系统检测到增值功能包未安装,相关增值功能可能无法使用。请联系 REBUILD 服务人员获取")); } if (dangers == null || dangers.isEmpty()) { @@ -92,7 +91,7 @@ public class CheckDangers { String hasUpdate = dangers.get(HasUpdate); if (hasUpdate != null && hasUpdate.contains("$$$$")) { String[] ss = hasUpdate.split("\\$\\$\\$\\$"); - hasUpdate = $L("有新版的 REBUILD (%s) 更新可用 [(查看详情)](%s)", ss[0], ss[1]); + hasUpdate = Language.L("有新版的 REBUILD (%s) 更新可用 [(查看详情)](%s)", ss[0], ss[1]); hasUpdate = hasUpdate.replace(" availableLocales() { Map map = new LinkedHashMap<>(); for (Map.Entry item : bundleMap.entrySet()) { - map.put(item.getKey(), item.getValue().$L("_")); + map.put(item.getKey(), item.getValue().L("_")); } return map; } @@ -191,26 +191,26 @@ public class Language implements Initialization { return Application.getLanguage().getBundle(UserContextHolder.getLocale()); } - public static String $L(String key, Object... placeholders) { - return getCurrentBundle().$L(key, placeholders); + public static String L(String key, Object... placeholders) { + return getCurrentBundle().L(key, placeholders); } - public static String $L(StateSpec state) { + public static String L(StateSpec state) { String lang = getCurrentBundle().getLang(state.getName()); return lang == null ? state.getName() : lang; } - public static String $L(DisplayType type) { + public static String L(DisplayType type) { String lang = getCurrentBundle().getLang(type.getDisplayName()); return lang == null ? type.getDisplayName() : lang; } - public static String $L(ActionType type) { + public static String L(ActionType type) { String lang = getCurrentBundle().getLang(type.getDisplayName()); return lang == null ? type.getDisplayName() : lang; } - public static String $L(BaseMeta meta) { + public static String L(BaseMeta meta) { String lang = getCurrentBundle().getLang(meta.getDescription()); return lang == null ? meta.getDescription() : lang; } diff --git a/src/main/java/com/rebuild/core/support/i18n/LanguageBundle.java b/src/main/java/com/rebuild/core/support/i18n/LanguageBundle.java index 2537ff7cb..24c699186 100644 --- a/src/main/java/com/rebuild/core/support/i18n/LanguageBundle.java +++ b/src/main/java/com/rebuild/core/support/i18n/LanguageBundle.java @@ -157,7 +157,7 @@ public class LanguageBundle implements JSONable { * @param placeholders * @return */ - public String $L(String key, Object... placeholders) { + public String L(String key, Object... placeholders) { String lang = getLang(key); if (lang == null) { log.warn("Missing lang `{}` for `{}`", key, getLocale()); @@ -194,7 +194,7 @@ public class LanguageBundle implements JSONable { return SYS_LC; } @Override - public String $L(String key, Object... placeholders) { + public String L(String key, Object... placeholders) { String lang = getLang(key); if (lang == null) lang = formatLang(key); return placeholders.length > 0 ? String.format(lang, placeholders) : lang; diff --git a/src/main/java/com/rebuild/core/support/integration/SMSender.java b/src/main/java/com/rebuild/core/support/integration/SMSender.java index 27f75eab6..6cb20f35d 100644 --- a/src/main/java/com/rebuild/core/support/integration/SMSender.java +++ b/src/main/java/com/rebuild/core/support/integration/SMSender.java @@ -20,6 +20,7 @@ import com.rebuild.core.privileges.UserService; import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.License; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.CommonsUtils; import com.rebuild.utils.HttpUtils; import lombok.extern.slf4j.Slf4j; @@ -34,8 +35,6 @@ import org.springframework.util.Assert; import java.util.HashMap; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * SUBMAIL SMS/MAIL 发送 * @@ -87,7 +86,7 @@ public class SMSender { if (specAccount == null || specAccount.length < 4 || StringUtils.isBlank(specAccount[0]) || StringUtils.isBlank(specAccount[1]) || StringUtils.isBlank(specAccount[2]) || StringUtils.isBlank(specAccount[3])) { - throw new ConfigurationException($L("邮件账户未配置或配置错误")); + throw new ConfigurationException(Language.L("邮件账户未配置或配置错误")); } // 使用邮件模板 @@ -241,7 +240,7 @@ public class SMSender { if (specAccount == null || specAccount.length < 3 || StringUtils.isBlank(specAccount[0]) || StringUtils.isBlank(specAccount[1]) || StringUtils.isBlank(specAccount[2])) { - throw new ConfigurationException($L("短信账户未配置或配置错误")); + throw new ConfigurationException(Language.L("短信账户未配置或配置错误")); } Map params = new HashMap<>(); diff --git a/src/main/java/com/rebuild/core/support/state/StateManager.java b/src/main/java/com/rebuild/core/support/state/StateManager.java index 8813dc556..633360774 100644 --- a/src/main/java/com/rebuild/core/support/state/StateManager.java +++ b/src/main/java/com/rebuild/core/support/state/StateManager.java @@ -69,7 +69,7 @@ public class StateManager { StateSpec ss = (StateSpec) c; JSONObject item = JSONUtils.toJSONObject( new String[]{"id", "text", "default"}, - new Object[]{ss.getState(), Language.$L(ss), ss.isDefault()}); + new Object[]{ss.getState(), Language.L(ss), ss.isDefault()}); options.add(item); } diff --git a/src/main/java/com/rebuild/utils/AppUtils.java b/src/main/java/com/rebuild/utils/AppUtils.java index 4036a00a1..b011fddb3 100644 --- a/src/main/java/com/rebuild/utils/AppUtils.java +++ b/src/main/java/com/rebuild/utils/AppUtils.java @@ -16,6 +16,7 @@ import com.rebuild.core.Application; import com.rebuild.core.BootApplication; import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.i18n.LanguageBundle; import com.rebuild.web.admin.AdminVerfiyController; import org.apache.commons.lang.StringUtils; @@ -26,8 +27,6 @@ import javax.servlet.http.HttpServletRequest; import java.nio.file.AccessDeniedException; import java.sql.DataTruncation; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 封裝一些有用的工具方法 * @@ -137,9 +136,9 @@ public class AppUtils { Integer code = (Integer) request.getAttribute(ServletUtils.ERROR_STATUS_CODE); if (code != null && code == 404) { - return $L("访问的页面/资源不存在"); + return Language.L("访问的页面/资源不存在"); } else if (code != null && code == 403) { - return $L("权限不足,访问被阻止"); + return Language.L("权限不足,访问被阻止"); } exception = (Throwable) request.getAttribute(ServletUtils.ERROR_EXCEPTION); @@ -149,18 +148,18 @@ public class AppUtils { if (exception != null) { Throwable known = ThrowableUtils.getRootCause(exception); if (known instanceof DataTruncation) { - return $L("字段长度超出限制"); + return Language.L("字段长度超出限制"); } else if (known instanceof AccessDeniedException) { - return $L("权限不足,访问被阻止"); + return Language.L("权限不足,访问被阻止"); } } if (exception == null) { - return $L("系统繁忙,请稍后重试"); + return Language.L("系统繁忙,请稍后重试"); } else { exception = ThrowableUtils.getRootCause(exception); String errorMsg = exception.getLocalizedMessage(); - if (StringUtils.isBlank(errorMsg)) errorMsg = $L("系统繁忙,请稍后重试"); + if (StringUtils.isBlank(errorMsg)) errorMsg = Language.L("系统繁忙,请稍后重试"); return errorMsg; } } diff --git a/src/main/java/com/rebuild/web/BaseController.java b/src/main/java/com/rebuild/web/BaseController.java index d3c296954..b8dd5dda7 100644 --- a/src/main/java/com/rebuild/web/BaseController.java +++ b/src/main/java/com/rebuild/web/BaseController.java @@ -11,6 +11,7 @@ import cn.devezhao.commons.web.ServletUtils; import cn.devezhao.persist4j.engine.ID; import com.alibaba.fastjson.JSON; import com.rebuild.api.Controller; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.AppUtils; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; @@ -20,8 +21,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * Root Controller * @@ -38,7 +37,7 @@ public abstract class BaseController extends Controller { protected ID getRequestUser(HttpServletRequest request) { ID user = AppUtils.getRequestUser(request); if (user == null) { - throw new InvalidParameterException($L("无效请求用户")); + throw new InvalidParameterException(Language.L("无效请求用户")); } return user; } @@ -119,7 +118,7 @@ public abstract class BaseController extends Controller { protected String getParameterNotNull(HttpServletRequest request, String name) { String v = request.getParameter(name); if (StringUtils.isEmpty(v)) { - throw new InvalidParameterException($L("无效请求参数 (%s=%s)", name, v)); + throw new InvalidParameterException(Language.L("无效请求参数 (%s=%s)", name, v)); } return v; } @@ -190,7 +189,7 @@ public abstract class BaseController extends Controller { protected ID getIdParameterNotNull(HttpServletRequest request, String name) { String v = request.getParameter(name); if (ID.isId(v)) return ID.valueOf(v); - throw new InvalidParameterException($L("无效请求参数 (%s=%s)", name, v)); + throw new InvalidParameterException(Language.L("无效请求参数 (%s=%s)", name, v)); } /** diff --git a/src/main/java/com/rebuild/web/EntityParamMethodArgumentResolver.java b/src/main/java/com/rebuild/web/EntityParamMethodArgumentResolver.java index de3c6f5a0..83b534379 100644 --- a/src/main/java/com/rebuild/web/EntityParamMethodArgumentResolver.java +++ b/src/main/java/com/rebuild/web/EntityParamMethodArgumentResolver.java @@ -8,6 +8,7 @@ See LICENSE and COMMERCIAL in the project root for license information. package com.rebuild.web; import com.rebuild.core.metadata.MetadataHelper; +import com.rebuild.core.support.i18n.Language; import org.apache.commons.lang.StringUtils; import org.springframework.core.MethodParameter; import org.springframework.util.Assert; @@ -16,8 +17,6 @@ import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import static com.rebuild.core.support.i18n.Language.$L; - /** * {@link cn.devezhao.persist4j.Entity} 参数解析器 * @@ -40,7 +39,7 @@ public class EntityParamMethodArgumentResolver implements HandlerMethodArgumentR String value = webRequest.getParameter(param.name()); if (StringUtils.isBlank(value)) { if (param.required()) { - throw new InvalidParameterException($L("无效请求参数 (%s=%s)", param.name(), value)); + throw new InvalidParameterException(Language.L("无效请求参数 (%s=%s)", param.name(), value)); } return null; } @@ -48,6 +47,6 @@ public class EntityParamMethodArgumentResolver implements HandlerMethodArgumentR if (MetadataHelper.containsEntity(value)) { return MetadataHelper.getEntity(value); } - throw new InvalidParameterException($L("无效请求参数")); + throw new InvalidParameterException(Language.L("无效请求参数")); } } diff --git a/src/main/java/com/rebuild/web/IdParamMethodArgumentResolver.java b/src/main/java/com/rebuild/web/IdParamMethodArgumentResolver.java index fa6a391dd..6c45d86fb 100644 --- a/src/main/java/com/rebuild/web/IdParamMethodArgumentResolver.java +++ b/src/main/java/com/rebuild/web/IdParamMethodArgumentResolver.java @@ -39,7 +39,7 @@ public class IdParamMethodArgumentResolver implements HandlerMethodArgumentResol ID idValue = ID.isId(value) ? ID.valueOf(value) : null; if (param.required() && idValue == null) { - throw new InvalidParameterException(Language.$L("无效请求参数 (%s=%s)", param.name(), value)); + throw new InvalidParameterException(Language.L("无效请求参数 (%s=%s)", param.name(), value)); } return idValue; } diff --git a/src/main/java/com/rebuild/web/RebuildWebConfigurer.java b/src/main/java/com/rebuild/web/RebuildWebConfigurer.java index c6e315510..f0ced978f 100644 --- a/src/main/java/com/rebuild/web/RebuildWebConfigurer.java +++ b/src/main/java/com/rebuild/web/RebuildWebConfigurer.java @@ -149,7 +149,7 @@ public class RebuildWebConfigurer implements WebMvcConfigurer, ErrorViewResolver if (ex != null && ThrowableUtils.getRootCause(ex) instanceof TemplateInputException && errorMsg.contains("Error resolving template")) { - errorMsg = Language.$L("访问的页面/资源不存在"); + errorMsg = Language.L("访问的页面/资源不存在"); } } diff --git a/src/main/java/com/rebuild/web/admin/AdminVerfiyController.java b/src/main/java/com/rebuild/web/admin/AdminVerfiyController.java index 17037ef7d..96e44c70e 100644 --- a/src/main/java/com/rebuild/web/admin/AdminVerfiyController.java +++ b/src/main/java/com/rebuild/web/admin/AdminVerfiyController.java @@ -16,6 +16,7 @@ import com.rebuild.api.RespBody; import com.rebuild.core.Application; import com.rebuild.core.privileges.bizz.User; import com.rebuild.core.support.CheckDangers; +import com.rebuild.core.support.i18n.Language; import com.rebuild.web.BaseController; import org.apache.commons.lang.StringUtils; import org.springframework.web.bind.annotation.GetMapping; @@ -28,8 +29,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 10/13/2018 @@ -49,7 +48,7 @@ public class AdminVerfiyController extends BaseController { if (admin.isAdmin()) { return createModelAndView("/admin/admin-verify"); } else { - response.sendError(403, $L("非管理员用户")); + response.sendError(403, Language.L("非管理员用户")); return null; } } diff --git a/src/main/java/com/rebuild/web/admin/ConfigurationController.java b/src/main/java/com/rebuild/web/admin/ConfigurationController.java index 2a2e229f3..578b5e998 100644 --- a/src/main/java/com/rebuild/web/admin/ConfigurationController.java +++ b/src/main/java/com/rebuild/web/admin/ConfigurationController.java @@ -22,6 +22,7 @@ import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.DataMasking; import com.rebuild.core.support.License; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.QiniuCloud; import com.rebuild.core.support.integration.SMSender; import com.rebuild.utils.CommonsUtils; @@ -41,8 +42,6 @@ import java.util.Comparator; import java.util.Date; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 系统配置 * @@ -146,7 +145,7 @@ public class ConfigurationController extends BaseController { return RespBody.ok(); } catch (QiniuException ex) { - return RespBody.error($L("无效配置参数 : %s", ex.response.error)); + return RespBody.error(Language.L("无效配置参数 : %s", ex.response.error)); } catch (Exception ex) { return RespBody.error(ThrowableUtils.getRootCause(ex).getLocalizedMessage()); } @@ -192,7 +191,7 @@ public class ConfigurationController extends BaseController { specAccount[1] = RebuildConfiguration.get(ConfigurationItem.SmsPassword); } - String content = $L("收到此消息说明你的短信服务配置正确"); + String content = Language.L("收到此消息说明你的短信服务配置正确"); sent = SMSender.sendSMS(receiver, content, specAccount); } else if ("EMAIL".equalsIgnoreCase(type)) { @@ -209,7 +208,7 @@ public class ConfigurationController extends BaseController { specAccount[1] = RebuildConfiguration.get(ConfigurationItem.MailPassword); } - String content = $L("收到此消息说明你的邮件服务配置正确"); + String content = Language.L("收到此消息说明你的邮件服务配置正确"); sent = SMSender.sendMail(receiver, content, content, true, specAccount); } diff --git a/src/main/java/com/rebuild/web/admin/bizz/UserController.java b/src/main/java/com/rebuild/web/admin/bizz/UserController.java index 39bb2f61d..5cebfdead 100644 --- a/src/main/java/com/rebuild/web/admin/bizz/UserController.java +++ b/src/main/java/com/rebuild/web/admin/bizz/UserController.java @@ -22,6 +22,7 @@ import com.rebuild.core.privileges.UserService; import com.rebuild.core.privileges.bizz.Department; import com.rebuild.core.privileges.bizz.User; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.SMSender; import com.rebuild.utils.JSONUtils; import com.rebuild.web.EntityController; @@ -40,8 +41,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 10/08/2018 @@ -157,8 +156,8 @@ public class UserController extends EntityController { if (did == null) { String homeUrl = RebuildConfiguration.getHomeUrl(); - String subject = $L("你的账户已激活"); - String content = $L("%s 你的账户已激活!现在你可以登陆并使用系统。 [][] 登录地址 : [%s](%s) [][] 首次登陆,建议你立即修改密码!如有任何登陆或使用问题,请与系统管理员联系。", + String subject = Language.L("你的账户已激活"); + String content = Language.L("%s 你的账户已激活!现在你可以登陆并使用系统。 [][] 登录地址 : [%s](%s) [][] 首次登陆,建议你立即修改密码!如有任何登陆或使用问题,请与系统管理员联系。", enUser.getFullName(), homeUrl, homeUrl); SMSender.sendMailAsync(enUser.getEmail(), subject, content); diff --git a/src/main/java/com/rebuild/web/admin/data/DataImportController.java b/src/main/java/com/rebuild/web/admin/data/DataImportController.java index d4f97879c..d86eb812d 100644 --- a/src/main/java/com/rebuild/web/admin/data/DataImportController.java +++ b/src/main/java/com/rebuild/web/admin/data/DataImportController.java @@ -26,6 +26,7 @@ import com.rebuild.core.service.dataimport.DataFileParser; import com.rebuild.core.service.dataimport.DataImporter; import com.rebuild.core.service.dataimport.ImportRule; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.task.TaskExecutors; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; @@ -43,8 +44,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 01/03/2019 @@ -65,7 +64,7 @@ public class DataImportController extends BaseController { String file = getParameterNotNull(request, "file"); File tmp = getFileOfImport(file); if (tmp == null) { - writeFailure(response, $L("数据文件无效")); + writeFailure(response, Language.L("数据文件无效")); return; } @@ -77,7 +76,7 @@ public class DataImportController extends BaseController { preview = parser.parse(11); } catch (Exception ex) { log.error("Parse excel error : " + file, ex); - writeFailure(response, $L("无法解析数据,请检查数据文件格式")); + writeFailure(response, Language.L("无法解析数据,请检查数据文件格式")); return; } @@ -136,13 +135,13 @@ public class DataImportController extends BaseController { String defaultValue = null; if (EntityHelper.CreatedOn.equals(fieldName) || EntityHelper.ModifiedOn.equals(fieldName)) { - defaultValue = $L("当前时间"); + defaultValue = Language.L("当前时间"); } else if (EntityHelper.CreatedBy.equals(fieldName) || EntityHelper.ModifiedBy.equals(fieldName) || EntityHelper.OwningUser.equals(fieldName)) { - defaultValue = $L("当前用户"); + defaultValue = Language.L("当前用户"); } else if (easyMeta.getDisplayType() == DisplayType.SERIES) { - defaultValue = $L("自动编号"); + defaultValue = Language.L("自动编号"); } if (defaultValue != null) { diff --git a/src/main/java/com/rebuild/web/admin/data/ReportTemplateController.java b/src/main/java/com/rebuild/web/admin/data/ReportTemplateController.java index 89e295e04..2e394ddb4 100644 --- a/src/main/java/com/rebuild/web/admin/data/ReportTemplateController.java +++ b/src/main/java/com/rebuild/web/admin/data/ReportTemplateController.java @@ -19,6 +19,7 @@ import com.rebuild.core.service.datareport.EasyExcelGenerator; import com.rebuild.core.service.datareport.TemplateExtractor; import com.rebuild.core.support.RebuildConfiguration; import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.commons.FileDownloader; @@ -37,8 +38,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * Excel 报表 * @@ -77,7 +76,7 @@ public class ReportTemplateController extends BaseController { Map vars = new TemplateExtractor(template, true).transformVars(entityMeta); if (vars.isEmpty()) { - writeFailure(response, $L("无效模板文件 (未找到有效字段)")); + writeFailure(response, Language.L("无效模板文件 (未找到有效字段)")); return; } @@ -89,7 +88,7 @@ public class ReportTemplateController extends BaseController { } if (invalidVars.size() >= vars.size()) { - writeFailure(response, $L("无效模板文件 (未找到有效字段)")); + writeFailure(response, Language.L("无效模板文件 (未找到有效字段)")); return; } @@ -110,7 +109,7 @@ public class ReportTemplateController extends BaseController { entity.getPrimaryField().getName(), entity.getName()); Object[] random = Application.createQueryNoFilter(sql).unique(); if (random == null) { - response.sendError(400, $L("未找到可供预览的记录")); + response.sendError(400, Language.L("未找到可供预览的记录")); return; } @@ -119,7 +118,7 @@ public class ReportTemplateController extends BaseController { File template = DataReportManager.instance.getTemplateFile(entity, reportId); file = new EasyExcelGenerator(template, (ID) random[0]).generate(); } catch (ConfigurationException ex) { - response.sendError(400, $L("未找到可供预览的记录")); + response.sendError(400, Language.L("未找到可供预览的记录")); return; } diff --git a/src/main/java/com/rebuild/web/admin/metadata/ClassificationController.java b/src/main/java/com/rebuild/web/admin/metadata/ClassificationController.java index ead331915..ff3d92119 100644 --- a/src/main/java/com/rebuild/web/admin/metadata/ClassificationController.java +++ b/src/main/java/com/rebuild/web/admin/metadata/ClassificationController.java @@ -14,6 +14,7 @@ import com.rebuild.api.RespBody; import com.rebuild.core.Application; import com.rebuild.core.configuration.general.ClassificationService; import com.rebuild.core.metadata.EntityHelper; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.IdParam; @@ -29,8 +30,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 分类数据管理 * @@ -54,7 +53,7 @@ public class ClassificationController extends BaseController { .setParameter(1, id) .unique(); if (data == null) { - resp.sendError(404, $L("分类数据不存在")); + resp.sendError(404, Language.L("分类数据不存在")); return null; } diff --git a/src/main/java/com/rebuild/web/admin/metadata/MetaEntityController.java b/src/main/java/com/rebuild/web/admin/metadata/MetaEntityController.java index b15f67d06..bc74202b3 100644 --- a/src/main/java/com/rebuild/web/admin/metadata/MetaEntityController.java +++ b/src/main/java/com/rebuild/web/admin/metadata/MetaEntityController.java @@ -25,6 +25,7 @@ import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.rbstore.MetaSchemaGenerator; import com.rebuild.core.service.general.QuickCodeReindexTask; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.task.TaskExecutors; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; @@ -45,8 +46,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author zhaofang123@gmail.com * @since 08/03/2018 @@ -136,16 +135,16 @@ public class MetaEntityController extends BaseController { String mainEntity = reqJson.getString("mainEntity"); if (StringUtils.isNotBlank(mainEntity)) { if (!MetadataHelper.containsEntity(mainEntity)) { - writeFailure(response, $L("无效主实体 : %s", mainEntity)); + writeFailure(response, Language.L("无效主实体 : %s", mainEntity)); return; } Entity useMain = MetadataHelper.getEntity(mainEntity); if (useMain.getMainEntity() != null) { - writeFailure(response, $L("明细实体不能作为主实体")); + writeFailure(response, Language.L("明细实体不能作为主实体")); return; } else if (useMain.getDetailEntity() != null) { - writeFailure(response, $L("选择的主实体已被 [%s] 使用", useMain.getDetailEntity())); + writeFailure(response, Language.L("选择的主实体已被 [%s] 使用", useMain.getDetailEntity())); return; } } diff --git a/src/main/java/com/rebuild/web/admin/metadata/MetaFieldController.java b/src/main/java/com/rebuild/web/admin/metadata/MetaFieldController.java index a0d9bf9f4..f616327f7 100644 --- a/src/main/java/com/rebuild/web/admin/metadata/MetaFieldController.java +++ b/src/main/java/com/rebuild/web/admin/metadata/MetaFieldController.java @@ -76,7 +76,7 @@ public class MetaFieldController extends BaseController { map.put("fieldName", easyMeta.getName()); map.put("fieldLabel", easyMeta.getLabel()); map.put("comments", easyMeta.getComments()); - map.put("displayType", Language.$L(easyMeta.getDisplayType())); + map.put("displayType", Language.L(easyMeta.getDisplayType())); map.put("nullable", field.isNullable()); map.put("builtin", easyMeta.isBuiltin()); map.put("creatable", field.isCreatable()); diff --git a/src/main/java/com/rebuild/web/admin/metadata/ViewAddonsController.java b/src/main/java/com/rebuild/web/admin/metadata/ViewAddonsController.java index ea25b2675..3c89403a1 100644 --- a/src/main/java/com/rebuild/web/admin/metadata/ViewAddonsController.java +++ b/src/main/java/com/rebuild/web/admin/metadata/ViewAddonsController.java @@ -22,6 +22,7 @@ import com.rebuild.core.configuration.general.ViewAddonsManager; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.metadata.easymeta.EasyMetaFactory; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import org.springframework.web.bind.annotation.*; @@ -30,8 +31,6 @@ import javax.servlet.http.HttpServletRequest; import java.util.HashSet; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 视图-相关项显示 * @@ -95,9 +94,9 @@ public class ViewAddonsController extends BaseController { } // 跟进(动态) - refs.add(new String[] { "Feeds.relatedRecord", $L("动态") }); + refs.add(new String[] { "Feeds.relatedRecord", Language.L("动态") }); // 任务(项目) - refs.add(new String[] { "ProjectTask.relatedRecord", $L("任务") }); + refs.add(new String[] { "ProjectTask.relatedRecord", Language.L("任务") }); return JSONUtils.toJSONObject( new String[] { "config", "refs" }, diff --git a/src/main/java/com/rebuild/web/admin/setup/InstallController.java b/src/main/java/com/rebuild/web/admin/setup/InstallController.java index 9c231c6d1..4f2cbe851 100644 --- a/src/main/java/com/rebuild/web/admin/setup/InstallController.java +++ b/src/main/java/com/rebuild/web/admin/setup/InstallController.java @@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONObject; import com.rebuild.api.RespBody; import com.rebuild.core.Application; import com.rebuild.core.rbstore.RBStore; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.setup.InstallState; import com.rebuild.core.support.setup.Installer; import com.rebuild.utils.AppUtils; @@ -40,8 +41,6 @@ import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2019/11/25 @@ -75,7 +74,7 @@ public class InstallController extends BaseController implements InstallState { Installer checker = new Installer(props); try (Connection conn = checker.getConnection(null)) { DatabaseMetaData dmd = conn.getMetaData(); - String okMsg = $L("连接成功 : %s", + String okMsg = Language.L("连接成功 : %s", dmd.getDatabaseProductName() + " " + dmd.getDatabaseProductVersion()); // 查询表 @@ -85,7 +84,7 @@ public class InstallController extends BaseController implements InstallState { if (hasTable != null) { // 挂载模式 if (checker.isRbDatabase()) { - okMsg += $L("已发现 **%s** 为 REBUILD 数据库,系统将自动挂载", dbProps.getString("dbName")); + okMsg += Language.L("已发现 **%s** 为 REBUILD 数据库,系统将自动挂载", dbProps.getString("dbName")); okMsg = "1#" + okMsg; } else { return RespBody.errorl("非空数据库不可使用,请使用其他数据库"); @@ -99,7 +98,7 @@ public class InstallController extends BaseController implements InstallState { } catch (SQLException ex) { if (ex.getLocalizedMessage().contains("Unknown database")) { - String okMsg = $L("连接成功 : 数据库 **%s** 不存在,系统将自动创建", dbProps.getString("dbName")); + String okMsg = Language.L("连接成功 : 数据库 **%s** 不存在,系统将自动创建", dbProps.getString("dbName")); return RespBody.ok(okMsg); } else { return RespBody.errorl("连接错误 : %s", ex.getLocalizedMessage()); @@ -124,7 +123,7 @@ public class InstallController extends BaseController implements InstallState { } pool.destroy(); - return RespBody.ok($L("连接成功 : %s", info)); + return RespBody.ok(Language.L("连接成功 : %s", info)); } catch (Exception ex) { return RespBody.errorl("连接错误 : %s", ThrowableUtils.getRootCause(ex).getLocalizedMessage()); diff --git a/src/main/java/com/rebuild/web/commons/ErrorPageView.java b/src/main/java/com/rebuild/web/commons/ErrorPageView.java index 110ab3bfe..93fee433e 100644 --- a/src/main/java/com/rebuild/web/commons/ErrorPageView.java +++ b/src/main/java/com/rebuild/web/commons/ErrorPageView.java @@ -11,6 +11,7 @@ import cn.devezhao.commons.web.ServletUtils; import com.alibaba.fastjson.JSONObject; import com.rebuild.core.Application; import com.rebuild.core.ServerStatus; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.AppUtils; import com.rebuild.web.BaseController; import org.springframework.stereotype.Controller; @@ -20,8 +21,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author zhaofang123@gmail.com * @see com.rebuild.web.RebuildWebConfigurer @@ -35,7 +34,7 @@ public class ErrorPageView extends BaseController { ModelAndView mv = createModelAndView("/error/error"); mv.getModelMap().put("error_code", 400); mv.getModelMap().put("error_msg", - $L("不支持 IE10 及以下的浏览器 [] 推荐使用 Edge、Chrome、Firefox 或 IE11")); + Language.L("不支持 IE10 及以下的浏览器 [] 推荐使用 Edge、Chrome、Firefox 或 IE11")); return mv; } diff --git a/src/main/java/com/rebuild/web/commons/FileDownloader.java b/src/main/java/com/rebuild/web/commons/FileDownloader.java index 0aba110a7..08383e1d6 100644 --- a/src/main/java/com/rebuild/web/commons/FileDownloader.java +++ b/src/main/java/com/rebuild/web/commons/FileDownloader.java @@ -16,6 +16,7 @@ import com.rebuild.core.RebuildException; import com.rebuild.core.privileges.UserService; import com.rebuild.core.support.CsrfToken; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.QiniuCloud; import com.rebuild.utils.AppUtils; import com.rebuild.utils.RbAssert; @@ -37,8 +38,6 @@ import java.awt.image.BufferedImage; import java.io.*; import java.nio.charset.StandardCharsets; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 文件下载/查看 * @@ -141,7 +140,7 @@ public class FileDownloader extends BaseController { if (request.getRequestURI().contains("/filex/access/")) { String e = getParameter(request, "e"); if (StringUtils.isBlank(e) || Application.getCommonsCache().get(e) == null) { - response.sendError(HttpStatus.FORBIDDEN.value(), $L("分享的文件已过期")); + response.sendError(HttpStatus.FORBIDDEN.value(), Language.L("分享的文件已过期")); return; } diff --git a/src/main/java/com/rebuild/web/commons/FileShareController.java b/src/main/java/com/rebuild/web/commons/FileShareController.java index d1cfe5d8f..31d91a325 100644 --- a/src/main/java/com/rebuild/web/commons/FileShareController.java +++ b/src/main/java/com/rebuild/web/commons/FileShareController.java @@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON; import com.rebuild.core.Application; import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.QiniuCloud; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; @@ -27,8 +28,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Collections; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 文件共享 * @@ -53,7 +52,7 @@ public class FileShareController extends BaseController { public JSON makeSharedFile(HttpServletRequest request) { Assert.isTrue( RebuildConfiguration.getBool(ConfigurationItem.FileSharable), - $L("不允许分享文件")); + Language.L("不允许分享文件")); String fileUrl = getParameterNotNull(request, "url"); int mtime = getIntParameter(request, "time", 5); @@ -71,7 +70,7 @@ public class FileShareController extends BaseController { String fileUrl; if (!RebuildConfiguration.getBool(ConfigurationItem.FileSharable) || (fileUrl = Application.getCommonsCache().get(shareKey)) == null) { - response.sendError(403, $L("分享的文件已过期")); + response.sendError(403, Language.L("分享的文件已过期")); return null; } diff --git a/src/main/java/com/rebuild/web/commons/FileUploader.java b/src/main/java/com/rebuild/web/commons/FileUploader.java index 13780d78b..cfbf7d275 100644 --- a/src/main/java/com/rebuild/web/commons/FileUploader.java +++ b/src/main/java/com/rebuild/web/commons/FileUploader.java @@ -11,6 +11,7 @@ import cn.devezhao.commons.ObjectUtils; import com.rebuild.api.RespBody; import com.rebuild.core.service.files.FilesHelper; import com.rebuild.core.support.RebuildConfiguration; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.QiniuCloud; import com.rebuild.web.BaseController; import lombok.extern.slf4j.Slf4j; @@ -29,8 +30,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 文件上传 * @@ -75,7 +74,7 @@ public class FileUploader extends BaseController { file.transferTo(dest); if (!dest.exists()) { - writeFailure(response, $L("上传失败,请稍后重试")); + writeFailure(response, Language.L("上传失败,请稍后重试")); return; } @@ -87,7 +86,7 @@ public class FileUploader extends BaseController { if (uploadName != null) { writeSuccess(response, uploadName); } else { - writeFailure(response, $L("上传失败,请稍后重试")); + writeFailure(response, Language.L("上传失败,请稍后重试")); } } diff --git a/src/main/java/com/rebuild/web/commons/MetadataGetting.java b/src/main/java/com/rebuild/web/commons/MetadataGetting.java index bd9f3eb9d..adf4ac913 100644 --- a/src/main/java/com/rebuild/web/commons/MetadataGetting.java +++ b/src/main/java/com/rebuild/web/commons/MetadataGetting.java @@ -88,7 +88,7 @@ public class MetadataGetting extends BaseController { // if ("VF_USER_TEAMS".equalsIgnoreCase(getParameter(request, "extra"))) { // final JSONObject temp = JSONUtils.toJSONObject( // new String[] { "name", "label", "type", "ref" }, -// new Object[] { null, "." + Language.L("JoinedTeams"), "REFERENCE", new String[] { "Team", "TEXT" } }); +// new Object[] { null, "." + Language.L("加入团队"), "REFERENCE", new String[] { "Team", "TEXT" } }); // // List dataNew = new ArrayList<>(); // for (JSONObject item : data) { diff --git a/src/main/java/com/rebuild/web/configuration/NavSettings.java b/src/main/java/com/rebuild/web/configuration/NavSettings.java index 085bb84f2..d8b425737 100644 --- a/src/main/java/com/rebuild/web/configuration/NavSettings.java +++ b/src/main/java/com/rebuild/web/configuration/NavSettings.java @@ -19,6 +19,7 @@ import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.privileges.RoleService; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.privileges.bizz.ZeroEntry; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.RbAssert; import com.rebuild.web.BaseController; import org.apache.commons.lang.StringUtils; @@ -30,8 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 导航菜单设置 * @@ -47,7 +46,7 @@ public class NavSettings extends BaseController implements ShareTo { final ID user = getRequestUser(request); RbAssert.isAllow( Application.getPrivilegesManager().allow(user, ZeroEntry.AllowCustomNav), - $L("无操作权限")); + Language.L("无操作权限")); ID cfgid = getIdParameter(request, "id"); // 普通用户只能有一个 diff --git a/src/main/java/com/rebuild/web/configuration/ShowFieldsController.java b/src/main/java/com/rebuild/web/configuration/ShowFieldsController.java index b2df679ab..2d0f7792d 100644 --- a/src/main/java/com/rebuild/web/configuration/ShowFieldsController.java +++ b/src/main/java/com/rebuild/web/configuration/ShowFieldsController.java @@ -27,6 +27,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.RoleService; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.privileges.bizz.ZeroEntry; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.RbAssert; import com.rebuild.web.BaseController; @@ -44,8 +45,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 列表配置 * @@ -62,7 +61,7 @@ public class ShowFieldsController extends BaseController implements ShareTo { final ID user = getRequestUser(request); RbAssert.isAllow( Application.getPrivilegesManager().allow(user, ZeroEntry.AllowCustomDataList), - $L("无操作权限")); + Language.L("无操作权限")); ID cfgid = getIdParameter(request, "id"); // 普通用户只能有一个 diff --git a/src/main/java/com/rebuild/web/dashboard/ChartDesignController.java b/src/main/java/com/rebuild/web/dashboard/ChartDesignController.java index 7e7b697aa..7b44f0488 100644 --- a/src/main/java/com/rebuild/web/dashboard/ChartDesignController.java +++ b/src/main/java/com/rebuild/web/dashboard/ChartDesignController.java @@ -29,6 +29,7 @@ import com.rebuild.core.service.dashboard.ChartConfigService; import com.rebuild.core.service.dashboard.DashboardConfigService; import com.rebuild.core.service.dashboard.charts.ChartData; import com.rebuild.core.service.dashboard.charts.ChartsFactory; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.RbAssert; import com.rebuild.web.EntityController; @@ -47,8 +48,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 12/09/2018 @@ -64,7 +63,7 @@ public class ChartDesignController extends EntityController { final ID user = getRequestUser(request); RbAssert.isAllow( Application.getPrivilegesManager().allow(user, ZeroEntry.AllowCustomChart), - $L("无操作权限")); + Language.L("无操作权限")); ModelAndView mv = createModelAndView("/dashboard/chart-design"); @@ -74,11 +73,11 @@ public class ChartDesignController extends EntityController { .setParameter(1, chartId) .unique(); if (chart == null) { - response.sendError(404, $L("未知图表")); + response.sendError(404, Language.L("未知图表")); return null; } if (!UserHelper.isAdmin(user) && !user.equals(chart[3])) { - response.sendError(403, $L("无权操作他人图表")); + response.sendError(403, Language.L("无权操作他人图表")); return null; } @@ -93,11 +92,11 @@ public class ChartDesignController extends EntityController { mv.getModel().put("chartOwningAdmin", UserHelper.isAdmin(user)); } else { - throw new InvalidParameterException($L("无效请求参数")); + throw new InvalidParameterException(Language.L("无效请求参数")); } if (!Application.getPrivilegesManager().allowRead(getRequestUser(request), entity.getEntityCode())) { - response.sendError(403, $L("没有读取 %s 的权限", EasyMetaFactory.getLabel(entity))); + response.sendError(403, Language.L("没有读取 %s 的权限", EasyMetaFactory.getLabel(entity))); return null; } diff --git a/src/main/java/com/rebuild/web/dashboard/DashboardController.java b/src/main/java/com/rebuild/web/dashboard/DashboardController.java index 78fabadf2..3d8acebbc 100644 --- a/src/main/java/com/rebuild/web/dashboard/DashboardController.java +++ b/src/main/java/com/rebuild/web/dashboard/DashboardController.java @@ -153,7 +153,7 @@ public class DashboardController extends BaseController { for (BuiltinChart b : ChartsFactory.getBuiltinCharts()) { charts.add(JSONUtils.toJSONObject( new String[] { "id", "title", "type", "entityLabel" }, - new Object[] { b.getChartId(), b.getChartTitle(), b.getChartType(), Language.$L("内置") })); + new Object[] { b.getChartId(), b.getChartTitle(), b.getChartType(), Language.L("内置") })); } } diff --git a/src/main/java/com/rebuild/web/extform/ExtformAdminController.java b/src/main/java/com/rebuild/web/extform/ExtformAdminController.java index 9b919dfe0..4771eba29 100644 --- a/src/main/java/com/rebuild/web/extform/ExtformAdminController.java +++ b/src/main/java/com/rebuild/web/extform/ExtformAdminController.java @@ -7,14 +7,13 @@ See LICENSE and COMMERCIAL in the project root for license information. package com.rebuild.web.extform; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.RbAssert; import com.rebuild.web.BaseController; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao * @since 2020/12/8 @@ -24,7 +23,7 @@ public class ExtformAdminController extends BaseController { @GetMapping("/admin/extforms") public ModelAndView pageList() { - RbAssert.isCommercial($L("免费版不支持外部表单功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)")); + RbAssert.isCommercial(Language.L("免费版不支持外部表单功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)")); return createModelAndView("/admin/extform/extform-list"); } } diff --git a/src/main/java/com/rebuild/web/feeds/FeedsPostController.java b/src/main/java/com/rebuild/web/feeds/FeedsPostController.java index c6defc133..b5e420b54 100644 --- a/src/main/java/com/rebuild/web/feeds/FeedsPostController.java +++ b/src/main/java/com/rebuild/web/feeds/FeedsPostController.java @@ -17,6 +17,7 @@ import com.rebuild.api.RespBody; import com.rebuild.core.Application; import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.service.feeds.FeedsType; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.IdParam; @@ -26,8 +27,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 操作相关 * @@ -84,7 +83,7 @@ public class FeedsPostController extends BaseController { .setParameter(2, FeedsType.SCHEDULE.getMask()) .unique(); if (schedule == null || !schedule[0].equals(user)) { - return RespBody.error($L("无操作权限")); + return RespBody.error(Language.L("无操作权限")); } // 非结构化存储 diff --git a/src/main/java/com/rebuild/web/files/FileListController.java b/src/main/java/com/rebuild/web/files/FileListController.java index 9d0d045bc..85890be37 100644 --- a/src/main/java/com/rebuild/web/files/FileListController.java +++ b/src/main/java/com/rebuild/web/files/FileListController.java @@ -226,7 +226,7 @@ public class FileListController extends BaseController { private JSONObject formatEntityJson(Entity entity) { return JSONUtils.toJSONObject( new String[] { "id", "text" }, - new Object[] { entity.getEntityCode(), Language.$L(entity) }); + new Object[] { entity.getEntityCode(), Language.L(entity) }); } private boolean hasAttachmentFields(Entity entity) { diff --git a/src/main/java/com/rebuild/web/general/BatchUpdateController.java b/src/main/java/com/rebuild/web/general/BatchUpdateController.java index 66cabf393..3b9a34e78 100644 --- a/src/main/java/com/rebuild/web/general/BatchUpdateController.java +++ b/src/main/java/com/rebuild/web/general/BatchUpdateController.java @@ -26,6 +26,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.metadata.impl.EasyFieldConfigProps; import com.rebuild.core.privileges.bizz.ZeroEntry; import com.rebuild.core.service.general.BulkContext; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.state.StateManager; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.RbAssert; @@ -36,8 +37,6 @@ import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 批量修改 * @@ -53,7 +52,7 @@ public class BatchUpdateController extends BaseController { final ID user = getRequestUser(request); RbAssert.isAllow( Application.getPrivilegesManager().allow(user, ZeroEntry.AllowBatchUpdate), - $L("无操作权限")); + Language.L("无操作权限")); JSONObject requestData = (JSONObject) ServletUtils.getRequestJson(request); @@ -118,10 +117,10 @@ public class BatchUpdateController extends BaseController { JSONArray options = new JSONArray(); options.add(JSONUtils.toJSONObject( new String[] { "id", "text" }, - new Object[] { true, $L("是") })); + new Object[] { true, Language.L("是") })); options.add(JSONUtils.toJSONObject( new String[] { "id", "text" }, - new Object[] { false, $L("否") })); + new Object[] { false, Language.L("否") })); map.put("options", options); } else if (dt == DisplayType.NUMBER) { diff --git a/src/main/java/com/rebuild/web/general/GeneralListController.java b/src/main/java/com/rebuild/web/general/GeneralListController.java index d354d0306..b06c5c213 100644 --- a/src/main/java/com/rebuild/web/general/GeneralListController.java +++ b/src/main/java/com/rebuild/web/general/GeneralListController.java @@ -18,6 +18,7 @@ import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.privileges.bizz.ZeroEntry; import com.rebuild.core.support.general.DataListBuilder; import com.rebuild.core.support.general.DataListBuilderImpl; +import com.rebuild.core.support.i18n.Language; import com.rebuild.web.EntityController; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -26,8 +27,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 数据列表 * @@ -96,7 +95,7 @@ public class GeneralListController extends EntityController { } if (!Application.getPrivilegesManager().allowRead(user, checkEntity.getEntityCode())) { - response.sendError(403, $L("你没有访问此页面的权限")); + response.sendError(403, Language.L("你没有访问此页面的权限")); return null; } diff --git a/src/main/java/com/rebuild/web/general/GeneralOperatingController.java b/src/main/java/com/rebuild/web/general/GeneralOperatingController.java index 9ab28fec3..980ef8c80 100644 --- a/src/main/java/com/rebuild/web/general/GeneralOperatingController.java +++ b/src/main/java/com/rebuild/web/general/GeneralOperatingController.java @@ -32,6 +32,7 @@ import com.rebuild.core.service.general.BulkContext; import com.rebuild.core.service.general.EntityService; import com.rebuild.core.support.general.FieldValueHelper; import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.IdParam; @@ -48,8 +49,6 @@ import javax.servlet.http.HttpServletRequest; import java.sql.DataTruncation; import java.util.*; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 业务实体操作(增/改/删/分派/共享) * @@ -89,7 +88,7 @@ public class GeneralOperatingController extends BaseController { // 检查重复值 List repeated = ies.getAndCheckRepeated(record, 100); if (!repeated.isEmpty()) { - return new RespBody(CODE_REPEATED_VALUES, $L("存在重复记录"), buildRepeatedData(repeated)); + return new RespBody(CODE_REPEATED_VALUES, Language.L("存在重复记录"), buildRepeatedData(repeated)); } try { @@ -379,7 +378,7 @@ public class GeneralOperatingController extends BaseController { sameEntityCode = id0.getEntityCode(); } if (sameEntityCode != id0.getEntityCode()) { - throw new InvalidParameterException($L("只能批量处理同一实体的记录")); + throw new InvalidParameterException(Language.L("只能批量处理同一实体的记录")); } idList.add(ID.valueOf(id)); } diff --git a/src/main/java/com/rebuild/web/general/ModelExtrasController.java b/src/main/java/com/rebuild/web/general/ModelExtrasController.java index 799634ad3..f8ac21a8e 100644 --- a/src/main/java/com/rebuild/web/general/ModelExtrasController.java +++ b/src/main/java/com/rebuild/web/general/ModelExtrasController.java @@ -23,6 +23,7 @@ import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.privileges.bizz.User; import com.rebuild.core.service.general.transform.RecordTransfomer; import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.EntityParam; @@ -36,8 +37,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 表单/视图 功能扩展 * @@ -69,7 +68,7 @@ public class ModelExtrasController extends BaseController { RecordTransfomer transfomer = new RecordTransfomer(targetEntity, (JSONObject) config.getJSON("config")); if (!transfomer.checkFilter(sourceRecord)) { - return RespBody.error($L("当前记录不符合转换条件"), 400); + return RespBody.error(Language.L("当前记录不符合转换条件"), 400); } ID newId = transfomer.transform(sourceRecord); @@ -146,13 +145,13 @@ public class ModelExtrasController extends BaseController { for (Object[] o : array) { int revType = (int) o[0]; - if (revType == 1) o[0] = $L("新建"); - else if (revType == 2) o[0] = $L("删除"); - else if (revType == 4) o[0] = $L("更新"); - else if (revType == 16) o[0] = $L("分派"); - else if (revType == 32) o[0] = $L("共享"); - else if (revType == 64) o[0] = $L("取消共享"); - else o[0] = $L("未知"); + if (revType == 1) o[0] = Language.L("新建"); + else if (revType == 2) o[0] = Language.L("删除"); + else if (revType == 4) o[0] = Language.L("更新"); + else if (revType == 16) o[0] = Language.L("分派"); + else if (revType == 32) o[0] = Language.L("共享"); + else if (revType == 64) o[0] = Language.L("取消共享"); + else o[0] = Language.L("未知"); o[1] = I18nUtils.formatDate((Date) o[1]); o[2] = new Object[] { o[2], UserHelper.getName((ID) o[2]) }; diff --git a/src/main/java/com/rebuild/web/general/RecentlyUsedSearchController.java b/src/main/java/com/rebuild/web/general/RecentlyUsedSearchController.java index 1ccb1d8e9..9fff92fc1 100644 --- a/src/main/java/com/rebuild/web/general/RecentlyUsedSearchController.java +++ b/src/main/java/com/rebuild/web/general/RecentlyUsedSearchController.java @@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject; import com.rebuild.api.RespBody; import com.rebuild.core.service.general.RecentlyUsedHelper; import com.rebuild.core.support.general.FieldValueHelper; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import org.apache.commons.lang.StringUtils; @@ -24,8 +25,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 最近搜索(针对引用字段)。 * 非自动,需要调用 recently-add 方法手动添加方可用,后期考虑自动化 @@ -43,7 +42,7 @@ public class RecentlyUsedSearchController extends BaseController { String type = getParameter(request, "type"); ID[] recently = RecentlyUsedHelper.gets(getRequestUser(request), entity, type); - return formatSelect2(recently, $L("最近使用")); + return formatSelect2(recently, Language.L("最近使用")); } @PostMapping("recently-add") diff --git a/src/main/java/com/rebuild/web/general/ReportsController.java b/src/main/java/com/rebuild/web/general/ReportsController.java index 46faee346..dd9ff8624 100644 --- a/src/main/java/com/rebuild/web/general/ReportsController.java +++ b/src/main/java/com/rebuild/web/general/ReportsController.java @@ -20,6 +20,7 @@ import com.rebuild.core.service.dataimport.DataExporter; import com.rebuild.core.service.datareport.DataReportManager; import com.rebuild.core.service.datareport.EasyExcelGenerator; import com.rebuild.core.support.general.BatchOperatorQuery; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.utils.RbAssert; import com.rebuild.web.BaseController; @@ -35,8 +36,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 报表/导出 * @@ -85,7 +84,7 @@ public class ReportsController extends BaseController { final ID user = getRequestUser(request); RbAssert.isAllow( Application.getPrivilegesManager().allow(user, ZeroEntry.AllowDataExport), - $L("无操作权限")); + Language.L("无操作权限")); int dataRange = getIntParameter(request, "dr", BatchOperatorQuery.DR_PAGED); JSONObject queryData = (JSONObject) ServletUtils.getRequestJson(request); diff --git a/src/main/java/com/rebuild/web/project/ProjectController.java b/src/main/java/com/rebuild/web/project/ProjectController.java index 79f0bbc92..9a97c5c35 100644 --- a/src/main/java/com/rebuild/web/project/ProjectController.java +++ b/src/main/java/com/rebuild/web/project/ProjectController.java @@ -119,7 +119,7 @@ public class ProjectController extends BaseController { // 未找到就跳转到第一个项目 ConfigBean[] ccc = ProjectManager.instance.getAvailable(getRequestUser(request)); if (ccc.length == 0) { - response.sendError(404, Language.$L("没有可用项目")); + response.sendError(404, Language.L("没有可用项目")); } else { String projectUrl = baseUrl + ccc[0].getID("id") + "/tasks#gs="; if (gs != null) projectUrl += CodecUtils.urlEncode(gs); diff --git a/src/main/java/com/rebuild/web/project/ProjectTaskController.java b/src/main/java/com/rebuild/web/project/ProjectTaskController.java index a7d1b6bbe..a6674bb3c 100644 --- a/src/main/java/com/rebuild/web/project/ProjectTaskController.java +++ b/src/main/java/com/rebuild/web/project/ProjectTaskController.java @@ -22,6 +22,7 @@ import com.rebuild.core.service.project.ProjectManager; import com.rebuild.core.service.query.AdvFilterParser; import com.rebuild.core.support.general.FieldValueHelper; import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.IdParam; @@ -40,8 +41,6 @@ import java.io.IOException; import java.util.Date; import java.util.Set; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 任务 * @@ -67,7 +66,7 @@ public class ProjectTaskController extends BaseController { final ID user = getRequestUser(request); if (!ProjectHelper.checkReadable(taskId2, user)) { - response.sendError(403, $L("你无权查看此任务")); + response.sendError(403, Language.L("你无权查看此任务")); return null; } @@ -230,7 +229,7 @@ public class ProjectTaskController extends BaseController { public JSON relatedTaskList(@IdParam(name = "related", required = false) ID relatedId, @IdParam(name = "task", required = false) ID taskId, HttpServletRequest request) { - Assert.isTrue(relatedId != null || taskId != null, $L("无效请求参数")); + Assert.isTrue(relatedId != null || taskId != null, Language.L("无效请求参数")); String queryWhere = String.format("relatedRecord = '%s'", relatedId); // 关键词搜索 diff --git a/src/main/java/com/rebuild/web/robot/approval/ApprovalAdminController.java b/src/main/java/com/rebuild/web/robot/approval/ApprovalAdminController.java index 567cfae05..ae056cfa9 100644 --- a/src/main/java/com/rebuild/web/robot/approval/ApprovalAdminController.java +++ b/src/main/java/com/rebuild/web/robot/approval/ApprovalAdminController.java @@ -24,6 +24,7 @@ import com.rebuild.core.metadata.easymeta.EasyMetaFactory; import com.rebuild.core.privileges.UserHelper; import com.rebuild.core.service.approval.ApprovalHelper; import com.rebuild.core.service.approval.RobotApprovalConfigService; +import com.rebuild.core.support.i18n.Language; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.EntityParam; @@ -37,8 +38,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao zhaofang123@gmail.com * @since 2019/06/24 @@ -61,7 +60,7 @@ public class ApprovalAdminController extends BaseController { .setParameter(1, configId) .unique(); if (config == null) { - response.sendError(404, $L("审批流程不存在")); + response.sendError(404, Language.L("审批流程不存在")); return null; } @@ -116,8 +115,8 @@ public class ApprovalAdminController extends BaseController { @GetMapping("approval/user-fields") public JSON approvalUserFields(@EntityParam Entity entity) { - final String textSubmitor = $L("发起人") + "."; - final String textApprover = $L("审批人") + "."; + final String textSubmitor = Language.L("发起人") + "."; + final String textApprover = Language.L("审批人") + "."; List fields = new ArrayList<>(); @@ -158,8 +157,8 @@ public class ApprovalAdminController extends BaseController { public JSON approvalUserFieldsShow(@EntityParam Entity entity, HttpServletRequest request) { final JSON users = ServletUtils.getRequestJson(request); - final String textSubmitor = $L("发起人") + "."; - final String textApprover = $L("审批人") + "."; + final String textSubmitor = Language.L("发起人") + "."; + final String textApprover = Language.L("审批人") + "."; List shows = new ArrayList<>(); diff --git a/src/main/java/com/rebuild/web/robot/trigger/AutoApprovalController.java b/src/main/java/com/rebuild/web/robot/trigger/AutoApprovalController.java index fb2deff1a..32d05e07b 100644 --- a/src/main/java/com/rebuild/web/robot/trigger/AutoApprovalController.java +++ b/src/main/java/com/rebuild/web/robot/trigger/AutoApprovalController.java @@ -1,5 +1,4 @@ -/* -Copyright (c) REBUILD and/or its owners. All rights reserved. +/*Copyright (c) REBUILD and/or its owners. All rights reserved. rebuild is dual-licensed under commercial and open source licenses (GPLv3). See LICENSE and COMMERCIAL in the project root for license information. @@ -9,7 +8,6 @@ package com.rebuild.web.robot.trigger; import com.alibaba.fastjson.JSON; import com.rebuild.core.Application; -import com.rebuild.core.service.approval.RobotApprovalManager; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/com/rebuild/web/robot/trigger/TriggerAdminController.java b/src/main/java/com/rebuild/web/robot/trigger/TriggerAdminController.java index b08adfb73..f99dae55f 100644 --- a/src/main/java/com/rebuild/web/robot/trigger/TriggerAdminController.java +++ b/src/main/java/com/rebuild/web/robot/trigger/TriggerAdminController.java @@ -33,8 +33,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author devezhao zhaofang123@gmail.com * @since 2019/05/23 @@ -69,7 +67,7 @@ public class TriggerAdminController extends BaseController { mv.getModel().put("sourceEntity", sourceEntity.getName()); mv.getModel().put("sourceEntityLabel", EasyMetaFactory.getLabel(sourceEntity)); mv.getModel().put("actionType", actionType.name()); - mv.getModel().put("actionTypeLabel", $L(actionType)); + mv.getModel().put("actionTypeLabel", Language.L(actionType)); mv.getModel().put("when", config[2]); mv.getModel().put("whenTimer", config[7] == null ? StringUtils.EMPTY : config[7]); mv.getModel().put("whenFilter", StringUtils.defaultIfBlank((String) config[3], JSONUtils.EMPTY_OBJECT_STR)); @@ -83,7 +81,7 @@ public class TriggerAdminController extends BaseController { public List getAvailableActions() { List alist = new ArrayList<>(); for (ActionType t : ActionFactory.getAvailableActions()) { - alist.add(new String[] { t.name(), $L(t) }); + alist.add(new String[] { t.name(), Language.L(t) }); } return alist; } @@ -112,7 +110,7 @@ public class TriggerAdminController extends BaseController { Object[][] array = ReportTemplateController.queryListOfConfig(sql, belongEntity, q); for (Object[] o : array) { - o[7] = $L(ActionType.valueOf((String) o[7])); + o[7] = Language.L(ActionType.valueOf((String) o[7])); } return array; } diff --git a/src/main/java/com/rebuild/web/user/UserSettings.java b/src/main/java/com/rebuild/web/user/UserSettings.java index f722c13d6..18f23e519 100644 --- a/src/main/java/com/rebuild/web/user/UserSettings.java +++ b/src/main/java/com/rebuild/web/user/UserSettings.java @@ -16,6 +16,7 @@ import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.privileges.UserService; import com.rebuild.core.support.VerfiyCode; import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.SMSender; import com.rebuild.web.EntityController; import org.apache.commons.lang.StringUtils; @@ -27,8 +28,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.Date; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 用户设置 * @@ -59,7 +58,7 @@ public class UserSettings extends EntityController { String vcode = VerfiyCode.generate(email); String subject = "邮箱验证码"; - String content = $L("你的邮箱验证码是 : **%s**", vcode); + String content = Language.L("你的邮箱验证码是 : **%s**", vcode); String sentid = SMSender.sendMail(email, subject, content); if (sentid != null) { diff --git a/src/main/java/com/rebuild/web/user/signup/LoginController.java b/src/main/java/com/rebuild/web/user/signup/LoginController.java index 198b07324..acb428d06 100644 --- a/src/main/java/com/rebuild/web/user/signup/LoginController.java +++ b/src/main/java/com/rebuild/web/user/signup/LoginController.java @@ -27,6 +27,7 @@ import com.rebuild.core.privileges.UserService; import com.rebuild.core.privileges.bizz.User; import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.support.*; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.SMSender; import com.rebuild.utils.AES; import com.rebuild.utils.AppUtils; @@ -48,8 +49,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.rebuild.core.support.i18n.Language.$L; - /** * @author zhaofang123@gmail.com * @since 07/25/2018 @@ -280,8 +279,8 @@ public class LoginController extends BaseController { } String vcode = VerfiyCode.generate(email, 2); - String subject = $L("重置密码"); - String content = $L("你的重置密码验证码是 : **%s**", vcode); + String subject = Language.L("重置密码"); + String content = Language.L("你的重置密码验证码是 : **%s**", vcode); String sentid = SMSender.sendMail(email, subject, content); if (sentid != null) { diff --git a/src/main/java/com/rebuild/web/user/signup/SignUpController.java b/src/main/java/com/rebuild/web/user/signup/SignUpController.java index 042599fb6..53cccd74d 100644 --- a/src/main/java/com/rebuild/web/user/signup/SignUpController.java +++ b/src/main/java/com/rebuild/web/user/signup/SignUpController.java @@ -20,6 +20,7 @@ import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.support.ConfigurationItem; import com.rebuild.core.support.RebuildConfiguration; import com.rebuild.core.support.VerfiyCode; +import com.rebuild.core.support.i18n.Language; import com.rebuild.core.support.integration.SMSender; import com.rebuild.utils.BlockList; import com.rebuild.web.BaseController; @@ -37,8 +38,6 @@ import javax.servlet.http.HttpServletResponse; import java.awt.*; import java.io.IOException; -import static com.rebuild.core.support.i18n.Language.$L; - /** * 用户自助注册 * @@ -53,7 +52,7 @@ public class SignUpController extends BaseController { @GetMapping("signup") public ModelAndView pageSignup(HttpServletResponse response) throws IOException { if (!RebuildConfiguration.getBool(ConfigurationItem.OpenSignUp)) { - response.sendError(400, $L("管理员未开放公开注册")); + response.sendError(400, Language.L("管理员未开放公开注册")); return null; } return createModelAndView("/signup/signup"); @@ -74,8 +73,8 @@ public class SignUpController extends BaseController { } String vcode = VerfiyCode.generate(email, 1); - String title = $L("注册验证码"); - String content = $L("你的注册验证码是 : **%s**", vcode); + String title = Language.L("注册验证码"); + String content = Language.L("你的注册验证码是 : **%s**", vcode); String sentid = SMSender.sendMail(email, title, content); @@ -113,8 +112,8 @@ public class SignUpController extends BaseController { // 通知用户 String homeUrl = RebuildConfiguration.getHomeUrl(); - String title = $L("管理员正在审核你的注册信息"); - String content = $L( + String title = Language.L("管理员正在审核你的注册信息"); + String content = Language.L( "%s 欢迎注册!以下是你的注册信息,请妥善保管。 [][] 登录账号 : **%s** [] 登录密码 : **%s** [] 登录地址 : [%s](%s) [][] 目前你还无法登录系统,因为系统管理员正在审核你的注册信息。完成后会通过邮件通知你,请耐心等待。", fullName, loginName, passwd, homeUrl, homeUrl); SMSender.sendMail(email, title, content); diff --git a/src/main/resources/web/_include/nav-left-admin.html b/src/main/resources/web/_include/nav-left-admin.html index f519c19cf..26af5029f 100644 --- a/src/main/resources/web/_include/nav-left-admin.html +++ b/src/main/resources/web/_include/nav-left-admin.html @@ -6,20 +6,20 @@

- +
diff --git a/src/main/resources/web/_include/nav-top.html b/src/main/resources/web/_include/nav-top.html index 4af61c128..f78c46db3 100644 --- a/src/main/resources/web/_include/nav-top.html +++ b/src/main/resources/web/_include/nav-top.html @@ -3,7 +3,7 @@
- +
- +
@@ -21,25 +21,25 @@ - - - diff --git a/src/main/resources/web/admin/admin-verify.html b/src/main/resources/web/admin/admin-verify.html index af0896df5..74889ab99 100644 --- a/src/main/resources/web/admin/admin-verify.html +++ b/src/main/resources/web/admin/admin-verify.html @@ -2,11 +2,11 @@ - [[${bundle.$L('管理员验证')}]] + [[${bundle.L('管理员验证')}]] @@ -18,21 +18,21 @@
-

[[${bundle.$L('需要验证你的管理员身份')}]]

+

[[${bundle.L('需要验证你的管理员身份')}]]

- +
diff --git a/src/main/resources/web/admin/audit/login-logs.html b/src/main/resources/web/admin/audit/login-logs.html index c23907b1b..52bd50663 100644 --- a/src/main/resources/web/admin/audit/login-logs.html +++ b/src/main/resources/web/admin/audit/login-logs.html @@ -2,7 +2,7 @@ - [[${bundle.$L('登录日志')}]] + [[${bundle.L('登录日志')}]]