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 8c3baca..d790d22 100644 --- a/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java +++ b/project/src/main/java/cyou/chenx221/dao/impl/AdminDaoImpl.java @@ -2,37 +2,47 @@ package cyou.chenx221.dao.impl; import cyou.chenx221.dao.AdminDao; import cyou.chenx221.modal.Admin; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; import java.util.List; +@Repository public class AdminDaoImpl implements AdminDao { + private final SqlSession sqlSession; + + public AdminDaoImpl(SqlSession sqlSession) { + this.sqlSession = sqlSession; + } + @Override public void addAdmin(Admin admin) { - + sqlSession.insert("AdminMapper.addAdmin", admin); } @Override public void updateAdmin(Admin admin) { - + sqlSession.update("AdminMapper.updateAdmin", admin); } @Override public void deleteAdmin(int adminId) { - + sqlSession.delete("AdminMapper.deleteAdmin", adminId); } @Override public Admin getAdminById(int adminId) { - return null; + return sqlSession.selectOne("AdminMapper.getAdminById", adminId); } @Override public Admin getAdminByUsername(String username) { - return null; + return sqlSession.selectOne("AdminMapper.getAdminByUsername", username); } @Override public List getAllAdmins() { - return null; + return sqlSession.selectList("AdminMapper.getAllAdmins"); } } 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 ff52e1b..c6e857a 100644 --- a/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java +++ b/project/src/main/java/cyou/chenx221/dao/impl/ScoreDaoImpl.java @@ -2,42 +2,51 @@ package cyou.chenx221.dao.impl; import cyou.chenx221.dao.ScoreDao; import cyou.chenx221.modal.Score; +import org.apache.ibatis.session.SqlSession; +import org.springframework.stereotype.Repository; import java.util.List; +@Repository public class ScoreDaoImpl implements ScoreDao { + private final SqlSession sqlSession; + + public ScoreDaoImpl(SqlSession sqlSession) { + this.sqlSession = sqlSession; + } + @Override public void addScore(Score score) { - + sqlSession.insert("ScoreMapper.addScore", score); } @Override public void updateScore(Score score) { - + sqlSession.update("ScoreMapper.updateScore", score); } @Override public void deleteScore(int scoreId) { - + sqlSession.delete("ScoreMapper.deleteScore", scoreId); } @Override public Score getScoreById(int scoreId) { - return null; + return sqlSession.selectOne("ScoreMapper.getScoreById", scoreId); } @Override public List getScoresByStudentId(int studentId) { - return null; + return sqlSession.selectList("ScoreMapper.getScoresByStudentId", studentId); } @Override public List getScoresByCourse(String course) { - return null; + return sqlSession.selectList("ScoreMapper.getScoresByCourse", course); } @Override public List getAllScores() { - return null; + return sqlSession.selectList("ScoreMapper.getAllScores"); } }