From 85767126a9989b08d36fa6ad2c7e73688e1e9567 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Sat, 11 Nov 2023 13:15:06 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E4=B8=AA=E6=80=A7=E5=8C=96=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=8F=90=E9=86=92=E7=9A=84=E6=96=87=E6=A1=88=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1020779955716096]个人设置-个性化弹窗提醒的文案错误 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1020779955716096 --- .../common/constvalue/IUserProfile.java | 8 ++-- .../constvalue/IUserProfileOperate.java | 6 +++ .../common/constvalue/UserProfile.java | 46 ++++--------------- .../common/constvalue/UserProfileOperate.java | 23 +++++----- .../userprofile/UserProfileFactory.java | 20 ++++---- 5 files changed, 39 insertions(+), 64 deletions(-) create mode 100644 src/main/java/neatlogic/framework/common/constvalue/IUserProfileOperate.java diff --git a/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java b/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java index 8b02e0141..d8092a69b 100644 --- a/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java +++ b/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java @@ -1,11 +1,11 @@ package neatlogic.framework.common.constvalue; -import neatlogic.framework.dto.UserProfileVo; +import java.util.List; public interface IUserProfile { - - UserProfileVo getUserProfile(); - + String getValue(); + String getText(); + List getProfileOperateList(); String getModuleId(); } diff --git a/src/main/java/neatlogic/framework/common/constvalue/IUserProfileOperate.java b/src/main/java/neatlogic/framework/common/constvalue/IUserProfileOperate.java new file mode 100644 index 000000000..070c94df8 --- /dev/null +++ b/src/main/java/neatlogic/framework/common/constvalue/IUserProfileOperate.java @@ -0,0 +1,6 @@ +package neatlogic.framework.common.constvalue; + +public interface IUserProfileOperate { + String getValue(); + String getText(); +} diff --git a/src/main/java/neatlogic/framework/common/constvalue/UserProfile.java b/src/main/java/neatlogic/framework/common/constvalue/UserProfile.java index db3994f8a..8eea6a65d 100644 --- a/src/main/java/neatlogic/framework/common/constvalue/UserProfile.java +++ b/src/main/java/neatlogic/framework/common/constvalue/UserProfile.java @@ -1,25 +1,20 @@ package neatlogic.framework.common.constvalue; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.common.util.ModuleUtil; -import neatlogic.framework.dto.UserProfileVo; import neatlogic.framework.util.$; -import neatlogic.framework.util.I18n; import java.util.Arrays; import java.util.List; public enum UserProfile implements IUserProfile { - USER_CREATE_SUCESS("usercreatesuccess", new I18n("用户创建成功"), Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_USER, UserProfileOperate.BACK_USER_LIST)), - ROLE_CREATE_SUCESS("rolecreatesuccess", new I18n("用户组创建成功"), Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_ROLE, UserProfileOperate.BACK_ROLE_LIST)), - TEAM_CREATE_SUCESS("teamcreatesuccess", new I18n("用户组创建成功"), Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_TEAM, UserProfileOperate.BACK_TEAM_LIST)); + USER_CREATE_SUCESS("usercreatesuccess", "nfcc.userprofile.usercreatesuccess", Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_USER, UserProfileOperate.BACK_USER_LIST)), + ROLE_CREATE_SUCESS("rolecreatesuccess", "nfcc.userprofile.rolecreatesuccess", Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_ROLE, UserProfileOperate.BACK_ROLE_LIST)), + TEAM_CREATE_SUCESS("teamcreatesuccess", "nfcc.userprofile.teamcreatesuccess", Arrays.asList(UserProfileOperate.KEEP_ON_CREATE, UserProfileOperate.EDIT_TEAM, UserProfileOperate.BACK_TEAM_LIST)); private String value; - private I18n text; - private List userProfileOperateList; + private String text; + private List userProfileOperateList; - private UserProfile(String _value, I18n _text, List _userProfileOperateList) { + UserProfile(String _value, String _text, List _userProfileOperateList) { this.value = _value; this.text = _text; this.userProfileOperateList = _userProfileOperateList; @@ -29,36 +24,13 @@ public enum UserProfile implements IUserProfile { return value; } - public JSONArray getUserProfileOperateList() { - JSONArray userProfileOperateArray = new JSONArray(); - for (UserProfileOperate userProfileOperate : userProfileOperateList) { - JSONObject json = new JSONObject(); - json.put("value", userProfileOperate.getValue()); - json.put("text", userProfileOperate.getText()); - userProfileOperateArray.add(json); - } - return userProfileOperateArray; - } - public String getText() { - return $.t(text.toString()); + return $.t(text); } @Override - public UserProfileVo getUserProfile() { - UserProfileVo userProfileVo = new UserProfileVo(); - userProfileVo.setModuleId(getModuleId()); - userProfileVo.setModuleName(ModuleUtil.getModuleById(getModuleId()).getName()); - JSONArray userProfileArray = new JSONArray(); - for (UserProfile f : UserProfile.values()) { - JSONObject configJson = new JSONObject(); - configJson.put("value", f.getValue()); - configJson.put("text", f.getText()); - configJson.put("userProfileOperateList", f.getUserProfileOperateList()); - userProfileArray.add(configJson); - } - userProfileVo.setConfig(userProfileArray.toJSONString()); - return userProfileVo; + public List getProfileOperateList() { + return this.userProfileOperateList; } @Override diff --git a/src/main/java/neatlogic/framework/common/constvalue/UserProfileOperate.java b/src/main/java/neatlogic/framework/common/constvalue/UserProfileOperate.java index 8bea31e2f..04085894e 100644 --- a/src/main/java/neatlogic/framework/common/constvalue/UserProfileOperate.java +++ b/src/main/java/neatlogic/framework/common/constvalue/UserProfileOperate.java @@ -1,21 +1,20 @@ package neatlogic.framework.common.constvalue; import neatlogic.framework.util.$; -import neatlogic.framework.util.I18n; -public enum UserProfileOperate { - KEEP_ON_CREATE("keeponcreate", new I18n("继续创建")), - EDIT_USER("edituser", new I18n("编辑用户")), - BACK_USER_LIST("backuserlist", new I18n("返回用户列表")), - EDIT_ROLE("editrole", new I18n("编辑角色")), - BACK_ROLE_LIST("backrolelist", new I18n("返回角色列表")), - EDIT_TEAM("editteam", new I18n("编辑用户")), - BACK_TEAM_LIST("backteamlist", new I18n("返回用户组列表")); +public enum UserProfileOperate implements IUserProfileOperate { + KEEP_ON_CREATE("keeponcreate", "nfcc.userprofileoperate.keeponcreate"), + EDIT_USER("edituser", "nfcc.userprofileoperate.edituser"), + BACK_USER_LIST("backuserlist", "nfcc.userprofileoperate.backuserlist"), + EDIT_ROLE("editrole", "nfcc.userprofileoperate.editrole"), + BACK_ROLE_LIST("backrolelist", "nfcc.userprofileoperate.backrolelist"), + EDIT_TEAM("editteam", "nfcc.userprofileoperate.editteam"), + BACK_TEAM_LIST("backteamlist", "nfcc.userprofileoperate.backteamlist"); private String value; - private I18n text; + private String text; - private UserProfileOperate(String _value, I18n _text) { + UserProfileOperate(String _value, String _text) { this.value = _value; this.text = _text; } @@ -25,7 +24,7 @@ public enum UserProfileOperate { } public String getText() { - return $.t(text.toString()); + return $.t(text); } } diff --git a/src/main/java/neatlogic/framework/userprofile/UserProfileFactory.java b/src/main/java/neatlogic/framework/userprofile/UserProfileFactory.java index 09224e744..6dc3bdb4d 100644 --- a/src/main/java/neatlogic/framework/userprofile/UserProfileFactory.java +++ b/src/main/java/neatlogic/framework/userprofile/UserProfileFactory.java @@ -17,31 +17,29 @@ package neatlogic.framework.userprofile; import neatlogic.framework.common.constvalue.IUserProfile; -import neatlogic.framework.dto.UserProfileVo; import org.reflections.Reflections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; public class UserProfileFactory { - private static final Map userProfileMap = new HashMap<>(); + private static final Map> moduleId2UserProfileListMap = new HashMap<>(); static { Reflections reflections = new Reflections("neatlogic"); Set> userProfileClass = reflections.getSubTypesOf(IUserProfile.class); for (Class c : userProfileClass) { try { - Object[] objects = c.getEnumConstants(); - UserProfileVo userProfileVo = (UserProfileVo) c.getMethod("getUserProfile").invoke(objects[0]); - userProfileMap.put(userProfileVo.getModuleId(), userProfileVo); + IUserProfile[] objects = c.getEnumConstants(); + for (IUserProfile userProfile : objects) { + moduleId2UserProfileListMap.computeIfAbsent(userProfile.getModuleId(), key -> new ArrayList<>()).add(userProfile); + } } catch (Exception e) { e.printStackTrace(); } } } - public static Map getUserProfileMap() { - return userProfileMap; + + public static List getUserProfileListByModuleId(String moduleId) { + return moduleId2UserProfileListMap.get(moduleId); } - } -- Gitee