?? rightbean.java
字號(hào):
/*******************************************************************************
* Version 1.0 Date:2003-11-07 Description:權(quán)限控制 Other: Variable List: 1.String
* uid = "-1";//人員編號(hào) String Orgid = "-1";//部門(mén)編號(hào)
*
* Function List: 1.public void setUID(String uid)//設(shè)置人員編號(hào) 2.public void
* setOrgid(String Orgid)//設(shè)置部門(mén)編號(hào)
*
* //三種權(quán)限 3.public boolean isAdmin();//判斷是否是系統(tǒng)管理員 4.public Vector
* getRightConf()//配置權(quán)限 5.public Vector getRightMode()//模塊權(quán)限 6.public Vector
* getRightFlow()//流程權(quán)限 7.public String getConfValue(String type)//取得配置數(shù)字
* 8.public boolean isRightMode(String mode,String
* button)//是否有操作button對(duì)模塊mode的權(quán)限 9.public boolean isRightFlow(String
* flow)//是否有操作流程flow的權(quán)限
*
* //公文權(quán)限 10.public Vector getRightConfidential()機(jī)要權(quán)限 11.public boolean
* isRightConfidential()判斷當(dāng)前是否有該權(quán)限 12.public boolean isRightSecretary()文書(shū)權(quán)限
* 13.public Vector getRightDuty()職務(wù)權(quán)限 14.public Vector getRightArchives()檔案權(quán)限
* 15.public Vector getRightPeriodical()期刊權(quán)限
*
* //版面管理權(quán)限 16.public Vector getBMBHS()//當(dāng)前職工所在的部門(mén)編號(hào)(包括被分配職務(wù)后得到的職務(wù)部門(mén)編號(hào)) 柳美\
* 17.public boolean isRightOrg(String
* lbid)//部門(mén)新聞操作權(quán)限(根據(jù)orgmenu.id判斷)(uid,orgid) 18.public boolean
* isRightPage(String dxbh,String whichtable,String sf,String cz)//版面權(quán)限
*
* 19. //*取得模塊權(quán)限------------lbh-----------11-29 //public String
* getRightModelbh() 20. //是否有模塊操作權(quán)限------------lbh-----------11-29 //public
* boolean isRightModelbh(String strmkmc,String strbtnmc)
*
* History:
******************************************************************************/
package oa.bean;
import java.util.*;
import java.sql.*;
import oa.main.*;
public class RightBean extends ParentBean {
String uid = "-1";//人員編號(hào)
String Orgid = "-1";//部門(mén)編號(hào)
public void setUID(String uid)//設(shè)置人員編號(hào)
{
this.uid = uid.trim();
}
public void setOrgid(String Orgid)//設(shè)置部門(mén)編號(hào)
{
this.Orgid = Orgid.trim();
}
/** 判斷是否是系統(tǒng)管理員 */
public boolean isAdmin() {
String name = toName("ZZ_ZGB", "ZGBH", "ZGBH", uid).toLowerCase();
if (name.equals("1"))
return true;
else
return false;
}
/** 配置權(quán)限 */
public Vector getRightConf() {
Vector vect = new Vector();
String right = "";
ResultSet rs = selectRecord("select PZCS from news.ZZ_ZGB where ZGBH='"
+ uid + "'");
Statement stmt = null;
try {
if (rs.next()) {
right = ds.toString(rs.getString("PZCS"));
}
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out
.println("RightBean.getRightConf()關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out
.println("RightBean.getRightConf()關(guān)閉聲明時(shí)statement出錯(cuò)"
+ e);
}
//if(right.equals(""))//當(dāng)當(dāng)前人員表為空時(shí),查詢職務(wù)表權(quán)限集合
{
rs = selectRecord("select PZCS from news.ZZ_ZWB where (BMBH,ZWBH) in (select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"
+ uid + "')");
if (rs.next()) {
if (!right.equals(""))
right += ",";
right = ds.toString(rs.getString("PZCS"));
}
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("RightBean.getRightConf()關(guān)閉記錄集rs時(shí)出錯(cuò)"
+ e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out
.println("RightBean.getRightConf()關(guān)閉聲明時(shí)statement出錯(cuò)"
+ e);
}
}
if (right.equals(""))//當(dāng)職務(wù)表集合為空時(shí)
{
stmt = rs.getStatement();
rs.close();
stmt.close();
rs = selectRecord("select PZSZ from news.CODE_XTPZ order by PZBH");
while (rs.next()) {
vect.add(ds.toString(rs.getString(1)));
}
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("RightBean.getRightConf()關(guān)閉記錄集rs時(shí)出錯(cuò)"
+ e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out
.println("RightBean.getRightConf()關(guān)閉聲明時(shí)statement出錯(cuò)"
+ e);
}
} else {
String str[] = ds.splitStr(right, ',');
for (int i = 0; i < str.length; i++) {
vect.add(str[i]);
}
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
return vect;
}
public String getConfValue(String type)//取得配置數(shù)字
{
String confvalue = "";
Vector vect = getRightConf();
int pzbh = toID("CODE_XTPZ", "PZMC", "PZBH", type.trim());
if (vect.size() >= pzbh && pzbh > 0)
confvalue = (String) vect.get(pzbh - 1);
return confvalue;
}
/** 模塊權(quán)限 */
public Vector getRightMode() {
Vector vect = new Vector();
String sql = "select BMBH,ZWBH,CZQX from news.ZZ_ZGZWB where ZGBH='"
+ uid + "'";
if (!uid.equals("1") && !Orgid.equals("-1")) {
char bmsub;
int n = 19;
for (n = 19; n >= 0; n--) {
bmsub = Orgid.charAt(n);
if (bmsub != '0')
break;
}
if (n == -1)
n = 1;
sql += " and (BMBH='" + Orgid + "' or BMBH like '%"
+ Orgid.substring(0, n + 1) + "%')";
}
String right = "";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next())//取得職務(wù)表權(quán)限
{
String czqx = ds.toString(rs.getString("CZQX"));
String bmbh = ds.toString(rs.getString("BMBH"));
String zwbh = ds.toString(rs.getString("ZWBH"));
if (czqx.equals(""))//當(dāng)職務(wù)表中權(quán)限為空時(shí),去部門(mén)職務(wù)表權(quán)限
{
sql = "select CZQX from news.ZZ_ZWB where BMBH='" + bmbh
+ "' and ZWBH=" + zwbh + " and ZWZT=0";
ResultSet rs_t = selectRecord(sql);
try {
rs_t.next();
czqx = ds.toString(rs_t.getString("CZQX"));
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs_t != null)
try {
stmt = rs_t.getStatement();
rs_t.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
}
if (!right.equals("") && !czqx.equals(""))
right += ",";
if (!czqx.equals(""))
right += czqx;
}
//if(right.equals(""))//當(dāng)職務(wù)權(quán)限集合為空時(shí)查詢字典
//{
stmt = rs.getStatement();
rs.close();
stmt.close();
rs = selectRecord("select ID from news.CODE_ANCZQXB where MRCZ=1 and SYZT=0");
while (rs.next()) {
vect.add(rs.getString(1));
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
//}
//else
//{
String str[] = ds.splitStr(right, ',');
for (int i = 0; i < str.length; i++) {
vect.add(str[i]);
}
//}
return vect;
}
/** 流程權(quán)限 */
public Vector getRightFlow() {
Vector vect = new Vector();
String sql = "select BMBH,ZWBH,LCQX from news.ZZ_ZGZWB where ZGBH='"
+ uid + "'";
if (!Orgid.equals("-1"))
sql += " and BMBH='" + Orgid + "'";
String right = "";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next())//取得職務(wù)表權(quán)限
{
String czqx = ds.toString(rs.getString("LCQX"));
String bmbh = ds.toString(rs.getString("BMBH"));
String zwbh = ds.toString(rs.getString("ZWBH"));
if (czqx.equals(""))//當(dāng)職務(wù)表中權(quán)限為空時(shí),去部門(mén)職務(wù)表權(quán)限
{
sql = "select LCQX from news.ZZ_ZWB where BMBH='" + bmbh
+ "' and ZWBH=" + zwbh + " and ZWZT=0";
ResultSet rs_t = selectRecord(sql);
try {
if (rs_t.next())
czqx = ds.toString(rs_t.getString("LCQX"));
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs_t != null)
try {
stmt = rs_t.getStatement();
rs_t.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
}
if (!right.equals("") && !czqx.equals(""))
right += ",";
if (!czqx.equals(""))
right += czqx;
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
if (right.equals(""))//當(dāng)職務(wù)權(quán)限集合為空時(shí)查詢字典
{
rs = selectRecord("select MKBH from news.CODE_LCQXB where MRCZ=1 and SYZT=0");
try {
while (rs.next()) {
vect.add(rs.getString(1));
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
} else {
String str[] = ds.splitStr(right, ',');
for (int i = 0; i < str.length; i++) {
vect.add(str[i]);
}
}
return vect;
}
/** 是否有操作button對(duì)模塊mode的權(quán)限 */
public boolean isRightMode(String mode, String button) {
boolean bool = false;
ResultSet rs = selectRecord("select ID from news.CODE_ANCZQXB where MKMC='"
+ ds.toString(mode)
+ "' and ANMC='"
+ ds.toString(button)
+ "'");
String mkbh = "";
Statement stmt = null;
try {
if (rs.next()) {
mkbh = ds.toString(rs.getString("ID"));
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
Vector vect = getRightMode();
int index = vect.indexOf(mkbh);
if (index != -1)
bool = true;
return bool;
}
public boolean isRightFlow(String flow)//是否有操作流程flow的權(quán)限
{
boolean bool = false;
ResultSet rs = selectRecord("select MKBH from news.CODE_LCQXB where MKMC='"
+ ds.toString(flow) + "'");
String mkbh = "";
Statement stmt = null;
try {
if (rs.next()) {
mkbh = ds.toString(rs.getString("MKBH"));
}
} catch (Exception e) {
System.out.println("運(yùn)行時(shí)出錯(cuò):" + e);
} finally {
if (rs != null)
try {
stmt = rs.getStatement();
rs.close();
} catch (Exception e) {
System.out.println("關(guān)閉記錄集rs時(shí)出錯(cuò)" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("關(guān)閉聲明時(shí)statement出錯(cuò)" + e);
}
}
Vector vect = getRightFlow();
int index = vect.indexOf(mkbh);
if (index != -1)
bool = true;
return bool;
}
/** 機(jī)要權(quán)限 */
public Vector getRightConfidential() {
Vector vect = new Vector();
ResultSet rs = selectRecord("select CKQX from news.ZZ_BMB where BMBH ='"
+ Orgid + "'");
String right = "";
Statement stmt = null;
try {
if (rs.next())
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -