|
|
@ -47,7 +47,7 @@ public class ExperimentalClassService { |
|
|
|
return resp; |
|
|
|
return resp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//实验班级删除学生
|
|
|
|
//实验班级删除学生
|
|
|
|
public HashMap<String, Object> experimentClassDeleteStudent(List<Student> student){ |
|
|
|
public HashMap<String, Object> experimentClassDeleteStudent(List<Student> student){ |
|
|
|
HashMap<String, Object> resp = new HashMap<String, Object>(); |
|
|
|
HashMap<String, Object> resp = new HashMap<String, Object>(); |
|
|
|
try { |
|
|
|
try { |
|
|
@ -155,63 +155,7 @@ public class ExperimentalClassService { |
|
|
|
} |
|
|
|
} |
|
|
|
return resp; |
|
|
|
return resp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//新增学生
|
|
|
|
|
|
|
|
public HashMap<String, Object> addStudent(ExperimentalClassVo vo){ |
|
|
|
|
|
|
|
HashMap<String, Object> resp = new HashMap<String,Object>(); |
|
|
|
|
|
|
|
ExperimentalClass experimentalClass=vo.getExperimentalClass(); |
|
|
|
|
|
|
|
List<Student> studeList=vo.getStudentList(); |
|
|
|
|
|
|
|
//存储班级原有的学生
|
|
|
|
|
|
|
|
List<Integer> oldstudeId=new ArrayList<Integer>(); |
|
|
|
|
|
|
|
//新增的学生
|
|
|
|
|
|
|
|
List<Integer> newstudeId=new ArrayList<Integer>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Integer experimentalClassId=experimentalClass.getExperimentalClassId(); |
|
|
|
|
|
|
|
List<Student> students=experimentalClassMapper.querystudent(experimentalClassId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//取出学生id
|
|
|
|
|
|
|
|
for (Student student : students) { |
|
|
|
|
|
|
|
oldstudeId.add(student.getStudentId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//得到要添加的学生和要删除的学生
|
|
|
|
|
|
|
|
for (int i = 0; i < studeList.size(); i++) { |
|
|
|
|
|
|
|
Integer id=studeList.get(i).getStudentId(); |
|
|
|
|
|
|
|
if(oldstudeId.contains(id)) {//新增的学生如果在数据库中,则删除oldstudeId中的学生
|
|
|
|
|
|
|
|
studeList.remove(i); |
|
|
|
|
|
|
|
oldstudeId.remove(id); |
|
|
|
|
|
|
|
i--; |
|
|
|
|
|
|
|
}else {//新增的学生没有在数据库中,存储起来,在关系表中绑定
|
|
|
|
|
|
|
|
newstudeId.add(id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//在实验班级绑定新学生
|
|
|
|
|
|
|
|
if(!newstudeId.isEmpty()&&newstudeId.size()>0) { |
|
|
|
|
|
|
|
for (int i=0;i<newstudeId.size();i++) { |
|
|
|
|
|
|
|
Student student=new Student(); |
|
|
|
|
|
|
|
student.setStudentId(newstudeId.get(i)); |
|
|
|
|
|
|
|
student.setIntExperimentalClassId(experimentalClassId); |
|
|
|
|
|
|
|
experimentalClassMapper.experimentClassAddStudent(student); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//删除学生
|
|
|
|
|
|
|
|
if(!oldstudeId.isEmpty()&&newstudeId.size()>0) { |
|
|
|
|
|
|
|
for (int i=0;i<oldstudeId.size();i++) { |
|
|
|
|
|
|
|
Student student=new Student(); |
|
|
|
|
|
|
|
student.setStudentId(oldstudeId.get(i)); |
|
|
|
|
|
|
|
student.setIntExperimentalClassId(experimentalClassId); |
|
|
|
|
|
|
|
experimentalClassMapper.experimentClassDeleteStudent(student); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resp.put("retcode", 200); |
|
|
|
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
|
|
|
resp.put("retcode", 500); |
|
|
|
|
|
|
|
resp.put("retvalue", "Inquiry Failed"); |
|
|
|
|
|
|
|
return resp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新增学生显示数据
|
|
|
|
//新增学生显示数据
|
|
|
|
public HashMap<String, Object> queryexperimentalClass(Integer experimentalClassId){ |
|
|
|
public HashMap<String, Object> queryexperimentalClass(Integer experimentalClassId){ |
|
|
|