⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rightinfo.java

📁 java阿里巴巴代码
💻 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 + -