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

📄 operserviceimpl.java

📁 一个关于短信的java程序,非常适合java程序员,谢谢大家
💻 JAVA
字号:
/**
 * 
 */
package com.chinatech.cpmanage.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.chinatech.cpmanage.common.BusinessException;
import com.chinatech.cpmanage.common.DAOException;
import com.chinatech.cpmanage.dao.FuncDAO;
import com.chinatech.cpmanage.dao.OperDAO;
import com.chinatech.cpmanage.dao.OperLogDAO;
import com.chinatech.cpmanage.dao.PermissionDAO;
import com.chinatech.cpmanage.dao.RoleDAO;
import com.chinatech.cpmanage.dao.ZoneDAO;
import com.chinatech.cpmanage.dto.LoginDTO;
import com.chinatech.cpmanage.dto.OperDTO;
import com.chinatech.cpmanage.hibernate.CpmanageFunction;
import com.chinatech.cpmanage.hibernate.CpmanageOperator;
import com.chinatech.cpmanage.hibernate.CpmanageOperatorLog;
import com.chinatech.cpmanage.hibernate.CpmanagePermission;
import com.chinatech.cpmanage.hibernate.CpmanageRole;
import com.chinatech.cpmanage.hibernate.NyxxwZone;
import com.chinatech.cpmanage.service.OperService;
import org.infosys.util.ParamUtil;

/**
 * @author LiYang
 *
 */
public class OperServiceImpl implements OperService {

	/* (非 Javadoc)
	 * @see com.chinatech.cpmanage.service.OperService#addOper(com.chinatech.cpmanage.hibernate.CpmanageOperator)
	 */
	
	private OperDAO operDAO;
	
	private PermissionDAO permissionDAO;
	
	private ZoneDAO zoneDAO;
	
	private FuncDAO funcDAO;
	
	private RoleDAO roleDAO;
	
	private OperLogDAO operLogDAO;
	
	public void setOperDAO(OperDAO operDAO){
		this.operDAO = operDAO;
	}
	
	public void setPermissionDAO(PermissionDAO permissionDAO){
		this.permissionDAO = permissionDAO;
	}
	
	public void setZoneDAO(ZoneDAO zoneDAO){
		this.zoneDAO = zoneDAO;
	}
	
	public void setFuncDAO(FuncDAO funcDAO){
		this.funcDAO = funcDAO;
	}
	
	public void setRoleDAO(RoleDAO roleDAO){
		this.roleDAO = roleDAO;
	}
	
	public void setOperLogDAO(OperLogDAO operLogDAO){
		this.operLogDAO = operLogDAO;
	}
	
	public void addOper(CpmanageOperator co) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			operDAO.insertOper(co);
		}catch(DAOException e){
			throw new BusinessException("addOper方法出错!");
		}
	}

	public LoginDTO getOper(String operName, String pwd) throws BusinessException {
		// TODO 自动生成方法存根
		LoginDTO loginDTO = new LoginDTO();
		try{
			CpmanageOperator co = operDAO.getOPerByOperNamePwd(operName,pwd);
			if(co == null){
				return null;
			}
			loginDTO.setUserID(co.getId());
			loginDTO.setUserName(co.getOperName());
			loginDTO.setUserPass(co.getPwd());
			loginDTO.setUserArea(co.getAreaId());
			loginDTO.setUserStatus(co.getStatus());
			loginDTO.setIsSp(co.getIsSp());
			loginDTO.setOrdreNum(co.getOrderNum());
			loginDTO.setRoleID(co.getCpmanageRole().getId());
			loginDTO.setRoleName(co.getCpmanageRole().getName());
			loginDTO.setRoleArea(co.getCpmanageRole().getAreaId());
		}catch(DAOException e){
			throw new BusinessException("getOper方法出错!" + e.getMessage());
		}
		return loginDTO;
	}
	
	public String getXmlStr(String parentID,HttpServletRequest request) throws BusinessException{
		StringBuffer responseXml = new StringBuffer();
		if(parentID == null){
			parentID = "0";
		}else{
			parentID.trim();
		}
		int servPathLen=request.getServletPath().length();
		String uriStr=request.getRequestURI();
		String folderUrl=(uriStr).substring(0,uriStr.length()-servPathLen);  //服务器部署文件夹补偿地址
		responseXml.append("<?xml version='1.0' encoding='GBK'?>\n");
		responseXml.append("<xml>\n");
		
		LoginDTO loginDTO = (LoginDTO)request.getSession().getAttribute("loginDTO");
		if(loginDTO != null){
			String roleID = loginDTO.getRoleID();
			try{
				List list = permissionDAO.getFuncByRoleID(roleID,parentID);
				if(list != null && list.size()>0){
					CpmanagePermission cmp = new CpmanagePermission();
					int childCount = 0;
					for(int i=0;i<list.size();i++){
						cmp = (CpmanagePermission)list.get(i);
						responseXml.append("<TreeNode id='");
						responseXml.append(cmp.getCpmanageFunction().getId());
						responseXml.append("'>\n");
						responseXml.append("<NodeText>");
						responseXml.append(cmp.getCpmanageFunction().getName());
						responseXml.append("</NodeText>\n");
						responseXml.append("<title>");
						responseXml.append(cmp.getCpmanageFunction().getName());
						responseXml.append("</title>\n");
						childCount = funcDAO.getFuncCountByParentID(cmp.getCpmanageFunction().getId());
						responseXml.append("<child>");
						responseXml.append(childCount);
						responseXml.append("</child>\n");
						if(childCount > 0){
							responseXml.append("<NodeUrl></NodeUrl>\n");
						}else{
							responseXml.append("<NodeUrl>");
							responseXml.append(folderUrl);
							if(cmp.getCpmanageFunction().getUrl() != null){
								responseXml.append(ParamUtil.XMLencode(cmp.getCpmanageFunction().getUrl()));
							}
							responseXml.append("</NodeUrl>\n");
						}
						responseXml.append("<target>mainFrame</target>\n");
					    responseXml.append("</TreeNode>\n");
					}
				}else{
					responseXml.append("<TreeNode id='xxxxx'>\n");
					responseXml.append("<NodeText>功能点被删除或者登录已经过期</NodeText>\n");
					responseXml.append("<title>没有登录系统或者登录过期</title>\n");
					responseXml.append("<child>0</child>\n");
					responseXml.append("<NodeUrl></NodeUrl>\n");
					responseXml.append("<target>self</target>\n");
				    responseXml.append("</TreeNode>\n");
				}
				if("0".equals(parentID)){
					responseXml.append("<TreeNode id='-1'>\n");
					responseXml.append("<NodeText>退出</NodeText>\n");
					responseXml.append("<title>退出</title>\n");
					responseXml.append("<child>0</child>\n");
					responseXml.append("<NodeUrl>login.do?actionFlag=loginOut</NodeUrl>\n");
					responseXml.append("<target>_parent</target>\n");
					responseXml.append("</TreeNode>\n");
				}
				responseXml.append("</xml>");
			}catch(DAOException e){
				e.printStackTrace();
				throw new BusinessException("getXmlStr方法出错!" + e.getMessage());
			}
		}
		
		return responseXml.toString();
	}

	public List getZoneByParentID(String parentID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return zoneDAO.getZoneByParentID(parentID);
		}catch(DAOException e){
			throw new BusinessException("getZoneByParentID方法出错!");
		}
	}

	public void addFunc(CpmanageFunction cf) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			funcDAO.insertFunc(cf);
		}catch(DAOException e){
			throw new BusinessException("addFunc方法出错!" + e.getMessage());
		}
	}

	public List getFunc(int startRow, int pageSize) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return funcDAO.getFunc(startRow, pageSize);
		}catch(DAOException e){
			throw new BusinessException("getFunc方法出错!" + e.getMessage());
		}
	}

	public int getFuncCount() throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return funcDAO.getFuncCount();
		}catch(DAOException e){
			throw new BusinessException("getFuncCount方法出错!" + e.getMessage());
		}
	}

	public void modifyFunc(CpmanageFunction cf) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			funcDAO.updateFunc(cf);
		}catch(DAOException e){
			throw new BusinessException("modifyFunc方法出错!" + e.getMessage());
		}
	}

	public CpmanageFunction getFuncByID(String ID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return funcDAO.getFuncByID(ID);
		}catch(DAOException e){
			throw new BusinessException("getFuncByID方法出错!" + e.getMessage());
		}
	}

	public List getFuncByParentID(String parentID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return funcDAO.getFuncByParentID(parentID);
		}catch(DAOException e){
			throw new BusinessException("getFuncByParentID方法出错!" + e.getMessage());
		}
	}
	public void removeFunc(CpmanageFunction cf) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			funcDAO.deleteFunc(cf);
		}catch(DAOException e){
			throw new BusinessException("removeFunc方法出错!" + e.getMessage());
		}
	}

	public void addRole(CpmanageRole cr) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			roleDAO.insertRole(cr);
		}catch(DAOException e){
			throw new BusinessException("addRole方法出错!" + e.getMessage());
		}
	}

	public List getRole() throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return roleDAO.getRole();
		}catch(DAOException e){
			throw new BusinessException("getRole方法出错!" + e.getMessage());
		}
	}

	public void modifyRole(CpmanageRole cr) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			roleDAO.updateRole(cr);
		}catch(DAOException e){
			throw new BusinessException("modifyRole方法出错!" + e.getMessage());
		}
	}

	public void removeRole(CpmanageRole cr) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			roleDAO.deleteRole(cr);
		}catch(DAOException e){
			throw new BusinessException("removeRole方法出错!" + e.getMessage());
		}
	}

	public boolean isHaveFunc(String roleID, String funcID) throws BusinessException {
		// TODO 自动生成方法存根
		boolean isHaveFunc = false;
		CpmanagePermission cp = new CpmanagePermission();
		
		try{
			List list = permissionDAO.getFuncByRoleID(roleID);
			if(list != null && list.size()>0){
				for(int i=0;i<list.size();i++){
					cp = (CpmanagePermission)list.get(i);
					if(cp.getCpmanageFunction().getId().equals(funcID)){
						isHaveFunc = true;
						break;
					}
				}
			}
		}catch(DAOException e){
			throw new BusinessException("isHaveFunc方法出错!" + e.getMessage());
		}
		
		return isHaveFunc;
	}

	public void addPermission(CpmanagePermission cp) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			permissionDAO.insertPermission(cp);
		}catch(DAOException e){
			throw new BusinessException("addPermission方法出错!" + e.getMessage());
		}
	}

	public CpmanageRole getRoleByID(String ID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return roleDAO.getRoleByID(ID);
		}catch(DAOException e){
			throw new BusinessException("getRoleByID方法出错!" + e.getMessage());
		}
	}

	public List getFuncByRoleID(String roleID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return permissionDAO.getFuncByRoleID(roleID);
		}catch(DAOException e){
			throw new BusinessException("getFuncByRoleID方法出错!" + e.getMessage());
		}
	}

	public void removePermission(CpmanagePermission cp) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			permissionDAO.deletePermission(cp);
		}catch(DAOException e){
			throw new BusinessException("removePermission方法出错!" + e.getMessage());
		}
	}

	public CpmanagePermission getPermByID(String ID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return permissionDAO.getPermByID(ID);
		}catch(DAOException e){
			throw new BusinessException("getPermByID方法出错!" + e.getMessage());
		}
	}

	public NyxxwZone getZoneByZone(String zone) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return zoneDAO.getZoneByZone(zone);		
		}catch(DAOException e){
			throw new BusinessException("getZoneByZone方法出错!" + e.getMessage());
		}
	}

	public List getOperPageByArea(String areaID, int startRow, int pageSize) throws BusinessException {
		// TODO 自动生成方法存根
		ArrayList list = new ArrayList();
		ArrayList returnList = new ArrayList();
		try{
			list = (ArrayList)operDAO.getOperPageByArea(areaID, startRow, pageSize);
			if(list != null && list.size()>0){
				for(int i=0;i<list.size();i++){
					OperDTO operDTO = new OperDTO();
					CpmanageOperator co = new CpmanageOperator();
					co = (CpmanageOperator)list.get(i);
					operDTO.setId(co.getId());
					operDTO.setOperName(co.getOperName());
					operDTO.setPwd(co.getPwd());
					operDTO.setAreaId(co.getAreaId());
					NyxxwZone nyxxwZone = new NyxxwZone();
					nyxxwZone = zoneDAO.getZoneByZone(co.getAreaId());
					operDTO.setAreaName(nyxxwZone.getArea());
					operDTO.setRemark(co.getRemark());
					operDTO.setStatus(co.getStatus());
					operDTO.setCr(co.getCpmanageRole());
					returnList.add(operDTO);
				}
			}
			return returnList;
		}catch(DAOException e){
			throw new BusinessException("getOperPageByArea方法出错!" + e.getMessage());
		}
	}

	public int getOperPageCountByArea(String areaID) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return operDAO.getOperPageCountByArea(areaID);
		}catch(DAOException e){
			throw new BusinessException("getOperPageCountByArea方法出错!" + e.getMessage());
		}
	}

	public CpmanageOperator getOperByID(String id) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			return operDAO.getOperById(id);
		}catch(DAOException e){
			throw new BusinessException("getOperByID方法出错!" + e.getMessage());
		}
	}

	public void removeOper(CpmanageOperator co) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			operDAO.deleteOper(co);
		}catch(DAOException e){
			throw new BusinessException("deleteOper方法出错!" + e.getMessage());
		}
	}

	public void modifyOper(CpmanageOperator co) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			operDAO.updateOper(co);
		}catch(DAOException e){
			throw new BusinessException("modifyOper方法出错!" + e.getMessage());
		}
	}

	public void addOperLog(CpmanageOperatorLog col) throws BusinessException {
		// TODO 自动生成方法存根
		try{
			operLogDAO.insertOperLog(col);
		}catch(DAOException e){
			throw new BusinessException("addOperLog方法出错!" + e.getMessage());
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -