This commit is contained in:
Chenx221 2023-06-02 13:48:11 +08:00
parent e35b270ada
commit f76e150542
2 changed files with 32 additions and 13 deletions

View File

@ -2,37 +2,47 @@ package cyou.chenx221.dao.impl;
import cyou.chenx221.dao.AdminDao; import cyou.chenx221.dao.AdminDao;
import cyou.chenx221.modal.Admin; 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; import java.util.List;
@Repository
public class AdminDaoImpl implements AdminDao { public class AdminDaoImpl implements AdminDao {
private final SqlSession sqlSession;
public AdminDaoImpl(SqlSession sqlSession) {
this.sqlSession = sqlSession;
}
@Override @Override
public void addAdmin(Admin admin) { public void addAdmin(Admin admin) {
sqlSession.insert("AdminMapper.addAdmin", admin);
} }
@Override @Override
public void updateAdmin(Admin admin) { public void updateAdmin(Admin admin) {
sqlSession.update("AdminMapper.updateAdmin", admin);
} }
@Override @Override
public void deleteAdmin(int adminId) { public void deleteAdmin(int adminId) {
sqlSession.delete("AdminMapper.deleteAdmin", adminId);
} }
@Override @Override
public Admin getAdminById(int adminId) { public Admin getAdminById(int adminId) {
return null; return sqlSession.selectOne("AdminMapper.getAdminById", adminId);
} }
@Override @Override
public Admin getAdminByUsername(String username) { public Admin getAdminByUsername(String username) {
return null; return sqlSession.selectOne("AdminMapper.getAdminByUsername", username);
} }
@Override @Override
public List<Admin> getAllAdmins() { public List<Admin> getAllAdmins() {
return null; return sqlSession.selectList("AdminMapper.getAllAdmins");
} }
} }

View File

@ -2,42 +2,51 @@ package cyou.chenx221.dao.impl;
import cyou.chenx221.dao.ScoreDao; import cyou.chenx221.dao.ScoreDao;
import cyou.chenx221.modal.Score; import cyou.chenx221.modal.Score;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@Repository
public class ScoreDaoImpl implements ScoreDao { public class ScoreDaoImpl implements ScoreDao {
private final SqlSession sqlSession;
public ScoreDaoImpl(SqlSession sqlSession) {
this.sqlSession = sqlSession;
}
@Override @Override
public void addScore(Score score) { public void addScore(Score score) {
sqlSession.insert("ScoreMapper.addScore", score);
} }
@Override @Override
public void updateScore(Score score) { public void updateScore(Score score) {
sqlSession.update("ScoreMapper.updateScore", score);
} }
@Override @Override
public void deleteScore(int scoreId) { public void deleteScore(int scoreId) {
sqlSession.delete("ScoreMapper.deleteScore", scoreId);
} }
@Override @Override
public Score getScoreById(int scoreId) { public Score getScoreById(int scoreId) {
return null; return sqlSession.selectOne("ScoreMapper.getScoreById", scoreId);
} }
@Override @Override
public List<Score> getScoresByStudentId(int studentId) { public List<Score> getScoresByStudentId(int studentId) {
return null; return sqlSession.selectList("ScoreMapper.getScoresByStudentId", studentId);
} }
@Override @Override
public List<Score> getScoresByCourse(String course) { public List<Score> getScoresByCourse(String course) {
return null; return sqlSession.selectList("ScoreMapper.getScoresByCourse", course);
} }
@Override @Override
public List<Score> getAllScores() { public List<Score> getAllScores() {
return null; return sqlSession.selectList("ScoreMapper.getAllScores");
} }
} }