feat(class): 删除班级时验证是否存在学生
- 新增StudentDOMapper接口方法selectStudentCountByClassId,用于查询班级下学生数量 - 在ClassServiceImpl中注入StudentDOMapper - 删除班级时先判断班级下是否存在学生,若存在则抛出异常防止删除 - 更新StudentDOMapper.xml,添加对应的SQL查询语句selectStudentCountByClassId
This commit is contained in:
@@ -61,4 +61,11 @@
|
||||
set is_deleted = 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectStudentCountByClassId" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from student
|
||||
where class_id = #{classId}
|
||||
and is_deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user