feat(class): 删除班级时验证是否存在学生

- 新增StudentDOMapper接口方法selectStudentCountByClassId,用于查询班级下学生数量
- 在ClassServiceImpl中注入StudentDOMapper
- 删除班级时先判断班级下是否存在学生,若存在则抛出异常防止删除
- 更新StudentDOMapper.xml,添加对应的SQL查询语句selectStudentCountByClassId
This commit is contained in:
lbw
2025-12-15 16:37:42 +08:00
parent f8169b453e
commit e5fbb445cf
3 changed files with 16 additions and 0 deletions

View File

@@ -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>