From da4fa0aaa9a514a3ef5c434df16f190b9f91bd8e Mon Sep 17 00:00:00 2001 From: "jingwei.tao" <1249074319@qq.com> Date: Sat, 10 Jun 2023 18:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=9D=A5=E4=B9=8D=E5=88=B0=20?= =?UTF-8?q?=E8=AF=B7=E5=A4=9A=E5=85=B3=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ecologyutil/rightutil/RightMoveUtil.java | 61 ++++ .../cushttpclasses/CusHttpServletRequest.java | 274 ++++++++++++++++++ .../cushttpclasses/CusHttpSession.java | 113 ++++++++ 3 files changed, 448 insertions(+) create mode 100644 src/main/java/aiyh/utils/ecologyutil/rightutil/RightMoveUtil.java create mode 100644 src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java create mode 100644 src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpSession.java diff --git a/src/main/java/aiyh/utils/ecologyutil/rightutil/RightMoveUtil.java b/src/main/java/aiyh/utils/ecologyutil/rightutil/RightMoveUtil.java new file mode 100644 index 0000000..6d80747 --- /dev/null +++ b/src/main/java/aiyh/utils/ecologyutil/rightutil/RightMoveUtil.java @@ -0,0 +1,61 @@ +package aiyh.utils.ecologyutil.rightutil; + +import aiyh.utils.Util; +import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest; +import aiyh.utils.httpUtil.cushttpclasses.CusHttpSession; +import com.alibaba.fastjson.JSONObject; +import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd; +import weaver.hrm.User; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.HashMap; +import java.util.Map; + + +/** + * ecology权限相关方法 + * + */ +public class RightMoveUtil { + + /** + * 触发标准权限转移 转移待办已办等信息 + * @param param + * @return + */ + public static JSONObject moveRight(JSONObject param){ + JSONObject result = new JSONObject(); + try{ + Util.logStr("RightMoveUtil moveRight begin;param:[{}]", param.toJSONString()); + Map params = new HashMap<>(); + for(Object key : param.keySet()){ + params.put(key.toString(),param.get(key)); + } + HttpServletRequest request = new CusHttpServletRequest(){ + @Override + public String getParameter(String s) { + return param.getString(s); + } + @Override + public HttpSession getSession(boolean b) { + HttpSession session = new CusHttpSession(){ + @Override + public Object getAttribute(String s) { + return new User(1); + } + }; + return session; + } + }; + ProcessDataCmd cmd = new ProcessDataCmd(params,request,new User(1)); + Map execute = cmd.execute(null); + result = new JSONObject(execute); + Util.logStr("RightMoveUtil moveRight end;result:[{}]", execute.toString()); + return result; + }catch (Throwable e){ + Util.logStr("RightMoveUtil moveRight error;message:[{}]", e.getMessage()); + return result; + } + } + +} \ No newline at end of file diff --git a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java new file mode 100644 index 0000000..231944e --- /dev/null +++ b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java @@ -0,0 +1,274 @@ +package aiyh.utils.httpUtil.cushttpclasses; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletInputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Map; + +public class CusHttpServletRequest implements HttpServletRequest { + + @Override + public String getMethod() { + return null; + } + + @Override + public String getRequestURI() { + return null; + } + + @Override + public StringBuffer getRequestURL() { + return null; + } + + @Override + public String getContextPath() { + return null; + } + + @Override + public String getServletPath() { + return null; + } + + @Override + public String getPathInfo() { + return null; + } + + @Override + public String getPathTranslated() { + return null; + } + + @Override + public String getQueryString() { + return null; + } + + @Override + public String getHeader(String s) { + return null; + } + + @Override + public Enumeration getHeaders(String s) { + return null; + } + + @Override + public Enumeration getHeaderNames() { + return null; + } + + @Override + public int getIntHeader(String s) { + return 0; + } + + @Override + public long getDateHeader(String s) { + return 0; + } + + @Override + public Cookie[] getCookies() { + return new Cookie[0]; + } + + @Override + public HttpSession getSession(boolean b) { + return null; + } + + @Override + public HttpSession getSession() { + return null; + } + + @Override + public String getRequestedSessionId() { + return null; + } + + @Override + public boolean isRequestedSessionIdValid() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return false; + } + + @Override + public String getAuthType() { + return null; + } + + @Override + public String getRemoteUser() { + return null; + } + + @Override + public boolean isUserInRole(String s) { + return false; + } + + @Override + public Principal getUserPrincipal() { + return null; + } + + /** + * @deprecated + */ + @Override + public boolean isRequestedSessionIdFromUrl() { + return false; + } + + @Override + public String getProtocol() { + return null; + } + + @Override + public String getScheme() { + return null; + } + + @Override + public String getServerName() { + return null; + } + + @Override + public int getServerPort() { + return 0; + } + + @Override + public String getRemoteAddr() { + return null; + } + + @Override + public String getRemoteHost() { + return null; + } + + @Override + public void setCharacterEncoding(String s) throws UnsupportedEncodingException { + + } + + @Override + public String getParameter(String s) { + return null; + } + + @Override + public String[] getParameterValues(String s) { + return new String[0]; + } + + @Override + public Enumeration getParameterNames() { + return null; + } + + @Override + public Map getParameterMap() { + return null; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return null; + } + + @Override + public BufferedReader getReader() throws IOException, IllegalStateException { + return null; + } + + @Override + public String getCharacterEncoding() { + return null; + } + + @Override + public int getContentLength() { + return 0; + } + + @Override + public String getContentType() { + return null; + } + + @Override + public Locale getLocale() { + return null; + } + + @Override + public Enumeration getLocales() { + return null; + } + + @Override + public boolean isSecure() { + return false; + } + + @Override + public Object getAttribute(String s) { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public void removeAttribute(String s) { + + } + + @Override + public RequestDispatcher getRequestDispatcher(String s) { + return null; + } + + /** + * @param s + * @deprecated + */ + @Override + public String getRealPath(String s) { + return null; + } +} diff --git a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpSession.java b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpSession.java new file mode 100644 index 0000000..ba33838 --- /dev/null +++ b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpSession.java @@ -0,0 +1,113 @@ +package aiyh.utils.httpUtil.cushttpclasses; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionContext; +import java.util.Enumeration; + +public class CusHttpSession implements HttpSession { + + @Override + public String getId() { + return null; + } + + @Override + public boolean isNew() { + return false; + } + + @Override + public long getCreationTime() { + return 0; + } + + @Override + public long getLastAccessedTime() { + return 0; + } + + @Override + public void setMaxInactiveInterval(int i) { + + } + + @Override + public int getMaxInactiveInterval() { + return 0; + } + + @Override + public Object getAttribute(String s) { + return null; + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public void removeAttribute(String s) { + + } + + @Override + public void invalidate() { + + } + + /** + * @deprecated + */ + @Override + public HttpSessionContext getSessionContext() { + return null; + } + + @Override + public ServletContext getServletContext() { + return null; + } + + /** + * @param s + * @deprecated + */ + @Override + public Object getValue(String s) { + return null; + } + + /** + * @deprecated + */ + @Override + public String[] getValueNames() { + return new String[0]; + } + + /** + * @param s + * @param o + * @deprecated + */ + @Override + public void putValue(String s, Object o) { + + } + + /** + * @param s + * @deprecated + */ + @Override + public void removeValue(String s) { + + } +}