?? rightinfo.java
字號:
package com.saas.biz.rightMgr;
import java.util.*;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.saas.biz.JavaScriptObject.TreeNode;
import com.saas.biz.JavaScriptObject.TreeObject;
import com.saas.biz.dao.rightsDAO.*;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import net.sf.json.JSONArray;
public class RightInfo{
Dbtable tradeQuery;
Logger log;
Buffers inBuffer;
Buffers outBuffer;
ArrayList queryResult = new ArrayList();
public RightInfo() {
log = new Logger(this);
tradeQuery = new Dbtable();
}
public void setTradeQuery(Dbtable tradeQuery) {
this.tradeQuery = tradeQuery;
}
public Dbtable getTradeQuery() {
return this.tradeQuery;
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
public Buffers getOutBuffer() {
return this.outBuffer;
}
public ArrayList getQueryResult() {
return this.queryResult;
}
public void setQueryResult(ArrayList queryResult) {
this.queryResult = queryResult;
}
/**
* 增加權限菜單
*/
public void addRightInfo(Buffers inbuffer) {
this.outBuffer = inbuffer;
log.LOG_INFO("進入addRightInfo方法...");
int iResult = -1;
try {
String start_Date = "";
String end_Date = "";
Calendar c = Calendar.getInstance();
start_Date = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()).toString();
c.add(Calendar.YEAR, 50);
end_Date = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()).toString();
String cust_class = inbuffer.getString("CLASS_CODE");
String menu_id = inbuffer.getString("MENU_ID");
RightinfoDAO rightDao = new RightinfoDAO();
rightDao.setCustClass(cust_class);
rightDao.setMenuId(menu_id);
rightDao.setStartDate(start_Date);
rightDao.setInDate(start_Date);
rightDao.setEndDate(end_Date);
iResult = addRightInfo(rightDao);
}
catch (SaasApplicationException e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失敗!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出addRightInfo方法...");
}
public int addRightInfo(RightinfoDAO rightDao) throws SaasApplicationException {
RightinfoExt menuExt = new RightinfoExt();
menuExt.setParam(":VCUST_CLASS", rightDao.getCustClass());
menuExt.setParam(":VMENU_ID", rightDao.getMenuId());
menuExt.setParam(":VSTART_DATE", rightDao.getStartDate());
menuExt.setParam(":VEND_DATE", rightDao.getEndDate());
menuExt.setParam(":VIN_DATE", rightDao.getInDate());
tradeQuery.executeBy(menuExt.insBy("DEL_BY_ONE"));
tradeQuery.executeBy(menuExt.insBy("INS_BY_ALL"));
return 0;
}
/**
* 刪除菜單
*
*/
public void deleteRight(Buffers inbuffer) {
this.outBuffer = inbuffer;
log.LOG_INFO("進入deleteRight方法...");
int iResult = -1;
try {
String cust_class = inbuffer.getString("CLASS_CODE");
String menu_id = inbuffer.getString("MENU_ID");
iResult = deleteRightInfo(menu_id, cust_class);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失敗!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出deleteRight方法...");
}
// 刪除菜單權限
public void deleteRightInfoByMenuIdx(Buffers inbuffer) {
this.outBuffer = inbuffer;
log.LOG_INFO("進入deleteRightInfoByMenuIdx方法...");
int iResult = -1;
try {
String cust_class = inbuffer.getString("CLASS_CODE");
String menu_id = inbuffer.getString("MENU_ID");
iResult = deleteRightInfo(menu_id, cust_class);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失敗!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出deleteRightInfoByMenuIdx方法...");
}
public int deleteRightInfoByIdx(String menu_id, String cust_class) throws SaasApplicationException {
log.LOG_INFO("進入deleteRightInfoByIdx方法.......");
try {
RightinfoExt menuExt = new RightinfoExt();
menuExt.setParam(":VCUST_CLASS", cust_class);
menuExt.setParam(":VMENU_ID", menu_id);
tradeQuery.executeBy(menuExt.insBy("DEL_BY_ONE"));
log.LOG_INFO("開始刪除菜單.......");
}
catch (Exception e) {
log.LOG_INFO("刪除菜單權限出錯......");
return -1;
}
log.LOG_INFO("退出deleteRightInfoByIdx方法.......");
return 0;
}
// 找出分配的菜單權限
public ArrayList getRightInfoByMenuId(String menu_id) throws SaasApplicationException {
RightinfoExt menuExt = new RightinfoExt();
ArrayList rigtlist = new ArrayList();
menuExt.setParam(":VMENU_ID", menu_id);
try {
rigtlist = menuExt.selByList("SEL_BY_MENUIDX");
}
catch (Exception e) {
return null;
}
return rigtlist;
}
/**
* @公用方法
*
* 遞歸刪除所有下級菜單和當前菜單
*
*/
private int deleteRightInfo(String up_Idx, String cust_class) {
log.LOG_INFO("進入deleteRightInfo方法.......");
try {
deleteRightInfoByIdx(up_Idx, cust_class);
log.LOG_INFO("刪除" + up_Idx + "=====" + cust_class + "成功.......");
ArrayList listChd = getDownMenuByUP(up_Idx, cust_class);
if (listChd != null && listChd.size() > 0) {
for (int j = 0; j < listChd.size(); j++) {
HashMap map = (HashMap) listChd.get(j);
String up_menuIdx = map.get("menu_id").toString();
String up_custclass = map.get("cust_class").toString();
deleteRightInfo(up_menuIdx, up_custclass);
}
}
}
catch (Exception e) {
return -1;
}
return 0;
}
/**
* @公用方法
*
* 通過上級id找出下一級菜單
*/
public ArrayList getDownMenuByUP(String menu_id, String cust_class) throws SaasApplicationException {
log.LOG_INFO("進入獲取下級菜單........");
RightinfoExt menuExt = new RightinfoExt();
ArrayList infoList = new ArrayList();
try {
menuExt.setParam(":VCUST_CLASS", cust_class);
menuExt.setParam(":VMENU_ID", menu_id);
infoList = menuExt.selByList("SEL_MENUDOWN_BY_UP");
}
catch (Exception e) {
log.LOG_INFO("獲取下級菜單失敗........");
return null;
}
log.LOG_INFO("退出獲取下級菜單........" + infoList);
return infoList;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -