diff --git a/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java b/src/main/java/neatlogic/framework/common/constvalue/IUserProfile.java index 8b02e01417c0f46733426349a76d4d8829db328c..d8092a69b9b51af7bfcebb2cbcbda58c255df243 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 0000000000000000000000000000000000000000..070c94df81682360a96021fd86c64aca746d0c0b --- /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 db3994f8aae0df210d7dbb719431c75a1fd4d6cf..8eea6a65db152a1b4f771d3ea74bb8cf95ac3be1 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 8bea31e2f18b897d4d79f098a2b03e461518a9ea..04085894ea2ad450fc615e69958fc851e3d7a4f3 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 09224e74404fe0efd76e15fbd2cad3682a8e478e..6dc3bdb4dc49b6135018642a1a9e27fa476a4aff 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); } - }