Browse Source

从表删除

zhaoy 7 years ago
parent
commit
f68257e498

+ 9 - 3
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/ScoreServiceImpl.java

@@ -112,6 +112,7 @@ public class ScoreServiceImpl implements ScoreService{
             throw new BizException(BizExceptionCode.EXISTS_TEACHER_CLASS);
         }
         scoreMapper.deleteByPrimaryKey(id);
+        scoreMapper.deleteByPrimaryDetailKey(id);
         messageLogService.delete(new DocBaseDTO(id, CODE, NAME));
     }
 
@@ -329,7 +330,6 @@ public class ScoreServiceImpl implements ScoreService{
             classId = sysClazz.getClazz_id();
             gradeId = sysClazz.getGrade_id();
         }
-        Long mId = main.getSi_id();
         if (null == main.getSi_id() || 0 == main.getSi_id()){
             main.setSi_date(new Date());
             main.setSi_creator(BaseContextHolder.getUserName());
@@ -353,11 +353,14 @@ public class ScoreServiceImpl implements ScoreService{
                             throw new BizException(BizExceptionCode.NONSTU);
                         }
                         SysStudent sysStudent = sysStudentMapper.selectByStudent(item.getSd_stu() ,classId,schoolId);
+                        if(sysStudent == null){
+                            throw new BizException(BizExceptionCode.NONSTUS);
+                        }
                         Long stuId = sysStudent.getStu_id();
                         item.setSd_stuid(stuId);
                     }
                     item.setSchool_id(schoolId);
-                    item.setSd_siid(mId);
+                    item.setSd_siid(main.getSi_id());
                     //插入从表
                     scoreMapper.insertScoreImportDetail(item);
                 }
@@ -382,11 +385,14 @@ public class ScoreServiceImpl implements ScoreService{
                             throw new BizException(BizExceptionCode.NONSTU);
                         }
                         SysStudent sysStudent = sysStudentMapper.selectByStudent(item.getSd_stu() ,classId,schoolId);
+                        if(sysStudent == null){
+                            throw new BizException(BizExceptionCode.NONSTUS);
+                        }
                         Long stuId = sysStudent.getStu_id();
                         item.setSd_stuid(stuId);
                     }
                     item.setSchool_id(schoolId);
-                    item.setSd_siid(mId);
+                    item.setSd_siid(main.getSi_id());
 
                     if(item.getSd_id() != null && 0 != item.getSd_id()) {
                         updateList.add(item);

+ 2 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java

@@ -17,7 +17,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     NONCLAZZ(500005, "班级名称不存在"),
     EXAM_SCOPE(5000014, "考试范围只有全年级和班级"),
     REPEAT_TEACHER_NUMBER(500006, "教师工号重复"),
-    NONSTU(500006, "学生不存在"),
+    NONSTU(500007, "学生不存在"),
+    NONSTUS(500008, "这个班没有这个学生"),
     EXISTS_TEACHER(500004,"存在任课教师,无法删除"),
     EXISTS_CURRICULUM(500005,"存在课表,无法删除"),
     EXISTS_TEACHER_CLASS(500006,"存在任课班级,无法删除"),

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/ScoreMapper.java

@@ -10,6 +10,8 @@ import java.util.List;
 public interface ScoreMapper {
     int deleteByPrimaryKey(Long score_id);
 
+    int deleteByPrimaryDetailKey(Long sd_siid);
+
     int insert(StuScoreDO record);
 
     int insertSelective(StuScoreDO record);

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/ScoreMapper.xml

@@ -31,6 +31,10 @@
     delete from Score_Import
     where si_id = #{si_id,jdbcType=BIGINT}
   </delete>
+  <delete id="deleteByPrimaryDetailKey" parameterType="java.lang.Long" >
+    delete from score_importdetail
+    where sd_siid = #{sd_siid,jdbcType=BIGINT}
+  </delete>
   <insert id="insert" parameterType="com.usoftchina.smartschool.school.po.StuScore" >
     insert into stu_score (score_id, score_type, score_name,
     stu_id, score_total, score_num,