数据库中有三张表,分别是STUDENTS,TEACHER,COURSE
DAO层接口设计:
Interface StudentDAO
{
public void InsertStudent(Student stu) ;
public void removeStudent(long id) ;
public void updateStudent(Student stu) ;
public Student findStudent(long id) ;
/**
*其它DAO方法
**/
}
Interface TeacherDAO
{
public void insertTeacher(Teacher tea);
public void removeTeacher(long id) ;
public void updateTeacher(Teacher tea) ;
public Teacher findTeacher(long id) ;
/**
*其它DAO方法
**/
}
Interface CourseDAO
{
public void insertCourse(Course c);
public void removeCourse(long id) ;
public void updateCourse(Course c) ;
public Teacher findCourse(long id) ;
/**
*其它DAO方法
**/
}
业务层接口设计:
Interface StudentService
{
public void saveStudent(Student stu) ;
public void deleteStudent(long id) ;
public void updateStudent(Student stu) ;
public Student getStudent(long id) ;
/**
*其它Service方法
**/
}
Interface TeacherService
{
public void saveTeacher(Teacher tea);
public void deleteTeacher(long id) ;
public void updateTeacher(Teacher tea) ;
public Teacher getTeacher(long id) ;
/**
*其它Service方法
**/
}
Interface CourseService
{
public void saveCourse(Course c);
public void deleteCourse(long id) ;
public void updateCourse(Course c) ;
public Teacher getCourse(long id) ;
/**
*其它Service方法
**/
}
将这两层接口写好后分别创建它们的实现类,比如:
public class StudentDAOImpl implements StudentDAO ;
public class StudentServiceImpl implements StudentService;
其中StudentServiceImpl中的方法调用StudentDAOImpl中的接口方法
DAO层接口设计:
Interface StudentDAO
{
public void InsertStudent(Student stu) ;
public void removeStudent(long id) ;
public void updateStudent(Student stu) ;
public Student findStudent(long id) ;
/**
*其它DAO方法
**/
}
Interface TeacherDAO
{
public void insertTeacher(Teacher tea);
public void removeTeacher(long id) ;
public void updateTeacher(Teacher tea) ;
public Teacher findTeacher(long id) ;
/**
*其它DAO方法
**/
}
Interface CourseDAO
{
public void insertCourse(Course c);
public void removeCourse(long id) ;
public void updateCourse(Course c) ;
public Teacher findCourse(long id) ;
/**
*其它DAO方法
**/
}
业务层接口设计:
Interface StudentService
{
public void saveStudent(Student stu) ;
public void deleteStudent(long id) ;
public void updateStudent(Student stu) ;
public Student getStudent(long id) ;
/**
*其它Service方法
**/
}
Interface TeacherService
{
public void saveTeacher(Teacher tea);
public void deleteTeacher(long id) ;
public void updateTeacher(Teacher tea) ;
public Teacher getTeacher(long id) ;
/**
*其它Service方法
**/
}
Interface CourseService
{
public void saveCourse(Course c);
public void deleteCourse(long id) ;
public void updateCourse(Course c) ;
public Teacher getCourse(long id) ;
/**
*其它Service方法
**/
}
将这两层接口写好后分别创建它们的实现类,比如:
public class StudentDAOImpl implements StudentDAO ;
public class StudentServiceImpl implements StudentService;
其中StudentServiceImpl中的方法调用StudentDAOImpl中的接口方法