diff --git a/src/main/java/neatlogic/framework/dto/AuthorityVo.java b/src/main/java/neatlogic/framework/dto/AuthorityVo.java index 7a499dcf1439aaaf062ea0e0e9e1509202c74aac..d7e6a76611854a3ba0b5393122adaa1bef3ff674 100644 --- a/src/main/java/neatlogic/framework/dto/AuthorityVo.java +++ b/src/main/java/neatlogic/framework/dto/AuthorityVo.java @@ -15,10 +15,15 @@ along with this program. If not, see .*/ package neatlogic.framework.dto; +import neatlogic.framework.common.constvalue.GroupSearch; + +import java.util.ArrayList; +import java.util.List; + public class AuthorityVo { private String type; private String uuid; - + private String action; public AuthorityVo() { } @@ -44,6 +49,14 @@ public class AuthorityVo { this.uuid = uuid; } + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -54,6 +67,11 @@ public class AuthorityVo { return false; } else if (!type.equals(that.type)) return false; + if (action == null) { + if (that.action != null) + return false; + } else if (!action.equals(that.action)) + return false; if (uuid == null) { return that.uuid == null; } else return uuid.equals(that.uuid); @@ -64,7 +82,34 @@ public class AuthorityVo { final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((action == null) ? 0 : action.hashCode()); result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); return result; } + + public static List getAuthorityList(List authorityVoList) { + List authorityList = new ArrayList<>(); + for(AuthorityVo authorityVo : authorityVoList) { + GroupSearch groupSearch = GroupSearch.getGroupSearch(authorityVo.getType()); + if(groupSearch != null) { + authorityList.add(groupSearch.getValuePlugin() + authorityVo.getUuid()); + } + } + return authorityList; + } + + public static List getAuthorityVoList(List authorityList, String action) { + List authorityVoList = new ArrayList<>(); + for(String authority : authorityList) { + String[] split = authority.split("#"); + if(GroupSearch.getGroupSearch(split[0]) != null) { + AuthorityVo authorityVo = new AuthorityVo(); + authorityVo.setType(split[0]); + authorityVo.setUuid(split[1]); + authorityVo.setAction(action); + authorityVoList.add(authorityVo); + } + } + return authorityVoList; + } }