📄 checkpowerbean.java~2~
字号:
package com.talent.system.login;/** * <p>Title: Login</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003-01-05</p> * <p>Company: www.chinatalent.com</p> * @author jingyucui * @version 1.0 */import java.rmi.*;import java.util.*;import java.sql.*;import javax.ejb.*;import javax.naming.*;import javax.servlet.*;import javax.sql.RowSet;import javax.servlet.http.*;import javax.servlet.http.HttpServlet;import javax.transaction.UserTransaction;import weblogic.jndi.*;import sun.jdbc.rowset.*;import com.talent.publics.DbBean;public class CheckPowerBean extends HttpServlet{ static final private String CONTENT_TYPE = "text/html; charset=GBK"; //Initialize global variables public void init() throws ServletException { } //Process the HTTP Get request public void doOtherGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String functionId = ""; String powerGroupId = ""; try{ CachedRowSet cachedRowSet = new CachedRowSet(); cachedRowSet = (CachedRowSet)session.getAttribute("LoginUser"); cachedRowSet.beforeFirst(); while(cachedRowSet.next()){ functionId = cachedRowSet.getString("functionId"); powerGroupId = cachedRowSet.getString("powerGroupId"); } if (!checkPower(functionId,powerGroupId)){ RequestDispatcher dispatcher = request.getRequestDispatcher("./jsp/error/error.jsp?key=0008"); dispatcher.forward(request, response); } }catch(Exception ex){ } } } //Process the HTTP Post request public void doOtherPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String functionId = ""; String powerGroupId = ""; try{ CachedRowSet cachedRowSet = new CachedRowSet(); cachedRowSet = (CachedRowSet)session.getAttribute("LoginUser"); cachedRowSet.beforeFirst(); while(cachedRowSet.next()){ functionId = cachedRowSet.getString("functionId"); powerGroupId = cachedRowSet.getString("powerGroupId"); } if (!checkPower(functionId,powerGroupId)){ RequestDispatcher dispatcher = request.getRequestDispatcher("./jsp/error/error.jsp?key=0008"); dispatcher.forward(request, response); } }catch(Exception ex){ } } private boolean checkPower(String functionId,String powerGroupId) throws Exception{ String sql = null; int count = 0; ResultSet resultSet; sql = "select count(*) from POWER where POWERID = '"+functionId+"' and POWERGROUPID = '"+powerGroupId+"'"; try{ DbBean dbBean = new DbBean(); resultSet = dbBean.execQuery(sql); while(resultSet.next()){ count = resultSet.getInt(1); } if (count > 0){ return true; }else{ return false; } }catch(Exception ex){ } return false; } private int checkRole(String operatorRole,String idName,String idValue,String tableName) throws Exception{ String sql = null; String inRole = ""; String supRead = ""; String supWrite = ""; String sameRead = ""; String sameWrite = ""; String subRead = ""; String subWrite = ""; ResultSet resultSet; try{ DbBean dbBean = new DbBean(); sql = "select * from " + tableName + " where " + idName + " = '" + idValue + "'"; resultSet = dbBean.execQuery(sql); while(resultSet.next()){ inRole = resultSet.getString("INROLE"); supRead = resultSet.getString("SUPREAD"); supWrite = resultSet.getString("SUPWRITE"); sameRead = resultSet.getString("SAMEREAD"); sameWrite = resultSet.getString("SAMEWRITE"); subRead = resultSet.getString("SUBREAD"); subWrite = resultSet.getString("SUBWRITE"); } if (operatorRole > inRole){ } }catch(Exception ex){ } return false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -