diff --git a/project/src/main/java/cyou/chenx221/dao/AdminDao.java b/project/src/main/java/cyou/chenx221/dao/AdminDao.java index cda2007..fddd440 100644 --- a/project/src/main/java/cyou/chenx221/dao/AdminDao.java +++ b/project/src/main/java/cyou/chenx221/dao/AdminDao.java @@ -1,4 +1,26 @@ package cyou.chenx221.dao; +import cyou.chenx221.modal.Admin; + +import java.util.List; + public interface AdminDao { + + //将给定的管理员对象添加到数据库中 + void addAdmin(Admin admin); + + //更新数据库中与给定管理员对象对应的记录 + void updateAdmin(Admin admin); + + //根据管理员ID从数据库中删除对应的记录 + void deleteAdmin(int adminId); + + //根据管理员ID从数据库中获取对应的管理员对象 + Admin getAdminById(int adminId); + + //根据管理员用户名从数据库中获取对应的管理员对象 + Admin getAdminByUsername(String username); + + //获取数据库中所有的管理员对象,并以列表形式返回 + List getAllAdmins(); } diff --git a/project/src/main/java/cyou/chenx221/dao/ScoreDao.java b/project/src/main/java/cyou/chenx221/dao/ScoreDao.java index 003bbaa..1bfa98e 100644 --- a/project/src/main/java/cyou/chenx221/dao/ScoreDao.java +++ b/project/src/main/java/cyou/chenx221/dao/ScoreDao.java @@ -5,17 +5,24 @@ import cyou.chenx221.modal.Score; import java.util.List; public interface ScoreDao { + //将给定的成绩对象添加到数据库中 void addScore(Score score); + //更新数据库中与给定成绩对象对应的记录 void updateScore(Score score); + //根据成绩ID从数据库中删除对应的记录 void deleteScore(int scoreId); + //根据成绩ID从数据库中获取对应的成绩对象 Score getScoreById(int scoreId); + //根据学生ID从数据库中获取该学生的所有成绩列表 List getScoresByStudentId(int studentId); + //根据课程名称从数据库中获取该课程的所有成绩列表 List getScoresByCourse(String course); + //获取数据库中所有的成绩对象,并以列表形式返回 List getAllScores(); } diff --git a/project/src/main/java/cyou/chenx221/dao/StudentDao.java b/project/src/main/java/cyou/chenx221/dao/StudentDao.java index 0de50e0..15014cd 100644 --- a/project/src/main/java/cyou/chenx221/dao/StudentDao.java +++ b/project/src/main/java/cyou/chenx221/dao/StudentDao.java @@ -5,13 +5,18 @@ import cyou.chenx221.modal.Student; import java.util.List; public interface StudentDao { + //将给定的学生对象添加到数据库中 void addStudent(Student student); + //更新数据库中与给定学生对象对应的记录 void updateStudent(Student student); + //根据学生ID从数据库中删除对应的记录 void deleteStudent(int studentId); + //根据学生ID从数据库中获取对应的学生对象 Student getStudentById(int studentId); + //获取数据库中所有的学生对象,并以列表形式返回 List getAllStudents(); } diff --git a/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java b/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java index 96d2857..8c3baca 100644 --- a/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java +++ b/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java @@ -1,6 +1,38 @@ package cyou.chenx221.dao.impl; import cyou.chenx221.dao.AdminDao; +import cyou.chenx221.modal.Admin; + +import java.util.List; public class AdminDaoImpl implements AdminDao { + @Override + public void addAdmin(Admin admin) { + + } + + @Override + public void updateAdmin(Admin admin) { + + } + + @Override + public void deleteAdmin(int adminId) { + + } + + @Override + public Admin getAdminById(int adminId) { + return null; + } + + @Override + public Admin getAdminByUsername(String username) { + return null; + } + + @Override + public List getAllAdmins() { + return null; + } } diff --git a/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java b/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java index da4cefb..ff52e1b 100644 --- a/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java +++ b/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java @@ -1,6 +1,43 @@ package cyou.chenx221.dao.impl; import cyou.chenx221.dao.ScoreDao; +import cyou.chenx221.modal.Score; + +import java.util.List; public class ScoreDaoImpl implements ScoreDao { + @Override + public void addScore(Score score) { + + } + + @Override + public void updateScore(Score score) { + + } + + @Override + public void deleteScore(int scoreId) { + + } + + @Override + public Score getScoreById(int scoreId) { + return null; + } + + @Override + public List getScoresByStudentId(int studentId) { + return null; + } + + @Override + public List getScoresByCourse(String course) { + return null; + } + + @Override + public List getAllScores() { + return null; + } } diff --git a/project/src/main/java/cyou/chenx221/dao/impl/StudentDaoImpl.java b/project/src/main/java/cyou/chenx221/dao/impl/StudentDaoImpl.java index 73269b5..3e57511 100644 --- a/project/src/main/java/cyou/chenx221/dao/impl/StudentDaoImpl.java +++ b/project/src/main/java/cyou/chenx221/dao/impl/StudentDaoImpl.java @@ -1,6 +1,42 @@ package cyou.chenx221.dao.impl; import cyou.chenx221.dao.StudentDao; +import cyou.chenx221.modal.Student; +import org.apache.ibatis.session.SqlSession; +import org.springframework.stereotype.Repository; +import java.util.List; + +@Repository public class StudentDaoImpl implements StudentDao { + private final SqlSession sqlSession; + + public StudentDaoImpl(SqlSession sqlSession) { + this.sqlSession = sqlSession; + } + + @Override + public void addStudent(Student student) { + sqlSession.insert("StudentMapper.addStudent", student); + } + + @Override + public void updateStudent(Student student) { + sqlSession.update("StudentMapper.updateStudent", student); + } + + @Override + public void deleteStudent(int studentId) { + sqlSession.delete("StudentMapper.deleteStudent", studentId); + } + + @Override + public Student getStudentById(int studentId) { + return sqlSession.selectOne("StudentMapper.getStudentById", studentId); + } + + @Override + public List getAllStudents() { + return sqlSession.selectList("StudentMapper.getAllStudents"); + } }