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

📄 testserviceimpl.java

📁 菲律宾的一个大学的图书管理系统 spring+hibernate+velocity
💻 JAVA
字号:
/*
 * 创建日期 2005-4-18
 */
package biz.bluesky.pts.service.impl;

import java.util.List;

import biz.bluesky.pts.model.TTest;
import biz.bluesky.pts.service.ITestService;
import biz.bluesky.pts.service.dao.ITestDAO;
import biz.bluesky.pts.util.ErrorCode;

import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.dao.DataAccessException;


public class TestServiceImpl implements ITestService {

    private ITestDAO testDAO;

    public ITestDAO getTestDAO() {
        return this.testDAO;
    }

    public void setTestDAO(ITestDAO testDAO) {
        this.testDAO = testDAO;
    }
    //根据测试编号查询测试
    public TTest findTest(int testId) {
        TTest test = null;
        try {
            test = testDAO.findTest(testId); 
        }
        catch(ObjectRetrievalFailureException excp) {
            
        }
        
        return test;
    }

    //根据教师编号测试名称查询测试
    public TTest findTest(String testType, int teacherId) {
        return testDAO.findTest(testType,teacherId);
    }

    //根据教师编号测试名称模糊查询测试
    public List findTests(String testType, int teacherId) {
        return testDAO.findTests(testType,teacherId);
    }

    //根据教师编号查询测试
    public List findTestsByTeacher(int teacherId) {
        return testDAO.findTestsByTeacher(teacherId);
    }

    //查询班级的测试
    public List findTestsByClass(int classId) {
        return testDAO.findTestByClass(classId);
    }
    
    //新增测试
    public int saveTest(TTest test) {
        if((test == null)||(test.getType() == "")) {
            return ErrorCode.ERR_TEST_EMPTY;
        }
               
        try {
            testDAO.saveTest(test);
        }
        catch(DataIntegrityViolationException excp) {
            return ErrorCode.ERR_TEST_REPEAT;
        }
        catch(DataAccessException excp) {
            return ErrorCode.ERR_UNKNOW;
        }
        
        return ErrorCode.ERR_UNDISCOVERED;
    }

    //删除测试
    public int removeTest(int testId) {
        try {
            testDAO.removeTest(testId);
        }
        catch(ObjectRetrievalFailureException excp) {
            return ErrorCode.ERR_TEST_NOT_FIND;
        }
        catch(DataAccessException excp) {
            return ErrorCode.ERR_UNKNOW;
        }
        
        return ErrorCode.ERR_UNDISCOVERED;
    }

}

⌨️ 快捷键说明

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