新增管理:补齐课程教室破坏性操作生命周期与安全引用拦截
This commit is contained in:
1 parent
32f22f950f
commit
88d6c17ca6
8 files changed
+99
-6
No files matched your search
+12
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -79,4 +80,15 @@ public class TrainClassroomInfoController extends BaseController
|
||||
trainClassroomInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(trainClassroomInfoService.updateTrainClassroomInfo(trainClassroomInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除教室信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('train:classroom:remove')")
|
||||
@Log(title = "教室信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{classRoomIds}")
|
||||
public AjaxResult remove(@PathVariable String[] classRoomIds)
|
||||
{
|
||||
return toAjax(trainClassroomInfoService.deleteTrainClassroomInfoByClassRoomIds(classRoomIds));
|
||||
}
|
||||
}
|
||||
+12
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -103,4 +104,15 @@ public class TrainCourseController extends BaseController
|
||||
}
|
||||
return toAjax(trainCourseService.updateTrainCourse(trainCourse));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除课程信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('train:course:remove')")
|
||||
@Log(title = "课程信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{cIds}")
|
||||
public AjaxResult remove(@PathVariable String[] cIds)
|
||||
{
|
||||
return toAjax(trainCourseService.deleteTrainCourseByCIds(cIds));
|
||||
}
|
||||
}
|
||||
@@ -142,4 +142,12 @@ public interface TrainLessonMapper
|
||||
*/
|
||||
List<com.ruoyi.train.domain.TrainClassPlan> selectPlansByTeacherId(@Param("tId") String tId,
|
||||
@Param("planStatus") Integer planStatus);
|
||||
|
||||
/**
|
||||
* 统计指定教室在排课课次中的引用数(train_lesson)。
|
||||
*
|
||||
* @param classRoomId 教室ID
|
||||
* @return 课次引用数
|
||||
*/
|
||||
int countLessonsByClassRoomId(@Param("classRoomId") String classRoomId);
|
||||
}
|
||||
+8
-3
@@ -77,12 +77,17 @@ public interface TrainPlanCourseMapper
|
||||
* @return 引用成绩项目数
|
||||
*/
|
||||
int countScoreItemsByPlanCourseId(@Param("planCourseId") Long planCourseId);
|
||||
|
||||
/**
|
||||
* 统计指定本期课程关联的外部学习记录数(train_study_duration 下游引用)。
|
||||
*
|
||||
* @param planCourseId 本期课程ID
|
||||
* @return 引用学习记录数
|
||||
*/
|
||||
int countStudyDurationsByPlanCourseId(@Param("planCourseId") Long planCourseId);
|
||||
|
||||
/**
|
||||
* 统计指定公共课程在开班计划中的引用数(train_plan_course)。
|
||||
*
|
||||
* @param cId 公共课程ID
|
||||
* @return 引用数
|
||||
*/
|
||||
int countPlanCoursesByCId(@Param("cId") String cId);
|
||||
}
|
||||
+18
-1
@@ -14,6 +14,7 @@ import com.ruoyi.train.domain.vo.ClassroomBoardSummaryVO;
|
||||
import com.ruoyi.train.domain.vo.ClassroomDetailVO;
|
||||
import com.ruoyi.train.mapper.TrainClassroomInfoMapper;
|
||||
import com.ruoyi.train.mapper.TrainElectronicBoardMapper;
|
||||
import com.ruoyi.train.mapper.TrainLessonMapper;
|
||||
import com.ruoyi.train.service.ITrainClassroomInfoService;
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,9 @@ public class TrainClassroomInfoServiceImpl implements ITrainClassroomInfoService
|
||||
@Autowired
|
||||
private TrainElectronicBoardMapper trainElectronicBoardMapper;
|
||||
|
||||
@Autowired
|
||||
private TrainLessonMapper trainLessonMapper;
|
||||
|
||||
/**
|
||||
* 查询教室详情(供API详情接口使用,聚合班牌轻量摘要列表,0..N语义)
|
||||
*
|
||||
@@ -184,7 +188,15 @@ public class TrainClassroomInfoServiceImpl implements ITrainClassroomInfoService
|
||||
@Override
|
||||
public int deleteTrainClassroomInfoByClassRoomIds(String[] classRoomIds)
|
||||
{
|
||||
return trainClassroomInfoMapper.deleteTrainClassroomInfoByClassRoomIds(classRoomIds);
|
||||
if (classRoomIds == null || classRoomIds.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (String id : classRoomIds)
|
||||
{
|
||||
deleteTrainClassroomInfoByClassRoomId(id);
|
||||
}
|
||||
return classRoomIds.length;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,6 +208,11 @@ public class TrainClassroomInfoServiceImpl implements ITrainClassroomInfoService
|
||||
@Override
|
||||
public int deleteTrainClassroomInfoByClassRoomId(String classRoomId)
|
||||
{
|
||||
int lessonCount = trainLessonMapper.countLessonsByClassRoomId(classRoomId);
|
||||
if (lessonCount > 0)
|
||||
{
|
||||
throw new ServiceException("该教室已在排课课次中使用,无法删除,可通过状态调整为维护中或停用。");
|
||||
}
|
||||
return trainClassroomInfoMapper.deleteTrainClassroomInfoByClassRoomId(classRoomId);
|
||||
}
|
||||
}
|
||||
+33
-2
@@ -9,7 +9,10 @@ import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import com.ruoyi.train.mapper.TrainCourseMapper;
|
||||
import com.ruoyi.train.mapper.TrainPlanCourseMapper;
|
||||
import com.ruoyi.train.mapper.TrainScoreInfoMapper;
|
||||
import com.ruoyi.train.domain.TrainCourse;
|
||||
import com.ruoyi.train.domain.TrainScoreInfo;
|
||||
import com.ruoyi.train.domain.vo.CourseDetailVO;
|
||||
import com.ruoyi.train.service.ITrainCourseService;
|
||||
|
||||
@@ -25,6 +28,12 @@ public class TrainCourseServiceImpl implements ITrainCourseService
|
||||
@Autowired
|
||||
private TrainCourseMapper trainCourseMapper;
|
||||
|
||||
@Autowired
|
||||
private TrainPlanCourseMapper trainPlanCourseMapper;
|
||||
|
||||
@Autowired
|
||||
private TrainScoreInfoMapper trainScoreInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询课程详情视图 (CourseDetailVO)
|
||||
*
|
||||
@@ -214,11 +223,19 @@ public class TrainCourseServiceImpl implements ITrainCourseService
|
||||
@Override
|
||||
public int deleteTrainCourseByCIds(String[] cIds)
|
||||
{
|
||||
return trainCourseMapper.deleteTrainCourseByCIds(cIds);
|
||||
if (cIds == null || cIds.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (String cId : cIds)
|
||||
{
|
||||
deleteTrainCourseByCId(cId);
|
||||
}
|
||||
return cIds.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除课程信息信息
|
||||
* 删除课程信息
|
||||
*
|
||||
* @param cId 课程信息主键
|
||||
* @return 结果
|
||||
@@ -226,6 +243,20 @@ public class TrainCourseServiceImpl implements ITrainCourseService
|
||||
@Override
|
||||
public int deleteTrainCourseByCId(String cId)
|
||||
{
|
||||
// 1. 检查是否已被开班计划引用
|
||||
int planRef = trainPlanCourseMapper.countPlanCoursesByCId(cId);
|
||||
if (planRef > 0)
|
||||
{
|
||||
throw new ServiceException("该课程已被培训计划引用,无法删除,可将其停用。");
|
||||
}
|
||||
// 2. 检查是否已产生学员成绩记录
|
||||
TrainScoreInfo scoreQuery = new TrainScoreInfo();
|
||||
scoreQuery.setcId(cId);
|
||||
List<TrainScoreInfo> scoreList = trainScoreInfoMapper.selectTrainScoreInfoList(scoreQuery);
|
||||
if (scoreList != null && !scoreList.isEmpty())
|
||||
{
|
||||
throw new ServiceException("该课程已产生学员成绩记录,无法删除,可将其停用。");
|
||||
}
|
||||
return trainCourseMapper.deleteTrainCourseByCId(cId);
|
||||
}
|
||||
}
|
||||
@@ -386,4 +386,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by p.start_time desc
|
||||
</select>
|
||||
|
||||
<select id="countLessonsByClassRoomId" parameterType="String" resultType="int">
|
||||
select count(1) from train_lesson where class_room_id = #{classRoomId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -118,4 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(*) from train_study_duration where plan_course_id = #{planCourseId}
|
||||
</select>
|
||||
|
||||
<select id="countPlanCoursesByCId" parameterType="String" resultType="int">
|
||||
select count(*) from train_plan_course where c_id = #{cId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user