Joburgess 5 年之前
父节点
当前提交
89c0eedc0a

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java

@@ -52,7 +52,7 @@ public class ExamSubjectSongController extends BaseController {
     @ApiOperation(value = "删除考试内容")
     @PostMapping(value = "del")
     public HttpResponseResult del(Long id) {
-        examSubjectSongService.delete(id);
+        examSubjectSongService.deleteExamSubjectSong(id);
         return succeed();
     }
 

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectDao.java

@@ -12,6 +12,8 @@ public interface ExamSubjectDao extends BaseDAO<Long, ExamSubject> {
 
     int batchInsert(@Param("examSubjects") List<ExamSubject> examSubjects);
 
+    int deleteWithExamSubject(@Param("examId") Long examId, @Param("subjectId") Integer subjectId);
+
     /**
      * @param examId: 考级项目编号
      * @return java.util.List<com.keao.edu.user.entity.ExamSubject>

+ 2 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectSongDao.java

@@ -2,7 +2,6 @@ package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.dto.ExamSubjectSongDto;
-import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.ExamSubjectSong;
 import org.apache.ibatis.annotations.Param;
 
@@ -43,4 +42,6 @@ public interface ExamSubjectSongDao extends BaseDAO<Long, ExamSubjectSong> {
     List<ExamSubjectSongDto> queryExamSubjectSongs(Map<String, Object> params);
     int countExamSubjectSongs(Map<String, Object> params);
 
+    int countExamSongsWithSubject(@Param("subjectId") Integer subjectId);
+
 }

+ 1 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamSubjectSongService.java

@@ -2,14 +2,12 @@ package com.keao.edu.user.service;
 
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
-import com.keao.edu.user.dao.ExamSubjectSongDao;
 import com.keao.edu.user.dto.ExamSubjectSongDto;
 import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.ExamSubjectSong;
 import com.keao.edu.user.page.ExamSubjectSongQueryInfo;
 
 import java.util.List;
-import java.util.Map;
 
 public interface ExamSubjectSongService extends BaseService<Long, ExamSubjectSong> {
 
@@ -24,6 +22,7 @@ public interface ExamSubjectSongService extends BaseService<Long, ExamSubjectSon
 
     PageInfo<ExamSubjectSongDto> queryExamSubjectSongs(ExamSubjectSongQueryInfo queryInfo);
 
+    void deleteExamSubjectSong(Long id);
 
     /**
      * 获取考试对应科目对应级别的曲目

+ 6 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java

@@ -177,7 +177,7 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 	}
 
 	@Override
-	public int delete(Long id) {
+	public void deleteExamSubjectSong(Long id) {
 		if(Objects.isNull(id)){
 			throw new BizException("参数错误");
 		}
@@ -193,7 +193,11 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 			&&!ExamStatusEnum.NOT_START.equals(examinationBasic.getStatus())){
 			throw new BizException("此状态无法删除");
 		}
-		return super.delete(id);
+		int i = examSubjectSongDao.countExamSongsWithSubject(examSubjectSong.getExamSubjectId().intValue());
+		examSubjectSongDao.delete(id);
+		if(i<=1){
+			examSubjectDao.deleteWithExamSubject(examSubjectSong.getExaminationBasicId().longValue(), examSubjectSong.getExamSubjectId().intValue());
+		}
 	}
 
 	@Override

+ 6 - 2
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectMapper.xml

@@ -62,8 +62,12 @@
 	<delete id="delete" >
 		DELETE FROM exam_subject WHERE id_ = #{id} 
 	</delete>
-	
-	<!-- 分页查询 -->
+
+    <delete id="deleteWithExamSubject">
+		DELETE FROM exam_subject WHERE examination_basic_id_=#{examId} AND subject_id_=#{subjectId}
+    </delete>
+
+    <!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamSubject" parameterType="map">
 		SELECT * FROM exam_subject ORDER BY id_
 		<include refid="global.limit"/>

+ 3 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml

@@ -162,4 +162,7 @@
 	<select id="getExamSubjectLevels" resultMap="ExamSubjectSong">
 		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} ORDER BY level_ ASC
 	</select>
+    <select id="countExamSongsWithSubject" resultType="int">
+		SELECT COUNT(id_) FROM exam_subject_song WHERE exam_subject_id_=#{subjectId}
+    </select>
 </mapper>