From bcae200f37ba68543b3f013e36e668db5b672db2 Mon Sep 17 00:00:00 2001 From: SCDR Date: Wed, 9 Jun 2021 20:28:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0service=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=20findStudentByClassNumberAndDepartment=20?= =?UTF-8?q?=E5=92=8C=20addStudent=20=E6=A8=A1=E5=9D=97=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=B1=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../service/impl/StudentServiceImpl.java | 32 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 1e23d89..2a824a2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/edu/tyut/selaba2/student/service/impl/StudentServiceImpl.java b/src/edu/tyut/selaba2/student/service/impl/StudentServiceImpl.java index a62100a..8c6f9b2 100644 --- a/src/edu/tyut/selaba2/student/service/impl/StudentServiceImpl.java +++ b/src/edu/tyut/selaba2/student/service/impl/StudentServiceImpl.java @@ -7,15 +7,13 @@ import edu.tyut.selaba2.student.service.StudentService; import java.util.List; public class StudentServiceImpl implements StudentService { - StudentRepository studentRepository; + private final StudentRepository studentRepository; StudentServiceImpl(StudentRepository studentRepository){ this.studentRepository=studentRepository; } @Override - public Student getStudentById(Long uid) { - return null; - } + public Student getStudentById(Long uid) { return null; } @Override public List findStudentByName(String name) { @@ -23,13 +21,31 @@ public class StudentServiceImpl implements StudentService { } @Override - public List findStudentByClassNumberAndDepartment(Integer classNumber, String department) { - return null; + public List findStudentByClassNumberAndDepartment(Integer classNumber, String department) { //@liaoyu + + //设置学生信息 + Student student = new Student(); + student.setClassNumber(classNumber); + student.setDepartment(department); + + //通过studentRepository接口的findStudentByExample()查找. + List findSt = studentRepository.findStudentByExample(student); + + return findSt; } @Override - public Boolean addStudent(Student student) { - return null; + public Boolean addStudent(Student student) { // @liaoyu + + //如果学生的Uid存在,则返回false + if(student.getUid()!=null){ + return false; + } + + //插入学生信息.并返回true. + studentRepository.insert(student); + + return true; } @Override -- Gitee