From 55a124bd88a17b6145a214bbf5202243d1985c9a Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Fri, 2 Jun 2023 14:02:05 +0800 Subject: [PATCH] up --- .../cyou/chenx221/service/AdminService.java | 15 ++++++ .../cyou/chenx221/service/ScoreService.java | 15 ++++++ .../cyou/chenx221/service/StudentService.java | 13 +++++ .../service/impl/AdminServiceImpl.java | 50 +++++++++++++++++++ .../service/impl/ScoreServiceImpl.java | 50 +++++++++++++++++++ .../service/impl/StudentServiceImpl.java | 46 +++++++++++++++++ 6 files changed, 189 insertions(+) create mode 100644 project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java create mode 100644 project/src/main/java/cyou/chenx221/service/impl/ScoreServiceImpl.java create mode 100644 project/src/main/java/cyou/chenx221/service/impl/StudentServiceImpl.java diff --git a/project/src/main/java/cyou/chenx221/service/AdminService.java b/project/src/main/java/cyou/chenx221/service/AdminService.java index 652d37d..7a73e04 100644 --- a/project/src/main/java/cyou/chenx221/service/AdminService.java +++ b/project/src/main/java/cyou/chenx221/service/AdminService.java @@ -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 getAllAdmins(); } diff --git a/project/src/main/java/cyou/chenx221/service/ScoreService.java b/project/src/main/java/cyou/chenx221/service/ScoreService.java index 406ecd0..a5d9a28 100644 --- a/project/src/main/java/cyou/chenx221/service/ScoreService.java +++ b/project/src/main/java/cyou/chenx221/service/ScoreService.java @@ -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 getScoresByStudentId(int studentId); + + List getAllScores(); } diff --git a/project/src/main/java/cyou/chenx221/service/StudentService.java b/project/src/main/java/cyou/chenx221/service/StudentService.java index aafa98a..f56e8f4 100644 --- a/project/src/main/java/cyou/chenx221/service/StudentService.java +++ b/project/src/main/java/cyou/chenx221/service/StudentService.java @@ -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 getAllStudents(); } diff --git a/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java b/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java new file mode 100644 index 0000000..5ff76ec --- /dev/null +++ b/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java @@ -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 getAllAdmins() { + return adminDao.getAllAdmins(); + } +} diff --git a/project/src/main/java/cyou/chenx221/service/impl/ScoreServiceImpl.java b/project/src/main/java/cyou/chenx221/service/impl/ScoreServiceImpl.java new file mode 100644 index 0000000..b8f5211 --- /dev/null +++ b/project/src/main/java/cyou/chenx221/service/impl/ScoreServiceImpl.java @@ -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 getScoresByStudentId(int studentId) { + return scoreDao.getScoresByStudentId(studentId); + } + + @Override + public List getAllScores() { + return scoreDao.getAllScores(); + } +} diff --git a/project/src/main/java/cyou/chenx221/service/impl/StudentServiceImpl.java b/project/src/main/java/cyou/chenx221/service/impl/StudentServiceImpl.java new file mode 100644 index 0000000..d937b53 --- /dev/null +++ b/project/src/main/java/cyou/chenx221/service/impl/StudentServiceImpl.java @@ -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 getAllStudents() { + return studentDao.getAllStudents(); + } +} +