|
|
@@ -7,13 +7,12 @@ import com.usoftchina.smartschool.school.dto.DocBaseDTO;
|
|
|
import com.usoftchina.smartschool.school.exception.BizExceptionCode;
|
|
|
import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
|
|
|
import com.usoftchina.smartschool.school.mapper.SysStudentMapper;
|
|
|
-import com.usoftchina.smartschool.school.po.ClassForm;
|
|
|
-import com.usoftchina.smartschool.school.po.SysClazz;
|
|
|
-import com.usoftchina.smartschool.school.po.SysStudent;
|
|
|
-import com.usoftchina.smartschool.school.po.TeacherDetail;
|
|
|
+import com.usoftchina.smartschool.school.po.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -52,8 +51,52 @@ public class ClassServiceImpl implements ClassService{
|
|
|
}
|
|
|
SysClazz clazz = formdata.getMain();
|
|
|
List<SysStudent> students = formdata.getItems1();
|
|
|
+ Long id = clazz.getClazz_id();
|
|
|
+ Long school_id = BaseContextHolder.getSchoolId();
|
|
|
+ school_id = 1l;
|
|
|
|
|
|
- return null;
|
|
|
+ //插入从表数据
|
|
|
+ List<SysStudent> insertDetails = new ArrayList<>();
|
|
|
+ //更新从表数据
|
|
|
+ List<SysStudent> updateDetails = new ArrayList<>();
|
|
|
+ //新增
|
|
|
+ if (StringUtils.isEmpty(id) || "0".equals(id.toString())) {
|
|
|
+ clazz.setClazz_status(1);
|
|
|
+ sysClazzMapper.insertSelective(clazz);
|
|
|
+ for (SysStudent student : students) {
|
|
|
+ student.setClazz_id(clazz.getClazz_id());
|
|
|
+ student.setStu_status(1);
|
|
|
+ student.setSchool_id(school_id);
|
|
|
+ sysStudentMapper.insertSelective(student);
|
|
|
+ }
|
|
|
+ return new DocBaseDTO(clazz.getClazz_id());
|
|
|
+ }
|
|
|
+ //更新
|
|
|
+ sysClazzMapper.updateByPrimaryKeySelective(clazz);
|
|
|
+ //更新明细
|
|
|
+ for (SysStudent detail : students) {
|
|
|
+ detail.setClazz_id(clazz.getClazz_id());
|
|
|
+ if (StringUtils.isEmpty(detail.getStu_id()) || "0".equals(detail.getStu_id().toString())) {
|
|
|
+ insertDetails.add(detail);
|
|
|
+ } else {
|
|
|
+ updateDetails.add(detail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //插入从表
|
|
|
+ if (insertDetails.size() > 0) {
|
|
|
+ Long pr_id = null;
|
|
|
+ for (SysStudent item : insertDetails) {
|
|
|
+ item.setSchool_id(school_id);
|
|
|
+ sysStudentMapper.insertSelective(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //更新从表
|
|
|
+ if (updateDetails.size() > 0) {
|
|
|
+ for (SysStudent item : updateDetails) {
|
|
|
+ sysStudentMapper.updateByPrimaryKeySelective(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new DocBaseDTO(clazz.getClazz_id());
|
|
|
}
|
|
|
|
|
|
@Override
|