|
|
|
@ -6,22 +6,20 @@ import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.jlw.Interceptor.SCoreUser;
|
|
|
|
|
import cn.jlw.aliPay.utils.StringUtils;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.jlw.dao.CourseInfoDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.ResourcesInfoDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeCourseInfoDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeResourcesInfoDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.entity.CourseInfo;
|
|
|
|
|
import com.ibeetl.jlw.entity.ResourcesInfo;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourse;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeResourcesInfo;
|
|
|
|
|
import com.ibeetl.jlw.enums.GlobalUpStatusEnum;
|
|
|
|
|
import com.ibeetl.jlw.enums.MoveEnum;
|
|
|
|
|
import com.ibeetl.jlw.web.query.ResourcesInfoQuery;
|
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeResourcesInfoQuery;
|
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeResourcesQuestionQuery;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
@ -179,65 +177,81 @@ public class ResourcesInfoService extends CoreBaseService<ResourcesInfo> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 课程资源删除
|
|
|
|
|
* 课程资源删除-系统管理端
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @param coreUser
|
|
|
|
|
*/
|
|
|
|
|
public void deleteCourseSystemOAndUniversities(String ids, CoreUser coreUser) {
|
|
|
|
|
public void deleteCourseSystem(String ids, CoreUser coreUser) {
|
|
|
|
|
if (StringUtils.isNotEmpty(ids)) {
|
|
|
|
|
String[] split = ids.split(",");
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
ResourcesInfo resourcesInfo = getById(Long.parseLong(s));
|
|
|
|
|
if (!ObjectUtil.isNull(resourcesInfo)) {
|
|
|
|
|
if (coreUser.isAdmin()){
|
|
|
|
|
courseInfoService.flushCache(resourcesInfo.getCourseInfoId());
|
|
|
|
|
CourseInfo oldCourseInfo = courseInfoDao.single(resourcesInfo.getCourseInfoId());
|
|
|
|
|
if (null != oldCourseInfo) {
|
|
|
|
|
//资源类型(1视频 2课件 3附件)
|
|
|
|
|
if (((Integer) 1).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseVideoId(null != oldCourseInfo.getCourseVideoId() && oldCourseInfo.getCourseVideoId().equals(resourcesInfo.getResourcesInfoId()) ? null : oldCourseInfo.getCourseVideoId());
|
|
|
|
|
courseInfoDao.updateVideoIdById(c);
|
|
|
|
|
} else if (((Integer) 2).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseCoursewareId(null != oldCourseInfo.getCourseCoursewareId() && oldCourseInfo.getCourseCoursewareId().equals(resourcesInfo.getResourcesInfoId()) ? null : oldCourseInfo.getCourseCoursewareId());
|
|
|
|
|
courseInfoDao.updateCoursewareIdById(c);
|
|
|
|
|
} else if (((Integer) 3).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseEnclosureIds(StringUtils.isNotBlank(oldCourseInfo.getCourseEnclosureIds()) ? (oldCourseInfo.getCourseEnclosureIds().replace(resourcesInfo.getResourcesInfoId().toString(), "").replace(",,", ",")) : oldCourseInfo.getCourseEnclosureIds());
|
|
|
|
|
courseInfoDao.updateEnclosureIdsById(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ResourcesInfo info = new ResourcesInfo();
|
|
|
|
|
info.setResourcesInfoStatus(0);
|
|
|
|
|
resourcesInfoDao.getSQLManager().lambdaQuery(ResourcesInfo.class)
|
|
|
|
|
.andEq(ResourcesInfo::getResourcesInfoId,s).updateSelective(info);
|
|
|
|
|
|
|
|
|
|
courseInfoService.flushCache(resourcesInfo.getCourseInfoId());
|
|
|
|
|
CourseInfo oldCourseInfo = courseInfoDao.single(resourcesInfo.getCourseInfoId());
|
|
|
|
|
if (null != oldCourseInfo) {
|
|
|
|
|
//资源类型(1视频 2课件 3附件)
|
|
|
|
|
if (((Integer) 1).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseVideoId(null != oldCourseInfo.getCourseVideoId() && oldCourseInfo.getCourseVideoId().equals(resourcesInfo.getResourcesInfoId()) ? null : oldCourseInfo.getCourseVideoId());
|
|
|
|
|
courseInfoDao.updateVideoIdById(c);
|
|
|
|
|
} else if (((Integer) 2).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseCoursewareId(null != oldCourseInfo.getCourseCoursewareId() && oldCourseInfo.getCourseCoursewareId().equals(resourcesInfo.getResourcesInfoId()) ? null : oldCourseInfo.getCourseCoursewareId());
|
|
|
|
|
courseInfoDao.updateCoursewareIdById(c);
|
|
|
|
|
} else if (((Integer) 3).equals(resourcesInfo.getResourcesInfoType())) {
|
|
|
|
|
CourseInfo c = new CourseInfo();
|
|
|
|
|
c.setCourseInfoId(oldCourseInfo.getCourseInfoId());
|
|
|
|
|
c.setCourseEnclosureIds(StringUtils.isNotBlank(oldCourseInfo.getCourseEnclosureIds()) ? (oldCourseInfo.getCourseEnclosureIds().replace(resourcesInfo.getResourcesInfoId().toString(), "").replace(",,", ",")) : oldCourseInfo.getCourseEnclosureIds());
|
|
|
|
|
courseInfoDao.updateEnclosureIdsById(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ResourcesInfo info = new ResourcesInfo();
|
|
|
|
|
info.setResourcesInfoStatus(0);
|
|
|
|
|
resourcesInfoDao.getSQLManager().lambdaQuery(ResourcesInfo.class)
|
|
|
|
|
.andEq(ResourcesInfo::getResourcesInfoId, s).updateSelective(info);
|
|
|
|
|
|
|
|
|
|
TeacherOpenCourseMergeResourcesInfo teacherOpenCourseMergeResourcesInfo = teacherOpenCourseMergeResourcesInfoDao.getSQLManager()
|
|
|
|
|
.lambdaQuery(TeacherOpenCourseMergeResourcesInfo.class)
|
|
|
|
|
.andEq(TeacherOpenCourseMergeResourcesInfo::getTeacherOpenCourseMergeResourcesInfoId,s)
|
|
|
|
|
.single();
|
|
|
|
|
if (!ObjectUtil.isEmpty(teacherOpenCourseMergeResourcesInfo)) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeacherOpenCourse teacherOpenCourse = new TeacherOpenCourse();
|
|
|
|
|
teacherOpenCourse.setTeacherOpenCourseId(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseId());
|
|
|
|
|
List<TeacherOpenCourse> teacherOpenCourses = teacherOpenCourseService.getValues(teacherOpenCourse);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(teacherOpenCourses) && teacherOpenCourses.get(0).getEndTime().getTime() >= new Date().getTime()){
|
|
|
|
|
Assert.isTrue(false, "课程在使用中");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 课程资源删除-院校管理端
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @param coreUser
|
|
|
|
|
*/
|
|
|
|
|
public void deleteCourseUniversities(String ids, CoreUser coreUser) {
|
|
|
|
|
if (StringUtils.isNotEmpty(ids)) {
|
|
|
|
|
String[] split = ids.split(",");
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
|
|
|
|
|
TeacherOpenCourseMergeResourcesInfo teacherOpenCourseMergeResourcesInfo = teacherOpenCourseMergeResourcesInfoDao.getSQLManager()
|
|
|
|
|
.lambdaQuery(TeacherOpenCourseMergeResourcesInfo.class)
|
|
|
|
|
.andEq(TeacherOpenCourseMergeResourcesInfo::getTeacherOpenCourseMergeResourcesInfoId, s)
|
|
|
|
|
.single();
|
|
|
|
|
if (!ObjectUtil.isEmpty(teacherOpenCourseMergeResourcesInfo)) {
|
|
|
|
|
|
|
|
|
|
TeacherOpenCourse teacherOpenCourse = new TeacherOpenCourse();
|
|
|
|
|
teacherOpenCourse.setTeacherOpenCourseId(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseId());
|
|
|
|
|
List<TeacherOpenCourse> teacherOpenCourses = teacherOpenCourseService.getValues(teacherOpenCourse);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(teacherOpenCourses) && teacherOpenCourses.get(0).getEndTime().getTime() <= new Date().getTime()) {
|
|
|
|
|
|
|
|
|
|
TeacherOpenCourseMergeResourcesInfo updateQuery = new TeacherOpenCourseMergeResourcesInfo();
|
|
|
|
|
updateQuery.setResourcesInfoStatus(GlobalUpStatusEnum.DEL);
|
|
|
|
|
updateQuery.setTeacherOpenCourseMergeResourcesInfoId(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeResourcesInfoId());
|
|
|
|
|
teacherOpenCourseMergeResourcesInfoDao.upsertByTemplate(updateQuery);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (split.length == 1) {
|
|
|
|
|
Assert.isTrue(false, "课程在使用中");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|