|
@@ -153,36 +153,42 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Boolean removeBasicCourseBatch(List<Long> idList) {
|
|
|
+ public Boolean removeBasicCourseBatch(List<Long> idList,Boolean enable) {
|
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
if (idList.size() == 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("请选择要删除的目标");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择要目标");
|
|
|
}
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- // 业务判断
|
|
|
- Set<String> courseCodeSet = idList.stream().map(e -> {
|
|
|
- BasicCourse basicCourse = this.getById(e);
|
|
|
- if (Objects.isNull(basicCourse)){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到课程");
|
|
|
- }
|
|
|
- return basicCourse.getCode();
|
|
|
- }).collect(Collectors.toSet());
|
|
|
- List<Map<String,Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId,courseCodeSet);
|
|
|
- if (mapList.size() > 0){
|
|
|
- StringBuilder courseNames = new StringBuilder();
|
|
|
- for (Map<String, Object> map : mapList) {
|
|
|
- courseNames.append(map.get("courseName")).append(",");
|
|
|
+ if (!enable){
|
|
|
+ // 批量禁用判断
|
|
|
+ // 业务判断
|
|
|
+ Set<String> courseCodeSet = idList.stream().map(e -> {
|
|
|
+ BasicCourse basicCourse = this.getById(e);
|
|
|
+ if (Objects.isNull(basicCourse)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到课程");
|
|
|
+ }
|
|
|
+ return basicCourse.getCode();
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
+ List<Map<String,Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId,courseCodeSet);
|
|
|
+ if (mapList.size() > 0){
|
|
|
+ StringBuilder courseNames = new StringBuilder();
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ courseNames.append(map.get("courseName")).append(",");
|
|
|
+ }
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【课程】 : " + courseNames.substring(0,courseNames.length() - 1) + " 已经生成了命题任务,不允许禁用");
|
|
|
}
|
|
|
- throw ExceptionResultEnum.ERROR.exception("【课程】 : " + courseNames.substring(0,courseNames.length() - 1) + " 已经生成了命题任务,不允许删除");
|
|
|
}
|
|
|
-
|
|
|
- basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda().in(BasicUserCourse::getCourseId, idList).eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
|
|
|
+ // 课程批量启用禁用
|
|
|
+ basicUserCourseService.update(new UpdateWrapper<BasicUserCourse>().lambda()
|
|
|
+ .in(BasicUserCourse::getCourseId, idList)
|
|
|
+ .eq(BasicUserCourse::getSchoolId,sysUser.getSchoolId())
|
|
|
+ .set(BasicUserCourse::getEnable,enable)
|
|
|
+ .set(BasicUserCourse::getUpdateId, sysUser.getId()));
|
|
|
|
|
|
UpdateWrapper<BasicCourse> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda()
|
|
|
- .set(BasicCourse::getEnable, false)
|
|
|
+ .set(BasicCourse::getEnable, enable)
|
|
|
.in(BasicCourse::getId, idList)
|
|
|
- .set(BasicCourse::getOrgId, sysUser.getOrgId())
|
|
|
.set(BasicCourse::getUpdateId, sysUser.getId());
|
|
|
|
|
|
return this.update(updateWrapper);
|