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

📄 departmentservice.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
字号:
package edu.yinhe.mis.services;

import java.sql.SQLException;

import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.IBaseDAO;
import edu.yinhe.system.services.Service;
import edu.yinhe.mis.dto.DepartmentDTO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.vo.DepartmentVO;


/**
 * @author 赵训福
 */
public class DepartmentService extends Service {
	
	

	IBaseDAO deptDAO=null;
	IBaseDAO dicDAO =null;
	@Override
	public Object alllist() throws AppException {
		// TODO Auto-generated method stub
		return super.alllist();
	}

	@Override
	public Object alllist(Object obj) throws AppException {
		// TODO Auto-generated method stub
		return super.alllist(obj);
	}

	/**
	 * 向department表中添加信息
	 * @throws AppException
	 * @param obj 传入DepartmentDTO对象
	 * @return flag 添加成功返回true。
	 */
	public Object create(Object obj) throws AppException {
		boolean flag=false;
		deptDAO =DAOFactory.getDepartmentDAO(conn);
		
		try {
			flag=(Boolean) deptDAO.insert(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
			}
		}finally{
			this.closeConnection();
			deptDAO = null;
		}
		return flag;
	}

	@Override
	public Object findAll() throws AppException {
		// TODO Auto-generated method stub
		return super.findAll();
	}

	/**
	 * 浏览department表中信息
	 * @throws AppException
	 * @param obj 传入DepartmentDTO对象
	 * @return objs 返回Object[]数组。
	 */
	public Object findAll(Object obj) throws AppException {
		Object[] objs = null;
	
		deptDAO =DAOFactory.getDepartmentDAO(conn);
		try {
			objs = (Object[]) deptDAO.findAll(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
			}
		}finally{
			this.closeConnection();
			deptDAO = null;
			
		}
		return objs;	
	}

	@Override
	public Object findById(Object obj) throws AppException {
		// TODO Auto-generated method stub
		return super.findById(obj);
	}

	@Override
	public Object findByObject(Object obj) throws AppException {
		// TODO Auto-generated method stub
		return super.findByObject(obj);
	}

	@Override
	public int getcount() throws AppException {
		// TODO Auto-generated method stub
		return super.getcount();
	}

	@Override
	public int getcount(Object obj) throws AppException {
		// TODO Auto-generated method stub
		return super.getcount(obj);
	}

	@Override
	public Object list() throws AppException {
		// TODO Auto-generated method stub
		return super.list();
	}

	/**
	 * 根据scope值查询数据字典中的数据
	 * @throws AppException
	 * @param obj DictionaryDTO对象
	 * @return objs 返回Object[]类型的数组集合。
	 */
	public Object list(Object obj) throws AppException {
		Object[] objs = null;
		dicDAO = DAOFactory.getDictionaryDAO(conn);
		try {
			objs = (Object[]) dicDAO.findAll(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
				
			}
		}finally{
			this.closeConnection();
			dicDAO=null;
		}
		return objs;
	}

	/**
	 * 根据ID获得一条记录的详细信息
	 * @throws AppException
	 * @param obj 传入DepartmentDTO对象
	 * @return dvo 返回department表中一条记录的对象
	 */
	public Object load(Object obj) throws AppException {
		DepartmentVO dvo = null;
		deptDAO =DAOFactory.getDepartmentDAO(conn);
		try {
			dvo = (DepartmentVO) deptDAO.findById(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
			}
		}finally{
			this.closeConnection();
			deptDAO = null;
		}
		return dvo;	
	}

	/**
	 * 修改一条记录的信息
	 * @throws AppException
	 * @param obj 传入DepartmentDTO对象
	 * @return flag 修改成功返回true
	 */
	public Object modify(Object obj) throws AppException {
		boolean flag=false;
		DepartmentDTO deptdto = (DepartmentDTO) obj;
		deptDAO =DAOFactory.getDepartmentDAO(conn);
		try {
			flag=(Boolean) deptDAO.update(deptdto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
			}
		}finally{
			this.closeConnection();
			deptDAO = null;
		}
		return flag;
	}

	/**
	 * 根据ID删除department表中的一条记录
	 * @throws AppException
	 * @param obj 传入DepartmentDTO对象
	 * @return flag 删除成功返回true
	 */
	public Object remove(Object obj) throws AppException{
		boolean flag=false;
		deptDAO =DAOFactory.getDepartmentDAO(conn);
		try {
			flag=(Boolean) deptDAO.delete(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				throw new AppException(e.getMessage()+"危险!");
			}
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			deptDAO = null;
		}
		return flag;
	}
}

⌨️ 快捷键说明

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