📄 checkpowerbean.java
字号:
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 doCheckRole(HttpServletRequest request, HttpServletResponse response) throws ServletException{ String operatorRole = ""; String operatorType = ""; String idName = ""; String idValue = ""; String tableName = ""; try{ operatorRole = request.getParameter("operatorrole"); operatorType = request.getParameter("operatortype"); idName = request.getParameter("idname"); idValue = request.getParameter("idvalue"); tableName = request.getParameter("tablename"); if (!checkRole(operatorRole,operatorType,idName,idValue,tableName)){ RequestDispatcher dispatcher = request.getRequestDispatcher("./jsp/error/error.jsp?key=0008"); dispatcher.forward(request, response); } }catch(Exception ex){ } } //Process the HTTP Post request public void doCheckPower(HttpServletRequest request, HttpServletResponse response) throws ServletException{ String functionId = ""; String powerGroupId = ""; try{ functionId = request.getParameter("functionid"); powerGroupId = request.getParameter("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 boolean checkRole(String operatorRole,String operatorType,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 (Integer.parseInt(operatorRole) > Integer.parseInt(inRole)){ //针对“读”操作 if (operatorType.equals("0")){ if (supRead.equals("1")){ return true; }else{ return false; } //针对“写”操作 }else{ if (supWrite.equals("1")){ return true; }else{ return false; } } }//同级操作员 if (operatorRole.equals(inRole)){ //针对“读”操作 if (operatorType.equals("0")){ if (sameRead.equals("1")){ return true; }else{ return false; } //针对“写”操作 }else{ if (sameWrite.equals("1")){ return true; }else{ return false; } } }// 下级操作员 if (Integer.parseInt(operatorRole) < Integer.parseInt(inRole)){ //针对“读”操作 if (operatorType.equals("0")){ if (subRead.equals("1")){ return true; }else{ return false; } //针对“写”操作 }else{ if (subWrite.equals("1")){ return true; }else{ return false; } } } }catch(Exception ex){ return false; } return false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -