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

📄 testpaperservice.java

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

import java.sql.SQLException;
import java.util.ArrayList;

import javax.sql.DataSource;

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

/**
 * 
 * @author 王小龙
 *
 */
public class TestPaperService extends Service {

	private IBaseDAO testPaperDAO;
	private IBaseDAO questionDAO;
	private IBaseDAO examineeDAO;
	private Boolean flag;

	public Object alllist() throws AppException {
		// TODO Auto-generated method stub
		return null;
	}

	public Object alllist(Object arg0) throws AppException {

		return null;
	}

	
	/**
	 * 根据规则自动生成试卷
	 */
	public Object create(Object arg0) throws AppException {
		testPaperDAO = DAOFactory.getTestPaperDAO(conn);
		examineeDAO = DAOFactory.getExamineeDAO(conn);
		ArrayList rulelist = null;
		ArrayList qlist = null;
		Object objs[] = new Object[2];
		try {
			rulelist = (ArrayList) testPaperDAO.findByObject(arg0);//得到试卷规则
			qlist =  (ArrayList) examineeDAO.findByObject(rulelist);//根据试卷规则得到不同类型的试题集
			objs[0] = arg0;
			objs[1] = qlist;
			flag = (Boolean) testPaperDAO.insert(objs);//生成试卷并将得到的试题插入到试卷中
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
			examineeDAO = null;
		}
		return flag;
	}

	public Object findAll() throws AppException {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * 查询试卷
	 */
	public Object findAll(Object arg0) throws AppException {
		testPaperDAO =DAOFactory.getTestPaperDAO(conn);
		Object obj[] = new Object[2];
		Object objs[] = new Object[2];
		ArrayList list = new ArrayList();
		
		try {
			obj = (Object[]) testPaperDAO.findAll(arg0);
			list = (ArrayList) testPaperDAO.findAll();
			objs[0] = obj;
			objs[1] = list;
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		return objs;
	}

	/**
	 * 根据ID得到试卷
	 */
	public Object findById(Object arg0) throws AppException {
		testPaperDAO = DAOFactory.getTestPaperDAO(conn);
		ArrayList list = new ArrayList();
		Object obj[] = new Object[2];
		
		try {
			obj = (Object[]) testPaperDAO.findById(arg0);
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		return obj;
	}

	/**
	 * 查看新建的试卷是否已存在
	 */
	public Object findByObject(Object arg0) throws AppException {
		testPaperDAO = DAOFactory.getTestPaperDAO(conn);
		examineeDAO = DAOFactory.getExamineeDAO(conn);

		Object objs[] = new Object[2];
		Object obj[] = null;
		int count;
		TestPaperDTO dto =  (TestPaperDTO) arg0;
		dto.setCurrentPage("1");
		dto.setPageSize("10");

		
		try {
			obj = (Object[]) testPaperDAO.findById(dto);
			objs[1] = examineeDAO.findById(dto.getTestPaper_Name());
			
			count = (Integer) obj[0];
			if(count>0){
				objs[0] = "true";
			}else{
				objs[0] = "false";
			}
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
			examineeDAO = null;
		}
		return objs;
	}

	public int getcount() throws AppException {
		// TODO Auto-generated method stub
		return 0;
	}

	public int getcount(Object arg0) throws AppException {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 得到所有的科目列表
	 */
	public Object list() throws AppException {
		testPaperDAO =DAOFactory.getTestPaperDAO(conn);
		ArrayList list = new ArrayList();
		try {
			list = (ArrayList) testPaperDAO.findAll();
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		return list;
	}

	/**
	 * 根据科目名得到该科目下的试卷规则列表
	 */
	public Object list(Object arg0) throws AppException {
		testPaperDAO =DAOFactory.getTestPaperDAO(conn);
		ArrayList list = new ArrayList();
		try {
			list = (ArrayList) testPaperDAO.find(arg0);
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		return list;
	}

	/**
	 * 得到试卷试题
	 */
	public Object load(Object arg0) throws AppException {
		questionDAO = DAOFactory.getQuestionDAO(conn);
		QuestionVO vo = new QuestionVO();
		
		try {
			vo = (QuestionVO) questionDAO.findById(arg0);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			this.closeConnection();
			questionDAO = null;
		}
		return vo;
	}

	/**
	 * 删除所选
	 */
	public Object modify(Object arg0) throws AppException {
		testPaperDAO = DAOFactory.getTestPaperDAO(conn);
		try {
			flag = (Boolean) testPaperDAO.update(arg0);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		
		return flag;
	}

	/**
	 * 删除指定ID试卷
	 */
	public Object remove(Object arg0) throws AppException {
		testPaperDAO = DAOFactory.getTestPaperDAO(conn);
		flag = false;
		
		try {
			flag = (Boolean) testPaperDAO.delete(arg0);
		} catch (SQLException e) {
			throw new AppException(e.getMessage());
		}finally{
			this.closeConnection();
			testPaperDAO = null;
		}
		return flag;
	}



}

⌨️ 快捷键说明

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