This commit is contained in:
Chenx221 2023-06-02 14:02:05 +08:00
parent f76e150542
commit 55a124bd88
6 changed files with 189 additions and 0 deletions

View File

@ -1,4 +1,19 @@
package cyou.chenx221.service;
import cyou.chenx221.modal.Admin;
import java.util.List;
public interface AdminService {
void addAdmin(Admin admin);
void updateAdmin(Admin admin);
void deleteAdmin(int adminId);
Admin getAdminById(int adminId);
Admin getAdminByUsername(String username);
List<Admin> getAllAdmins();
}

View File

@ -1,4 +1,19 @@
package cyou.chenx221.service;
import cyou.chenx221.modal.Score;
import java.util.List;
public interface ScoreService {
void addScore(Score score);
void updateScore(Score score);
void deleteScore(int scoreId);
Score getScoreById(int scoreId);
List<Score> getScoresByStudentId(int studentId);
List<Score> getAllScores();
}

View File

@ -1,4 +1,17 @@
package cyou.chenx221.service;
import cyou.chenx221.modal.Student;
import java.util.List;
public interface StudentService {
void addStudent(Student student);
void updateStudent(Student student);
void deleteStudent(int studentId);
Student getStudentById(int studentId);
List<Student> getAllStudents();
}

View File

@ -0,0 +1,50 @@
package cyou.chenx221.service.impl;
import cyou.chenx221.dao.AdminDao;
import cyou.chenx221.modal.Admin;
import cyou.chenx221.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {
private final AdminDao adminDao;
@Autowired
public AdminServiceImpl(AdminDao adminDao) {
this.adminDao = adminDao;
}
@Override
public void addAdmin(Admin admin) {
adminDao.addAdmin(admin);
}
@Override
public void updateAdmin(Admin admin) {
adminDao.updateAdmin(admin);
}
@Override
public void deleteAdmin(int adminId) {
adminDao.deleteAdmin(adminId);
}
@Override
public Admin getAdminById(int adminId) {
return adminDao.getAdminById(adminId);
}
@Override
public Admin getAdminByUsername(String username) {
return adminDao.getAdminByUsername(username);
}
@Override
public List<Admin> getAllAdmins() {
return adminDao.getAllAdmins();
}
}

View File

@ -0,0 +1,50 @@
package cyou.chenx221.service.impl;
import cyou.chenx221.dao.ScoreDao;
import cyou.chenx221.modal.Score;
import cyou.chenx221.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ScoreServiceImpl implements ScoreService {
private final ScoreDao scoreDao;
@Autowired
public ScoreServiceImpl(ScoreDao scoreDao) {
this.scoreDao = scoreDao;
}
@Override
public void addScore(Score score) {
scoreDao.addScore(score);
}
@Override
public void updateScore(Score score) {
scoreDao.updateScore(score);
}
@Override
public void deleteScore(int scoreId) {
scoreDao.deleteScore(scoreId);
}
@Override
public Score getScoreById(int scoreId) {
return scoreDao.getScoreById(scoreId);
}
@Override
public List<Score> getScoresByStudentId(int studentId) {
return scoreDao.getScoresByStudentId(studentId);
}
@Override
public List<Score> getAllScores() {
return scoreDao.getAllScores();
}
}

View File

@ -0,0 +1,46 @@
package cyou.chenx221.service.impl;
import cyou.chenx221.dao.StudentDao;
import cyou.chenx221.modal.Student;
import cyou.chenx221.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class StudentServiceImpl implements StudentService {
private final StudentDao studentDao;
@Autowired
public StudentServiceImpl(StudentDao studentDao) {
this.studentDao = studentDao;
}
@Override
public void addStudent(Student student) {
studentDao.addStudent(student);
}
@Override
public void updateStudent(Student student) {
studentDao.updateStudent(student);
}
@Override
public void deleteStudent(int studentId) {
studentDao.deleteStudent(studentId);
}
@Override
public Student getStudentById(int studentId) {
return studentDao.getStudentById(studentId);
}
@Override
public List<Student> getAllStudents() {
return studentDao.getAllStudents();
}
}