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