|
@@ -108,11 +108,11 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, int pageNumber, int pageSize) {
|
|
|
+ public IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, int pageNumber, int pageSize) {
|
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
|
|
|
courseName = SystemConstant.translateSpecificSign(courseName);
|
|
|
- IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), belongOrgId, courseName, startCreateTime, endCreateTime, enable, schoolId, orgIds);
|
|
|
+ IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), belongOrgId, courseName, startCreateTime, endCreateTime, schoolId, orgIds);
|
|
|
List<BasicCourseResult> list = iPage.getRecords();
|
|
|
for (BasicCourseResult basicCourseResult : list) {
|
|
|
Long courseId = basicCourseResult.getId();
|
|
@@ -148,50 +148,40 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Boolean removeBasicCourseBatch(List<Long> idList, Boolean enable) {
|
|
|
+ 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();
|
|
|
- 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());
|
|
|
- Set<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) + "】 已经生成了命题任务,不允许禁用");
|
|
|
+ // 批量禁用判断
|
|
|
+ // 业务判断
|
|
|
+ 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());
|
|
|
+ Set<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.update(new UpdateWrapper<BasicUserCourse>().lambda()
|
|
|
+ // 课程批量删除
|
|
|
+ basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda()
|
|
|
.in(BasicUserCourse::getCourseId, idList)
|
|
|
- .eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId())
|
|
|
- .set(BasicUserCourse::getEnable, enable)
|
|
|
- .set(BasicUserCourse::getUpdateId, sysUser.getId()));
|
|
|
+ .eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
|
|
|
|
|
|
- UpdateWrapper<BasicCourse> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda()
|
|
|
- .set(BasicCourse::getEnable, enable)
|
|
|
- .in(BasicCourse::getId, idList)
|
|
|
- .set(BasicCourse::getUpdateId, sysUser.getId());
|
|
|
-
|
|
|
- return this.update(updateWrapper);
|
|
|
+ return this.removeByIds(idList);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, Boolean enableOperate) {
|
|
|
+ public Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime) {
|
|
|
QueryWrapper<BasicCourse> basicCourseQueryWrapper = new QueryWrapper<>();
|
|
|
if (SystemConstant.longNotNull(belongOrgId)) {
|
|
|
basicCourseQueryWrapper.lambda().eq(BasicCourse::getTeachingRoomId, belongOrgId);
|
|
@@ -205,13 +195,10 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
if (SystemConstant.longNotNull(endCreateTime)) {
|
|
|
basicCourseQueryWrapper.lambda().le(BasicCourse::getCreateTime, endCreateTime);
|
|
|
}
|
|
|
- if (Objects.nonNull(enable)) {
|
|
|
- basicCourseQueryWrapper.lambda().eq(BasicCourse::getEnable, enable);
|
|
|
- }
|
|
|
List<BasicCourse> basicCourseList = this.list(basicCourseQueryWrapper);
|
|
|
List<Long> idList = basicCourseList.stream().map(BaseEntity::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- return idList.size() > 0 ? this.removeBasicCourseBatch(idList, enableOperate) : true;
|
|
|
+ return idList.size() > 0 ? this.removeBasicCourseBatch(idList) : true;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|