//package service; import dao.ScoreDAO; import entity.Score; /** * ScoreService:处理成绩相关业务逻辑 */ public class ScoreService { private ScoreDAO scoreDAO = new ScoreDAO(); // 添加成绩 public boolean addScore(Score score) { // 检查是否已有成绩记录 if (scoreDAO.getScore(score.getStudentId(), score.getCourseId()) != null) { return false; } return scoreDAO.addScore(score); } // 更新成绩 public boolean updateScore(Score score) { return scoreDAO.updateScore(score); } // 删除成绩记录 public boolean deleteScore(String studentId, String courseId) { return scoreDAO.deleteScore(studentId, courseId); } // 按学号和课程号获取成绩 public Score getScore(String studentId, String courseId) { return scoreDAO.getScore(studentId, courseId); } // 获取某学生的所有成绩 public java.util.List getScoresByStudent(String studentId) { return scoreDAO.getScoresByStudent(studentId); } // 获取所有成绩 public java.util.List getAllScores() { return scoreDAO.getAllScores(); } }