This commit is contained in:
Chenx221 2023-06-02 13:43:10 +08:00
parent dfb6c67a5a
commit e35b270ada
6 changed files with 139 additions and 0 deletions

View File

@ -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<Admin> getAllAdmins();
}

View File

@ -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<Score> getScoresByStudentId(int studentId);
//根据课程名称从数据库中获取该课程的所有成绩列表
List<Score> getScoresByCourse(String course);
//获取数据库中所有的成绩对象并以列表形式返回
List<Score> getAllScores();
}

View File

@ -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<Student> getAllStudents();
}

View File

@ -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<Admin> getAllAdmins() {
return null;
}
}

View File

@ -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<Score> getScoresByStudentId(int studentId) {
return null;
}
@Override
public List<Score> getScoresByCourse(String course) {
return null;
}
@Override
public List<Score> getAllScores() {
return null;
}
}

View File

@ -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<Student> getAllStudents() {
return sqlSession.selectList("StudentMapper.getAllStudents");
}
}