1、课程资源、实训案例批量删除,系统资源库接口更换

beetlsql3-dev
wgf 2 years ago
parent 2a10974687
commit e800ea65ca

@ -6,22 +6,20 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.jlw.Interceptor.SCoreUser;
import cn.jlw.aliPay.utils.StringUtils; import cn.jlw.aliPay.utils.StringUtils;
import com.ibeetl.admin.core.entity.CoreUser; import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreBaseService; import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException; 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.CourseInfoDao;
import com.ibeetl.jlw.dao.ResourcesInfoDao; import com.ibeetl.jlw.dao.ResourcesInfoDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeCourseInfoDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeResourcesInfoDao; 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.GlobalUpStatusEnum;
import com.ibeetl.jlw.enums.MoveEnum; import com.ibeetl.jlw.enums.MoveEnum;
import com.ibeetl.jlw.web.query.ResourcesInfoQuery; 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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.beetl.sql.core.SqlId; import org.beetl.sql.core.SqlId;
@ -179,65 +177,81 @@ public class ResourcesInfoService extends CoreBaseService<ResourcesInfo> {
} }
/** /**
* * -
*
* @param ids * @param ids
* @param coreUser * @param coreUser
*/ */
public void deleteCourseSystemOAndUniversities(String ids, CoreUser coreUser) { public void deleteCourseSystem(String ids, CoreUser coreUser) {
if (StringUtils.isNotEmpty(ids)) { if (StringUtils.isNotEmpty(ids)) {
String[] split = ids.split(","); String[] split = ids.split(",");
for (String s : split) { for (String s : split) {
ResourcesInfo resourcesInfo = getById(Long.parseLong(s)); ResourcesInfo resourcesInfo = getById(Long.parseLong(s));
if (!ObjectUtil.isNull(resourcesInfo)) { 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(); TeacherOpenCourseMergeResourcesInfo updateQuery = new TeacherOpenCourseMergeResourcesInfo();
updateQuery.setResourcesInfoStatus(GlobalUpStatusEnum.DEL); updateQuery.setResourcesInfoStatus(GlobalUpStatusEnum.DEL);
updateQuery.setTeacherOpenCourseMergeResourcesInfoId(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeResourcesInfoId()); updateQuery.setTeacherOpenCourseMergeResourcesInfoId(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeResourcesInfoId());
teacherOpenCourseMergeResourcesInfoDao.upsertByTemplate(updateQuery); teacherOpenCourseMergeResourcesInfoDao.upsertByTemplate(updateQuery);
} else {
if (split.length == 1) {
Assert.isTrue(false, "课程在使用中");
}
} }
} }
} }

@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -22,7 +21,6 @@ import com.ibeetl.jlw.dao.TeacherOpenCourseKnowledgePointDao;
import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.vo.StudentHandsOnVO; import com.ibeetl.jlw.entity.vo.StudentHandsOnVO;
import com.ibeetl.jlw.enums.CopyFromEnum; import com.ibeetl.jlw.enums.CopyFromEnum;
import com.ibeetl.jlw.enums.GlobalUpStatusEnum;
import com.ibeetl.jlw.enums.HandsOnTaskEnum; import com.ibeetl.jlw.enums.HandsOnTaskEnum;
import com.ibeetl.jlw.web.query.*; import com.ibeetl.jlw.web.query.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -154,33 +152,42 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService<TeacherOpen
* @param ids * @param ids
*/ */
public void manageDeleteTeacherOpenCourseHandsOn(String ids) { public void manageDeleteTeacherOpenCourseHandsOn(String ids) {
TeacherOpenCourseHandsOn teacherOpenCourseHandsOn = teacherOpenCourseHandsOnDao.getSQLManager()
.lambdaQuery(TeacherOpenCourseHandsOn.class)
.andEq(TeacherOpenCourseHandsOn::getHandsOnId, ids)
.single();
if (!ObjectUtil.isEmpty(teacherOpenCourseHandsOn)) {
TeacherOpenCourse teacherOpenCourse = new TeacherOpenCourse();
teacherOpenCourse.setTeacherOpenCourseId(teacherOpenCourseHandsOn.getTeacherOpenCourseId());
List<TeacherOpenCourse> teacherOpenCourses = teacherOpenCourseService.getValues(teacherOpenCourse);
if (CollectionUtil.isNotEmpty(teacherOpenCourses) && teacherOpenCourses.get(0).getEndTime().getTime() >= new Date().getTime()) {
Assert.isTrue(false, "课程在使用中");
}
try { if (StringUtils.isNotEmpty(ids)) {
TeacherOpenCourseHandsOnQuery handsOnQuery = new TeacherOpenCourseHandsOnQuery(); String[] split = ids.split(",");
handsOnQuery.setHandsOnIdPlural(ids); for (String s : split) {
handsOnQuery.set_given("handsOnStatus");
handsOnQuery.setHandsOnStatus(0); TeacherOpenCourseHandsOn teacherOpenCourseHandsOn = teacherOpenCourseHandsOnDao.getSQLManager()
teacherOpenCourseHandsOnDao.updateGivenByIds(handsOnQuery); .lambdaQuery(TeacherOpenCourseHandsOn.class)
} catch (Exception e) { .andEq(TeacherOpenCourseHandsOn::getHandsOnId, s)
throw new PlatformException("批量删除教师开课-课程实操失败", e); .single();
if (!ObjectUtil.isEmpty(teacherOpenCourseHandsOn)) {
TeacherOpenCourse teacherOpenCourse = new TeacherOpenCourse();
teacherOpenCourse.setTeacherOpenCourseId(teacherOpenCourseHandsOn.getTeacherOpenCourseId());
List<TeacherOpenCourse> teacherOpenCourses = teacherOpenCourseService.getValues(teacherOpenCourse);
if (CollectionUtil.isNotEmpty(teacherOpenCourses) && teacherOpenCourses.get(0).getEndTime().getTime() <= new Date().getTime()) {
try {
TeacherOpenCourseHandsOnQuery handsOnQuery = new TeacherOpenCourseHandsOnQuery();
handsOnQuery.setHandsOnIdPlural(s);
handsOnQuery.set_given("handsOnStatus");
handsOnQuery.setHandsOnStatus(0);
teacherOpenCourseHandsOnDao.updateGivenByIds(handsOnQuery);
} catch (Exception e) {
throw new PlatformException("批量删除教师开课-课程实操失败", e);
}
} else {
if (split.length == 1) {
Assert.isTrue(false, "课程在使用中");
}
}
} else {
Assert.isTrue(false, "找不到课程实训");
}
} }
}else {
Assert.isTrue(false, "找不到课程实训");
} }
} }
public String addAll(TeacherOpenCourseHandsOnQuery teacherOpenCourseHandsOnQuery) { public String addAll(TeacherOpenCourseHandsOnQuery teacherOpenCourseHandsOnQuery) {

@ -318,6 +318,32 @@ public class ResourcesInfoController {
return JsonResult.success(page); return JsonResult.success(page);
} }
@PostMapping(MODEL + "/resourcesList.json")
@Function("resourcesInfo.query")
@ResponseBody
public JsonResult<PageQuery> resourcesList(ResourcesInfoQuery condition, @SCoreUser CoreUser coreUser) {
PageQuery page = condition.getPageQuery();
if (coreUser.isUniAdmin()) {
condition.setOrgIdPlural(join(Arrays.asList(coreUser.getOrgId(), 1L).toArray(), ","));
// 查询已经授权的课程ID。
// 理论课程授权表universities_colleges_jurisdiction_curriculum_resources查询理论课程授权给院校的数据
Serializable courseInfoIds = defaultIfNull(condition.getCourseInfoId(), condition.getCourseInfoIds());
ResourcesCourseInfoAuthDetailsVO resourcesCourseInfoAuthDetails =
universitiesCollegesJurisdictionCurriculumResourcesService.getResourcesCourseInfoAuthDetails(coreUser.getOrgId());
Serializable ifNullCourseInfoIds = defaultIfNull(courseInfoIds, listJoin(resourcesCourseInfoAuthDetails.getTheoryCourseList(), CourseInfo::getCourseInfoId));
String ids = Arrays.stream(ifNullCourseInfoIds.toString().split(",")).map(item -> "_" + item + "_").collect(Collectors.joining("|"));
// 如果为空字符串,那么代表这个学校,还没有授权的课程,所以是不会显示任何东西的。
condition.setCourseInfoIds(StrUtil.blankToDefault(ids, "未授权应用"));
}
condition.setResourcesInfoStatus(1);
resourcesInfoService.queryByCondition(page);
return JsonResult.success(page);
}
@PostMapping(MODEL + "/getCurriculumResourceManagementList.json") @PostMapping(MODEL + "/getCurriculumResourceManagementList.json")
@ResponseBody @ResponseBody
public JsonResult<PageQuery> getCurriculumResourceManagementList(ResourcesInfoQuery condition, @SCoreUser CoreUser coreUser) { public JsonResult<PageQuery> getCurriculumResourceManagementList(ResourcesInfoQuery condition, @SCoreUser CoreUser coreUser) {
@ -512,7 +538,12 @@ public class ResourcesInfoController {
@PostMapping(MODEL + "/deleteCourseSystemOAndUniversities.json") @PostMapping(MODEL + "/deleteCourseSystemOAndUniversities.json")
@ResponseBody @ResponseBody
public JsonResult deleteCourseSystemOAndUniversities(String ids, @SCoreUser CoreUser coreUser) { public JsonResult deleteCourseSystemOAndUniversities(String ids, @SCoreUser CoreUser coreUser) {
resourcesInfoService.deleteCourseSystemOAndUniversities(ids, coreUser); if (coreUser.isAdmin()){
resourcesInfoService.deleteCourseSystem(ids, coreUser);
}else if (coreUser.isUniAdmin()){
resourcesInfoService.deleteCourseUniversities(ids, coreUser);
}
return JsonResult.success(); return JsonResult.success();
} }

Loading…
Cancel
Save