|
@@ -24,6 +24,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -59,7 +60,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
@Override
|
|
|
public void verifyCourseInfo(Long schoolId, String courseCode, String courseName, Long userId) {
|
|
|
QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode);
|
|
|
+ queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode).eq(BasicCourse::getEnable,true);
|
|
|
|
|
|
BasicCourse tmp = this.getOne(queryWrapper);
|
|
|
if (tmp != null) {
|
|
@@ -68,15 +69,17 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
.exception("课程代码和课程名称不匹配,课程代码为 :'" + courseCode + "',输入的课程名称 :'" + courseName + "',实际该代码对应的课程名称 :'" + tmp.getName() + "'。");
|
|
|
}
|
|
|
} else {
|
|
|
- BasicCourse basicCourse = new BasicCourse();
|
|
|
- basicCourse.setName(courseName);
|
|
|
- basicCourse.setCode(courseCode);
|
|
|
- basicCourse.setSchoolId(schoolId);
|
|
|
- basicCourse.setId(SystemConstant.getDbUuid());
|
|
|
- basicCourse.setCreateId(userId);
|
|
|
- basicCourse.setOrgId(sysUserService.getById(userId).getOrgId());
|
|
|
- basicCourse.setCreateTime(System.currentTimeMillis());
|
|
|
- this.saveOrUpdate(basicCourse);
|
|
|
+// BasicCourse basicCourse = new BasicCourse();
|
|
|
+// basicCourse.setName(courseName);
|
|
|
+// basicCourse.setCode(courseCode);
|
|
|
+// basicCourse.setSchoolId(schoolId);
|
|
|
+// basicCourse.setId(SystemConstant.getDbUuid());
|
|
|
+// basicCourse.setCreateId(userId);
|
|
|
+// basicCourse.setOrgId(sysUserService.getById(userId).getOrgId());
|
|
|
+// basicCourse.setCreateTime(System.currentTimeMillis());
|
|
|
+// basicCourse.setTeachingRoomId();
|
|
|
+// this.saveOrUpdate(basicCourse);
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考务文件中 【课程代码】为 :" + courseCode + ",【课程名称】为 : " + courseName + ",在基础课程信息中不存在,请先添加课程");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -151,10 +154,28 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Boolean removeBasicCourseBatch(List<Long> idList) {
|
|
|
+ Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
if (idList.size() == 0) {
|
|
|
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(",");
|
|
|
+ }
|
|
|
+ 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()));
|
|
|
|
|
|
UpdateWrapper<BasicCourse> updateWrapper = new UpdateWrapper<>();
|