|
@@ -1,7 +1,6 @@
|
|
package cn.iselab.mooctest.site.web.logic.impl;
|
|
package cn.iselab.mooctest.site.web.logic.impl;
|
|
|
|
|
|
-import cn.iselab.mooctest.site.common.enums.CourseAuthorisedType;
|
|
|
|
-import cn.iselab.mooctest.site.common.enums.EntityType;
|
|
|
|
|
|
+import cn.iselab.mooctest.site.common.enums.CourseType;
|
|
import cn.iselab.mooctest.site.common.enums.CourseVisibility;
|
|
import cn.iselab.mooctest.site.common.enums.CourseVisibility;
|
|
import cn.iselab.mooctest.site.common.enums.EntityTypeEnum;
|
|
import cn.iselab.mooctest.site.common.enums.EntityTypeEnum;
|
|
import cn.iselab.mooctest.site.models.*;
|
|
import cn.iselab.mooctest.site.models.*;
|
|
@@ -9,23 +8,18 @@ import cn.iselab.mooctest.site.service.*;
|
|
import cn.iselab.mooctest.site.service.common.PdfService;
|
|
import cn.iselab.mooctest.site.service.common.PdfService;
|
|
import cn.iselab.mooctest.site.util.data.Converter;
|
|
import cn.iselab.mooctest.site.util.data.Converter;
|
|
import cn.iselab.mooctest.site.web.data.*;
|
|
import cn.iselab.mooctest.site.web.data.*;
|
|
-import cn.iselab.mooctest.site.web.data.response.ResponseVO;
|
|
|
|
-import cn.iselab.mooctest.site.web.data.response.ServerCode;
|
|
|
|
import cn.iselab.mooctest.site.web.data.wrapper.*;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.*;
|
|
import cn.iselab.mooctest.site.web.exception.HttpForbiddenException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpForbiddenException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpNotFoundException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpNotFoundException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
|
|
-import cn.iselab.mooctest.site.web.exception.HttpNotFoundException;
|
|
|
|
import cn.iselab.mooctest.site.web.logic.OSSLogic;
|
|
import cn.iselab.mooctest.site.web.logic.OSSLogic;
|
|
import cn.iselab.mooctest.site.web.logic.ThemeLogic;
|
|
import cn.iselab.mooctest.site.web.logic.ThemeLogic;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
-import org.apache.shiro.crypto.hash.Hash;
|
|
|
|
-import org.drools.core.time.SchedulerService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -34,10 +28,10 @@ import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.sql.Array;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @program: mooctest-site
|
|
* @program: mooctest-site
|
|
@@ -69,6 +63,10 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
@Autowired
|
|
@Autowired
|
|
private ThemeSchedulerService themeSchedulerService;
|
|
private ThemeSchedulerService themeSchedulerService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private ThemeEntityRelationsSchedulerService themeEntityRelationsSchedulerService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ThemeEntityRelationsStatusService themeEntityRelationsStatusService;
|
|
|
|
+ @Autowired
|
|
private ThemeStatusService themeStatusService;
|
|
private ThemeStatusService themeStatusService;
|
|
@Autowired
|
|
@Autowired
|
|
private PdfService pdfService;
|
|
private PdfService pdfService;
|
|
@@ -81,6 +79,12 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
@Autowired
|
|
@Autowired
|
|
SubmitRecordService submitRecordService;
|
|
SubmitRecordService submitRecordService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private User2RoleService user2RoleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OperationRecourseService operationRecourseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RoleService roleService;
|
|
|
|
+ @Autowired
|
|
private OSSLogic ossLogic;
|
|
private OSSLogic ossLogic;
|
|
@Autowired
|
|
@Autowired
|
|
private CourseResourceService courseResourceService;
|
|
private CourseResourceService courseResourceService;
|
|
@@ -91,6 +95,8 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
private ThemeEntityRelationsVOWrapper themeEntityRelationsVOWrapper;
|
|
private ThemeEntityRelationsVOWrapper themeEntityRelationsVOWrapper;
|
|
@Autowired
|
|
@Autowired
|
|
private GroupVOWrapper groupVOWrapper;
|
|
private GroupVOWrapper groupVOWrapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserVOWrapper userVOWrapper;
|
|
|
|
|
|
|
|
|
|
private static final String BASE_DIR = "theme";
|
|
private static final String BASE_DIR = "theme";
|
|
@@ -107,8 +113,42 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<GroupVO> getForkCourseGroups(long themeId) {
|
|
public List<GroupVO> getForkCourseGroups(long themeId) {
|
|
- Theme2Group theme2Group = theme2GroupService.findByThemeId(themeId);
|
|
|
|
|
|
+ // 判断对被fork课程的使用权限
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
+ List<User2Theme> user2ThemeList = user2ThemeService.findAllByUserIdAndThemeId(userId, themeId);
|
|
|
|
+ // 使用权限要为* 或者 use
|
|
|
|
+ List<User2Theme> user2Themes = user2ThemeList.stream().filter(user2Theme -> user2Theme.getOperation() != User2Theme.AUTH_VIEW).collect(Collectors.toList());
|
|
|
|
+ if(user2Themes.size() <= 0){
|
|
|
|
+ throw new HttpBadRequestException("fork失败,当前用户并无对此课程的使用权限!");
|
|
|
|
+ }
|
|
|
|
+ // 判断对被fork课程的章节是否是 已授权的非自定义课程中的章节
|
|
|
|
+ // 获取被fork课程的所有章节 -> 所有公开的章节
|
|
|
|
+ List<Long> courseResourceIdList = themeService.getThemeEntityRelations(themeId, EntityTypeEnum.COURSE_RESOURCE).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList());
|
|
|
|
+ boolean canFork = true;
|
|
|
|
+ String message = "";
|
|
|
|
+ // 如果存在章节则需要判断
|
|
|
|
+ if(courseResourceIdList.size() > 0){
|
|
|
|
+ List<Long> publicResourceIdList = courseResourceService.getCourseResourceById(courseResourceIdList).stream()
|
|
|
|
+ .filter(resource -> resource.getPublicStatus() == CourseResource.IS_PUBLIC)
|
|
|
|
+ .map(CourseResource::getId).collect(Collectors.toList());
|
|
|
|
+ // 如果存在公开的章节则需要判断
|
|
|
|
+ if(publicResourceIdList.size() > 0){
|
|
|
|
+ // 根据这些公开章节获取所有已使用当前章节的 公开课程
|
|
|
|
+ for(Long resourceId : publicResourceIdList){
|
|
|
|
+ List<OperationResource> operationRecourseList = operationRecourseService.getOperationResourceList(userId, User2Theme.AUTH_VIEW, resourceId, CourseResource.NOT_Deleted, CourseResource.IS_PUBLIC, ThemeDetail.IS_PUBLIC, ThemeDetail.COURSE, ThemeDetail.NOT_DELETED);
|
|
|
|
+ if(operationRecourseList.size() <= 0){
|
|
|
|
+ canFork = false;
|
|
|
|
+ message += " \"" + courseResourceService.getCourseResourceByResourceId(resourceId).getTitle() + "\"";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!canFork){
|
|
|
|
+ throw new HttpBadRequestException("复制课程失败,被复制的课程中含有未授权的课程中的章节:" + message + "!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 允许被fork
|
|
|
|
+ Theme2Group theme2Group = theme2GroupService.findByThemeId(themeId);
|
|
List<Group> groups = groupService.getGroupsByOwnerId(userId);
|
|
List<Group> groups = groupService.getGroupsByOwnerId(userId);
|
|
List<GroupVO> groupVOs = groupVOWrapper.wrap(groups);
|
|
List<GroupVO> groupVOs = groupVOWrapper.wrap(groups);
|
|
return groupVOs.stream().filter(groupVO -> !groupVO.getId().equals(theme2Group.getGroupId())).collect(Collectors.toList());
|
|
return groupVOs.stream().filter(groupVO -> !groupVO.getId().equals(theme2Group.getGroupId())).collect(Collectors.toList());
|
|
@@ -132,80 +172,33 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
if(!admin && themeDetailVO.getVisibility() != CourseVisibility.NONE_OPEN.getVisibility()){
|
|
if(!admin && themeDetailVO.getVisibility() != CourseVisibility.NONE_OPEN.getVisibility()){
|
|
throw new HttpBadRequestException("当前用户只能新建自定义课程");
|
|
throw new HttpBadRequestException("当前用户只能新建自定义课程");
|
|
}
|
|
}
|
|
|
|
+ // 设置是否公开
|
|
|
|
+ if(admin && themeDetailVO.getVisibility() != CourseVisibility.NONE_OPEN.getVisibility()){
|
|
|
|
+ themeDetailVO.setPublicStatus(ThemeDetail.IS_PUBLIC);
|
|
|
|
+ }else{
|
|
|
|
+ themeDetailVO.setPublicStatus(ThemeDetail.IS_PRIVATE);
|
|
|
|
+ }
|
|
// 检验课程信息
|
|
// 检验课程信息
|
|
checkThemeInfo(themeDetailVO);
|
|
checkThemeInfo(themeDetailVO);
|
|
if (themeDetailVO.getGroupId() != null && groupService.getGroupsByOwnerId(themeDetailVO.getOwnerId()).stream()
|
|
if (themeDetailVO.getGroupId() != null && groupService.getGroupsByOwnerId(themeDetailVO.getOwnerId()).stream()
|
|
.map(Group::getId).collect(Collectors.toList()).contains(themeDetailVO.getGroupId())) {
|
|
.map(Group::getId).collect(Collectors.toList()).contains(themeDetailVO.getGroupId())) {
|
|
- // 课程中的实体信息(课程信息、考试信息、练习信息) 可否为空
|
|
|
|
- List<EntityVO> entityVOList = courseVO.getEntityVOList();
|
|
|
|
- if(entityVOList.size() != 0){
|
|
|
|
-// if(entityVOList.size() > 40) throw new HttpBadRequestException("课程内容(章节、练习、考试)总共不能超过40个");
|
|
|
|
- checkThemeCourseGroupAndExam(themeDetailVO, entityVOList);
|
|
|
|
- // 条件符合,可以创建
|
|
|
|
- ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
|
|
- themeDetail.setReleased(ThemeDetail.UNRELEASED);
|
|
|
|
- themeDetail = themeService.createThemeDetail(themeDetail);
|
|
|
|
-
|
|
|
|
- themeSchedulerService.createNewThemeScheduler(themeDetail);
|
|
|
|
-
|
|
|
|
- themeDetailVO.setId(themeDetail.getId());
|
|
|
|
- theme2GroupService.create(themeDetailVO.getGroupId(), themeDetailVO.getId());
|
|
|
|
- user2ThemeService.createOperationRelation(userId,themeDetail.getId(),"*");
|
|
|
|
- int index = 0;
|
|
|
|
- for(EntityVO entityVO: entityVOList){
|
|
|
|
- index++;
|
|
|
|
- entityVO.setThemeId(themeDetailVO.getId());
|
|
|
|
- ThemeEntityRelationsVO entityRelation = createEntityRelation(themeDetailVO.getId(), entityVO.getEntityId(), entityVO.getEntityType(), index, Boolean.TRUE);
|
|
|
|
- entityVO.setSortedId(entityRelation.getSortId());
|
|
|
|
- }
|
|
|
|
- courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- // 条件符合,可以创建
|
|
|
|
- ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
|
|
- themeDetail.setReleased(ThemeDetail.UNRELEASED);
|
|
|
|
- themeDetail = themeService.createThemeDetail(themeDetail);
|
|
|
|
- themeSchedulerService.createNewThemeScheduler(themeDetail);
|
|
|
|
- themeDetailVO.setId(themeDetail.getId());
|
|
|
|
- theme2GroupService.create(themeDetailVO.getGroupId(), themeDetailVO.getId());
|
|
|
|
- user2ThemeService.createOperationRelation(userId,themeDetail.getId(),"*");
|
|
|
|
- courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
|
|
- }
|
|
|
|
|
|
+ // 条件符合,可以创建
|
|
|
|
+ ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
|
|
+ themeDetail.setReleased(ThemeDetail.UNRELEASED);
|
|
|
|
+ themeDetail = themeService.createThemeDetail(themeDetail);
|
|
|
|
+ themeSchedulerService.createNewThemeScheduler(themeDetail);
|
|
|
|
+ themeDetailVO.setId(themeDetail.getId());
|
|
|
|
+ theme2GroupService.create(themeDetailVO.getGroupId(), themeDetailVO.getId());
|
|
|
|
+ user2ThemeService.createOperationRelation(userId,themeDetail.getId(),User2Theme.AUTH_ALL);
|
|
|
|
+ ThemeDetailVO themeDetailVOResult = themeVOWrapper.wrapperThemeDetail(themeDetail);
|
|
|
|
+ themeDetailVOResult.setCanEdit(true);
|
|
|
|
+ courseVO.setThemeDetailVO(themeDetailVOResult);
|
|
} else {
|
|
} else {
|
|
throw new HttpBadRequestException("No right for some group");
|
|
throw new HttpBadRequestException("No right for some group");
|
|
}
|
|
}
|
|
return courseVO;
|
|
return courseVO;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public CourseVO forkThemeCourse(Long themeId, Long groupId) {
|
|
|
|
- CourseVO courseVO = new CourseVO();
|
|
|
|
- Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
- // fork course info
|
|
|
|
- ThemeDetailVO themeDetailVO = getThemeDetailByThemeId(themeId);
|
|
|
|
- themeDetailVO.setOwnerId(userId);
|
|
|
|
- ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
|
|
- themeDetail.setId(null);
|
|
|
|
- themeDetail.setReleased(ThemeDetail.UNRELEASED);
|
|
|
|
- themeDetail = themeService.createThemeDetail(themeDetail);
|
|
|
|
- themeSchedulerService.createNewThemeScheduler(themeDetail);
|
|
|
|
- theme2GroupService.create(groupId, themeDetail.getId());
|
|
|
|
- user2ThemeService.createOperationRelation(userId, themeDetail.getId(),"*");
|
|
|
|
- courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
|
|
- // fork course resource
|
|
|
|
- List<EntityVO> entityVOS = new ArrayList<>();
|
|
|
|
- List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(themeId);
|
|
|
|
- List<ThemeEntityRelations> resourceEntityRelations = themeEntityRelations.stream().filter(entityRelation -> entityRelation.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
|
|
- if(resourceEntityRelations.size() != 0){
|
|
|
|
- for(ThemeEntityRelations resourceEntity: resourceEntityRelations){
|
|
|
|
- ThemeEntityRelationsVO entityRelation = createEntityRelation(themeDetail.getId(), resourceEntity.getEntityId(), resourceEntity.getEntityType(), resourceEntity.getSortId(), resourceEntity.isPreviewable());
|
|
|
|
- entityVOS.add(themeEntityRelationsVOWrapper.wrapperEntityVO(entityRelation));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- courseVO.setEntityVOList(entityVOS);
|
|
|
|
- return courseVO;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void checkThemeInfo(ThemeDetailVO themeDetailVO) {
|
|
private void checkThemeInfo(ThemeDetailVO themeDetailVO) {
|
|
// 检查主题信息
|
|
// 检查主题信息
|
|
// long currTime = System.currentTimeMillis();
|
|
// long currTime = System.currentTimeMillis();
|
|
@@ -231,6 +224,10 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
public CourseVO updateThemeCourse(CourseVO courseVO, Long userId) {
|
|
public CourseVO updateThemeCourse(CourseVO courseVO, Long userId) {
|
|
// 主题信息
|
|
// 主题信息
|
|
ThemeDetailVO themeDetailVO = courseVO.getThemeDetailVO();
|
|
ThemeDetailVO themeDetailVO = courseVO.getThemeDetailVO();
|
|
|
|
+ // 判断是否有查看当前课程的权限
|
|
|
|
+ checkCourseViewAuth(userId, themeDetailVO);
|
|
|
|
+ // 判断是否具有编辑权限
|
|
|
|
+ checkEditCourseAuth(themeDetailVO.getId());
|
|
if (!themeDetailVO.getOwnerId().equals(userId)) throw new HttpBadRequestException("当前用户无修改此课程的权限");
|
|
if (!themeDetailVO.getOwnerId().equals(userId)) throw new HttpBadRequestException("当前用户无修改此课程的权限");
|
|
if (themeDetailVO == null) throw new HttpBadRequestException("主题内容不可为空");
|
|
if (themeDetailVO == null) throw new HttpBadRequestException("主题内容不可为空");
|
|
// long currTime = System.currentTimeMillis();
|
|
// long currTime = System.currentTimeMillis();
|
|
@@ -238,14 +235,19 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
// if (isThemeTimeInvalid) {
|
|
// if (isThemeTimeInvalid) {
|
|
// throw new HttpBadRequestException("主题课程时间无效");
|
|
// throw new HttpBadRequestException("主题课程时间无效");
|
|
// }
|
|
// }
|
|
|
|
+ boolean admin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
+ // 设置是否公开
|
|
|
|
+ if(admin && themeDetailVO.getVisibility() != CourseVisibility.NONE_OPEN.getVisibility()){
|
|
|
|
+ themeDetailVO.setPublicStatus(ThemeDetail.IS_PUBLIC);
|
|
|
|
+ }else{
|
|
|
|
+ themeDetailVO.setPublicStatus(ThemeDetail.IS_PRIVATE);
|
|
|
|
+ }
|
|
|
|
|
|
// 课程中的实体信息(课程信息、考试信息、练习信息)
|
|
// 课程中的实体信息(课程信息、考试信息、练习信息)
|
|
List<EntityVO> entityVOList = courseVO.getEntityVOList();
|
|
List<EntityVO> entityVOList = courseVO.getEntityVOList();
|
|
|
|
|
|
if(entityVOList.size() != 0){
|
|
if(entityVOList.size() != 0){
|
|
// if(entityVOList.size() > 40) throw new HttpBadRequestException("课程内容(章节、练习、考试)总共不能超过40个");
|
|
// if(entityVOList.size() > 40) throw new HttpBadRequestException("课程内容(章节、练习、考试)总共不能超过40个");
|
|
- // 删除原有的实体
|
|
|
|
- deleteEntityRelationByThemeId(themeDetailVO.getId());
|
|
|
|
checkThemeCourseGroupAndExam(themeDetailVO, entityVOList);
|
|
checkThemeCourseGroupAndExam(themeDetailVO, entityVOList);
|
|
ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
Integer updateStatus = themeStatusService.updateStatus(themeDetail);
|
|
Integer updateStatus = themeStatusService.updateStatus(themeDetail);
|
|
@@ -258,11 +260,12 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
int index = 0;
|
|
int index = 0;
|
|
for(EntityVO entityVO: entityVOList){
|
|
for(EntityVO entityVO: entityVOList){
|
|
index++;
|
|
index++;
|
|
- entityVO.setThemeId(themeDetailVO.getId());
|
|
|
|
- ThemeEntityRelationsVO entityRelation = createEntityRelation(themeDetailVO.getId(), entityVO.getEntityId(), entityVO.getEntityType(), index, Boolean.TRUE);
|
|
|
|
- entityVO.setSortedId(entityRelation.getSortId());
|
|
|
|
|
|
+ ThemeEntityRelations entityRelations = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeDetail.getId(), entityVO.getEntityId(), entityVO.getEntityType());
|
|
|
|
+ entityRelations.setSortId(index);
|
|
|
|
+ themeService.updateEntityRelation(entityRelations);
|
|
}
|
|
}
|
|
- themeDetail.setReleased(getThemeDetailByThemeId(themeDetailVO.getId()).getReleased());
|
|
|
|
|
|
+
|
|
|
|
+ themeDetail.setReleased(getThemeDetailByThemeId(themeDetail.getId()).getReleased());
|
|
courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
}else{
|
|
}else{
|
|
ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
@@ -277,6 +280,68 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
return courseVO;
|
|
return courseVO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void checkCourseViewAuth(Long userId, ThemeDetailVO themeDetailVO) {
|
|
|
|
+ List<User2Theme> user2ThemeList = user2ThemeService.findAllByUserIdAndThemeId(userId, themeDetailVO.getId());
|
|
|
|
+ if(user2ThemeList.size() == 0){
|
|
|
|
+ throw new HttpForbiddenException("当前用户没有查看此课程的权限");
|
|
|
|
+ }
|
|
|
|
+ themeDetailVO.setCanEdit(false);
|
|
|
|
+ for (User2Theme user2Theme : user2ThemeList){
|
|
|
|
+ if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){
|
|
|
|
+ themeDetailVO.setCanEdit(true);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CourseVO forkThemeCourse(ThemeDetailVO forkThemeDetailVO) {
|
|
|
|
+ // 检验课程信息
|
|
|
|
+ checkThemeInfo(forkThemeDetailVO);
|
|
|
|
+ CourseVO courseVO = new CourseVO();
|
|
|
|
+ Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
+ // fork course info
|
|
|
|
+ ThemeDetailVO themeDetailVO = getThemeDetailByThemeId(forkThemeDetailVO.getId());
|
|
|
|
+ ThemeDetail themeDetail = themeVOWrapper.unWrapperThemeDetail(themeDetailVO);
|
|
|
|
+ if(SecurityUtils.getSubject().hasRole("admin")){
|
|
|
|
+ themeDetail.setVisibility(forkThemeDetailVO.getVisibility());
|
|
|
|
+ }else{
|
|
|
|
+ themeDetail.setVisibility(CourseVisibility.NONE_OPEN.getVisibility());
|
|
|
|
+ }
|
|
|
|
+ if(themeDetail.getVisibility() == CourseVisibility.NONE_OPEN.getVisibility()){
|
|
|
|
+ themeDetail.setPublicStatus(ThemeDetail.IS_PRIVATE);
|
|
|
|
+ }
|
|
|
|
+ themeDetail.setId(null);
|
|
|
|
+ themeDetail.setOwnerId(userId);
|
|
|
|
+ themeDetail.setTitle(forkThemeDetailVO.getTitle());
|
|
|
|
+ themeDetail.setBeginTime(new Timestamp(forkThemeDetailVO.getBeginTime()));
|
|
|
|
+ themeDetail.setEndTime(new Timestamp(forkThemeDetailVO.getEndTime()));
|
|
|
|
+ themeDetail.setCourseType(CourseType.CUSTOM.getType());
|
|
|
|
+ themeDetail.setReleased(ThemeDetail.UNRELEASED);
|
|
|
|
+ Integer updateStatusCourse = themeStatusService.updateStatus(themeDetail);
|
|
|
|
+ themeDetail.setStatus(updateStatusCourse);
|
|
|
|
+ themeDetail = themeService.createThemeDetail(themeDetail);
|
|
|
|
+ themeSchedulerService.createNewThemeScheduler(themeDetail);
|
|
|
|
+ theme2GroupService.create(forkThemeDetailVO.getGroupId(), themeDetail.getId());
|
|
|
|
+ user2ThemeService.createOperationRelation(userId, themeDetail.getId(),User2Theme.AUTH_ALL);
|
|
|
|
+ courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
|
|
|
|
+ // fork course resource
|
|
|
|
+ List<EntityVO> entityVOS = new ArrayList<>();
|
|
|
|
+ List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(forkThemeDetailVO.getId());
|
|
|
|
+ List<ThemeEntityRelations> resourceEntityRelations = themeEntityRelations.stream().filter(entityRelation -> entityRelation.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
|
|
+ if(resourceEntityRelations.size() != 0){
|
|
|
|
+ Integer updateStatus = themeEntityRelationsStatusService.updateStatusByTime(themeDetail.getBeginTime().getTime());
|
|
|
|
+ for(ThemeEntityRelations relation: resourceEntityRelations){
|
|
|
|
+ ThemeEntityRelations entityRelation = null;
|
|
|
|
+ entityRelation = themeService.createEntityRelation(themeDetail.getId(),relation.getEntityId(),relation.getEntityType(),relation.getSortId(),relation.isPreviewable(),themeDetail.getBeginTime(),updateStatus);
|
|
|
|
+ themeEntityRelationsSchedulerService.createEntityRelationScheduler(entityRelation);
|
|
|
|
+ entityVOS.add(themeEntityRelationsVOWrapper.wrapperEntityVO(entityRelation));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ courseVO.setEntityVOList(entityVOS);
|
|
|
|
+ return courseVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ThemeDetail releaseThemeCourse(Long themeId) {
|
|
public ThemeDetail releaseThemeCourse(Long themeId) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
@@ -341,7 +406,7 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
@Override
|
|
@Override
|
|
public Page<ThemeDetailVO> getAuthorisedCourses(Pageable pageable, Map<String, String> extraCondition, String keyword) {
|
|
public Page<ThemeDetailVO> getAuthorisedCourses(Pageable pageable, Map<String, String> extraCondition, String keyword) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
- Page<OperationCourse> operationCourseList = themeService.getAuthorizedCourseList(pageable, userId, null, "view", extraCondition, keyword);
|
|
|
|
|
|
+ Page<OperationCourse> operationCourseList = themeService.getAuthorizedCourseList(pageable, userId, null, User2Theme.AUTH_VIEW, extraCondition, keyword);
|
|
return operationCourseList.map(operationCourse -> {
|
|
return operationCourseList.map(operationCourse -> {
|
|
ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
|
|
ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
|
|
return themeVOWrapper.wrapperThemeDetail(convert);
|
|
return themeVOWrapper.wrapperThemeDetail(convert);
|
|
@@ -350,42 +415,40 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
|
|
|
|
// 获取当前教师用户已授权的与keyword有关的资源列表(通过课程展示)
|
|
// 获取当前教师用户已授权的与keyword有关的资源列表(通过课程展示)
|
|
@Override
|
|
@Override
|
|
- public Long[] getAuthorisedResourceList(String keyword) {
|
|
|
|
|
|
+ public Long[] getAuthorisedResourceList(Long themeId, String keyword) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
- // 获取所有已授权的课程
|
|
|
|
- List<OperationCourse> operationCourseList = themeService.getOperationCourseList(userId, "view");
|
|
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+
|
|
|
|
+ // 获取所有已授权的课程(除了当前课程)
|
|
|
|
+ List<OperationCourse> operationCourseList = themeService.getOperationCourseList(userId, User2Theme.AUTH_VIEW).stream()
|
|
|
|
+ .filter(operationCourse -> !operationCourse.getId().equals(themeDetail.getId())).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if(themeDetail.getPublicStatus() == ThemeDetail.IS_PUBLIC){
|
|
|
|
+ operationCourseList = operationCourseList.stream().filter(operationCourse -> operationCourse.getPublicStatus() == ThemeDetail.IS_PUBLIC).collect(Collectors.toList());
|
|
|
|
+ }
|
|
// 获取包含关键字的课程章节对应的已授权课程
|
|
// 获取包含关键字的课程章节对应的已授权课程
|
|
List<List<ThemeEntityRelations>> relationsLists = operationCourseList.stream().map(operationCourse -> themeService.getThemeEntityRelations(operationCourse.getId())).collect(Collectors.toList());
|
|
List<List<ThemeEntityRelations>> relationsLists = operationCourseList.stream().map(operationCourse -> themeService.getThemeEntityRelations(operationCourse.getId())).collect(Collectors.toList());
|
|
Set<Long> themeIdSet = new HashSet<>();
|
|
Set<Long> themeIdSet = new HashSet<>();
|
|
for(List<ThemeEntityRelations> relations : relationsLists){
|
|
for(List<ThemeEntityRelations> relations : relationsLists){
|
|
|
|
+ relations = relations.stream().filter(relationType -> relationType.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
if(relations.size() > 0){
|
|
if(relations.size() > 0){
|
|
for(ThemeEntityRelations relation : relations) {
|
|
for(ThemeEntityRelations relation : relations) {
|
|
-// System.out.println(relation.getId());
|
|
|
|
if(relation != null && relation.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE) && courseResourceService.getCourseResourceByResourceId(relation.getEntityId()).getTitle().contains(keyword)){
|
|
if(relation != null && relation.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE) && courseResourceService.getCourseResourceByResourceId(relation.getEntityId()).getTitle().contains(keyword)){
|
|
themeIdSet.add(relation.getThemeId());
|
|
themeIdSet.add(relation.getThemeId());
|
|
}
|
|
}
|
|
-// if(relation != null) {
|
|
|
|
-// if (relation.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)) {
|
|
|
|
-// System.out.println(relation.getId() + " " + relation.getEntityId());
|
|
|
|
-// CourseResource courseResourceByResourceId = courseResourceService.getCourseResourceByResourceId(relation.getEntityId());
|
|
|
|
-// if (courseResourceByResourceId != null && courseResourceByResourceId.getTitle().contains(keyword)) {
|
|
|
|
-// themeIdSet.add(relation.getThemeId());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 获取包含关键字的已授权课程
|
|
// 获取包含关键字的已授权课程
|
|
operationCourseList.stream().filter(operationCourse -> operationCourse.getTitle().contains(keyword)).map(operationCourse -> themeIdSet.add(operationCourse.getId())).collect(Collectors.toList());
|
|
operationCourseList.stream().filter(operationCourse -> operationCourse.getTitle().contains(keyword)).map(operationCourse -> themeIdSet.add(operationCourse.getId())).collect(Collectors.toList());
|
|
- Long[] themeIdArray = Arrays.stream(themeIdSet.toArray()).map(themeId -> Long.valueOf(themeId.toString())).toArray(Long[]::new);
|
|
|
|
|
|
+ Long[] themeIdArray = Arrays.stream(themeIdSet.toArray()).map(themeDetailId -> Long.valueOf(themeDetailId.toString())).toArray(Long[]::new);
|
|
return themeIdArray;
|
|
return themeIdArray;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<ThemeDetailVO> getCustomizeCourses(Pageable pageable, String keyword) {
|
|
public Page<ThemeDetailVO> getCustomizeCourses(Pageable pageable, String keyword) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
- Page<OperationCourse> operationCourseList = themeService.getCustomizeCourseList(pageable, userId, userId, "*", null, keyword);
|
|
|
|
|
|
+ Page<OperationCourse> operationCourseList = themeService.getCustomizeCourseList(pageable, userId, userId, User2Theme.AUTH_ALL, null, keyword);
|
|
return operationCourseList.map(operationCourse -> {
|
|
return operationCourseList.map(operationCourse -> {
|
|
ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
|
|
ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
|
|
return themeVOWrapper.wrapperThemeDetail(convert);
|
|
return themeVOWrapper.wrapperThemeDetail(convert);
|
|
@@ -484,6 +547,12 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public CourseVO getCourse(Long id, Long userId) {
|
|
public CourseVO getCourse(Long id, Long userId) {
|
|
|
|
+ // 判断教师是否具有查看查看当前课程的权限
|
|
|
|
+ List<User2Theme> user2ThemeList = user2ThemeService.findAllByUserIdAndThemeId(userId, id);
|
|
|
|
+ if(user2ThemeList.size() == 0){
|
|
|
|
+ throw new HttpForbiddenException("当前用户没有查看此课程的权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
ThemeDetail themeDetail = themeService.getThemeDetailById(id);
|
|
ThemeDetail themeDetail = themeService.getThemeDetailById(id);
|
|
userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
// 对于自定义课程 检查用户查看权限
|
|
// 对于自定义课程 检查用户查看权限
|
|
@@ -495,13 +564,27 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 获取课程所有信息 课程信息+实体信息
|
|
|
|
+ CourseVO courseVO = getCourseVO(themeDetail);
|
|
|
|
+
|
|
|
|
+ // 判断是否有权限编辑课程
|
|
|
|
+ courseVO.getThemeDetailVO().setCanEdit(false);
|
|
|
|
+ for (User2Theme user2Theme : user2ThemeList){
|
|
|
|
+ if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){
|
|
|
|
+ courseVO.getThemeDetailVO().setCanEdit(true);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return courseVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private CourseVO getCourseVO(ThemeDetail themeDetail) {
|
|
//根据id查询,然后过滤存map
|
|
//根据id查询,然后过滤存map
|
|
- List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(id);
|
|
|
|
|
|
+ List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(themeDetail.getId());
|
|
Theme theme = new Theme();
|
|
Theme theme = new Theme();
|
|
theme.setThemeDetail(themeDetail);
|
|
theme.setThemeDetail(themeDetail);
|
|
Map<EntityTypeEnum, List<ThemeEntityRelations>> map = themeEntityRelations.stream().collect(Collectors.groupingBy(ThemeEntityRelations::getEntityType));
|
|
Map<EntityTypeEnum, List<ThemeEntityRelations>> map = themeEntityRelations.stream().collect(Collectors.groupingBy(ThemeEntityRelations::getEntityType));
|
|
- for (EntityTypeEnum key: map.keySet()) {
|
|
|
|
- List<ThemeEntityRelations> tmp = map.get(key);
|
|
|
|
|
|
+ for (EntityTypeEnum key : map.keySet()) {
|
|
if (key == EntityTypeEnum.EXAM) {
|
|
if (key == EntityTypeEnum.EXAM) {
|
|
List<Exam> examList = examService.getTasks(map.get(key).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList()));
|
|
List<Exam> examList = examService.getTasks(map.get(key).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList()));
|
|
theme.setExamList(examList);
|
|
theme.setExamList(examList);
|
|
@@ -512,22 +595,19 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
CourseVO courseVO = themeVOWrapper.wrapTheme2CourseVO(theme, themeEntityRelations);
|
|
CourseVO courseVO = themeVOWrapper.wrapTheme2CourseVO(theme, themeEntityRelations);
|
|
- User2Theme user2Theme = user2ThemeService.findByUserIdAndThemeId(userId, id);
|
|
|
|
- // 判断是否有权限编辑课程
|
|
|
|
- if(user2Theme == null || !user2Theme.getOperation().equals("*")){
|
|
|
|
- courseVO.getThemeDetailVO().setCanEdit(false);
|
|
|
|
- }else{
|
|
|
|
- courseVO.getThemeDetailVO().setCanEdit(true);
|
|
|
|
- }
|
|
|
|
|
|
+ return courseVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CourseVO getCourseByStudent(Long id, Long userId) {
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(id);
|
|
|
|
+ //根据id查询,然后过滤存map
|
|
|
|
+ CourseVO courseVO = getCourseVO(themeDetail);
|
|
|
|
|
|
// 获取课程中的实体数量
|
|
// 获取课程中的实体数量
|
|
List<ThemeEntityRelations> entityRelationsList = themeService.getThemeEntityRelations(id);
|
|
List<ThemeEntityRelations> entityRelationsList = themeService.getThemeEntityRelations(id);
|
|
-// if(entityRelationsList.size() != 0){
|
|
|
|
-// courseVO.setCompleteCourseRecourseId(studyCompletenessByThemeId.stream().map(StudyRecord::getEntityId).collect(Collectors.toList()));
|
|
|
|
-// }else{
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
// 获取课程中的考试练习实体
|
|
// 获取课程中的考试练习实体
|
|
|
|
+ courseVO.setCompleteExamAndExerciseId(null);
|
|
List<ThemeEntityRelations> ExamRelationsList = entityRelationsList.stream().filter(entityRelations -> entityRelations.getEntityType() == EntityTypeEnum.EXAM).collect(Collectors.toList());
|
|
List<ThemeEntityRelations> ExamRelationsList = entityRelationsList.stream().filter(entityRelations -> entityRelations.getEntityType() == EntityTypeEnum.EXAM).collect(Collectors.toList());
|
|
if(ExamRelationsList.size() != 0){
|
|
if(ExamRelationsList.size() != 0){
|
|
List<Long> examIdList = ExamRelationsList.stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList());
|
|
List<Long> examIdList = ExamRelationsList.stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList());
|
|
@@ -535,11 +615,7 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
List<SubmitRecord> submitRecordList = submitRecordService.getSubmitScoreList(userId, examIdList);
|
|
List<SubmitRecord> submitRecordList = submitRecordService.getSubmitScoreList(userId, examIdList);
|
|
if(submitRecordList.size() != 0){
|
|
if(submitRecordList.size() != 0){
|
|
courseVO.setCompleteExamAndExerciseId(submitRecordList.stream().map(SubmitRecord::getExamId).collect(Collectors.toList()));
|
|
courseVO.setCompleteExamAndExerciseId(submitRecordList.stream().map(SubmitRecord::getExamId).collect(Collectors.toList()));
|
|
- }else{
|
|
|
|
- courseVO.setCompleteExamAndExerciseId(null);
|
|
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- courseVO.setCompleteExamAndExerciseId(null);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 获取课程下的所有考试和练习id
|
|
// 获取课程下的所有考试和练习id
|
|
@@ -547,20 +623,19 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
courseVO.setTotalExamAndExerciseId(examIdList);
|
|
courseVO.setTotalExamAndExerciseId(examIdList);
|
|
|
|
|
|
// 获取课程下所有章节的id
|
|
// 获取课程下所有章节的id
|
|
- courseVO.setTotalCourseRecourseId(entityRelationsList.stream().filter(entityRelations -> entityRelations.getEntityType() == EntityTypeEnum.COURSE_RESOURCE).map(ThemeEntityRelations::getEntityId).collect(Collectors.toList()));
|
|
|
|
- List<Long> totalCourseRecourseIds = new ArrayList<>(courseVO.getTotalCourseRecourseId());
|
|
|
|
|
|
+ courseVO.setTotalCourseResourceId(entityRelationsList.stream().filter(entityRelations -> entityRelations.getEntityType() == EntityTypeEnum.COURSE_RESOURCE).map(ThemeEntityRelations::getEntityId).collect(Collectors.toList()));
|
|
|
|
+ List<Long> totalCourseResourceIds = new ArrayList<>(courseVO.getTotalCourseResourceId());
|
|
|
|
|
|
// 获取当前学生课程所有章节学习记录(可能有已删除的章节的记录)
|
|
// 获取当前学生课程所有章节学习记录(可能有已删除的章节的记录)
|
|
List<StudyRecord> studyCompletenessByThemeId = themeService.getStudyCompletenessByThemeId(id, userId, EntityTypeEnum.COURSE_RESOURCE);
|
|
List<StudyRecord> studyCompletenessByThemeId = themeService.getStudyCompletenessByThemeId(id, userId, EntityTypeEnum.COURSE_RESOURCE);
|
|
List<Long> studyCompletenessEntityId = studyCompletenessByThemeId.stream().map(StudyRecord::getEntityId).collect(Collectors.toList());
|
|
List<Long> studyCompletenessEntityId = studyCompletenessByThemeId.stream().map(StudyRecord::getEntityId).collect(Collectors.toList());
|
|
|
|
|
|
// 去重 获取当前学生课程有效的已完成的章节学习记录
|
|
// 去重 获取当前学生课程有效的已完成的章节学习记录
|
|
- List<Long> courseRecourseIdRest = new ArrayList<>(totalCourseRecourseIds);
|
|
|
|
- List<Long> courseRecourseIdCommon = new ArrayList<>(totalCourseRecourseIds);
|
|
|
|
- courseRecourseIdRest.removeAll(studyCompletenessEntityId);
|
|
|
|
- courseRecourseIdCommon.removeAll(courseRecourseIdRest);
|
|
|
|
- courseVO.setCompleteCourseRecourseId(courseRecourseIdCommon);
|
|
|
|
-
|
|
|
|
|
|
+ List<Long> courseResourceIdRest = new ArrayList<>(totalCourseResourceIds);
|
|
|
|
+ List<Long> courseResourceIdCommon = new ArrayList<>(totalCourseResourceIds);
|
|
|
|
+ courseResourceIdRest.removeAll(studyCompletenessEntityId);
|
|
|
|
+ courseResourceIdCommon.removeAll(courseResourceIdRest);
|
|
|
|
+ courseVO.setCompleteCourseResourceId(courseResourceIdCommon);
|
|
return courseVO;
|
|
return courseVO;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -603,7 +678,7 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
themeDetailList = themeDetailList.stream().filter(themeDetail -> themeDetail.getCourseType() == type).collect(Collectors.toList());
|
|
themeDetailList = themeDetailList.stream().filter(themeDetail -> themeDetail.getCourseType() == type).collect(Collectors.toList());
|
|
}
|
|
}
|
|
List<CourseVO> courseVOS = themeDetailList.stream().map(themeDetail -> getCourseOfCourseResource(themeDetail.getId())).collect(Collectors.toList());
|
|
List<CourseVO> courseVOS = themeDetailList.stream().map(themeDetail -> getCourseOfCourseResource(themeDetail.getId())).collect(Collectors.toList());
|
|
- return courseVOS.stream().filter(courseVO -> courseVO.getEntityVOList() != null).peek(courseVO -> courseVO.getThemeDetailVO().setEntityVOList(courseVO.getEntityVOList())).collect(Collectors.toList());
|
|
|
|
|
|
+ return courseVOS.stream().filter(courseVO -> courseVO.getEntityVOList().size() != 0).peek(courseVO -> courseVO.getThemeDetailVO().setEntityVOList(courseVO.getEntityVOList())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -625,10 +700,6 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
Map<EntityTypeEnum, List<ThemeEntityRelations>> map = themeEntityRelations.stream().collect(Collectors.groupingBy(ThemeEntityRelations::getEntityType));
|
|
Map<EntityTypeEnum, List<ThemeEntityRelations>> map = themeEntityRelations.stream().collect(Collectors.groupingBy(ThemeEntityRelations::getEntityType));
|
|
for (EntityTypeEnum key: map.keySet()) {
|
|
for (EntityTypeEnum key: map.keySet()) {
|
|
List<ThemeEntityRelations> tmp = map.get(key);
|
|
List<ThemeEntityRelations> tmp = map.get(key);
|
|
-// if (key == EntityTypeEnum.EXAM) {
|
|
|
|
-// List<Exam> examList = examService.getTasks(map.get(key).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList()));
|
|
|
|
-// theme.setExamList(examList);
|
|
|
|
-// }
|
|
|
|
if (key == EntityTypeEnum.COURSE_RESOURCE) {
|
|
if (key == EntityTypeEnum.COURSE_RESOURCE) {
|
|
List<Long> courseIds = map.get(key).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList());
|
|
List<Long> courseIds = map.get(key).stream().map(ThemeEntityRelations::getEntityId).collect(Collectors.toList());
|
|
List<CourseResource> courseResourceList = courseResourceService.getCourseResourceById(courseIds);
|
|
List<CourseResource> courseResourceList = courseResourceService.getCourseResourceById(courseIds);
|
|
@@ -638,19 +709,6 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
return themeVOWrapper.wrapTheme2CourseVO(theme,themeEntityRelations);
|
|
return themeVOWrapper.wrapTheme2CourseVO(theme,themeEntityRelations);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 创建主题相关的实体
|
|
|
|
- * @param themeId
|
|
|
|
- * @param entityId
|
|
|
|
- * @param entityType
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public ThemeEntityRelationsVO createEntityRelation(long themeId, long entityId, EntityTypeEnum entityType, int sortId, boolean previewable) {
|
|
|
|
- ThemeEntityRelations themeEntityRelations = themeService.createEntityRelation(themeId, entityId, entityType, sortId, previewable);
|
|
|
|
- return themeEntityRelationsVOWrapper.wrapperThemeEntityRelations(themeEntityRelations);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public CaseExtendsVO createRelationBetweenThemeAndCase(long themeId, long caseId) {
|
|
public CaseExtendsVO createRelationBetweenThemeAndCase(long themeId, long caseId) {
|
|
ThemeEntityRelations themeEntityRelations = themeService.createRelationBetweenThemeAndEntity(themeId,caseId,EntityTypeEnum.CASE);
|
|
ThemeEntityRelations themeEntityRelations = themeService.createRelationBetweenThemeAndEntity(themeId,caseId,EntityTypeEnum.CASE);
|
|
@@ -713,7 +771,8 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void buyTheme(long userId, long themeId) {
|
|
public void buyTheme(long userId, long themeId) {
|
|
- if(user2ThemeService.findByUserIdAndThemeId(userId,themeId)==null)
|
|
|
|
|
|
+// if(user2ThemeService.findByUserIdAndThemeId(userId,themeId) == null)
|
|
|
|
+ if(user2ThemeService.findAllByUserIdAndThemeId(userId,themeId).size()==0)
|
|
user2ThemeService.createRelation(userId,themeId);
|
|
user2ThemeService.createRelation(userId,themeId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -764,36 +823,61 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
if (groupService.isUserInGroup(userId, theme2Group.getGroupId()))
|
|
if (groupService.isUserInGroup(userId, theme2Group.getGroupId()))
|
|
throw new HttpBadRequestException("请勿重复加入");
|
|
throw new HttpBadRequestException("请勿重复加入");
|
|
groupService.addUserIntoGroup(userId, theme2Group.getGroupId());
|
|
groupService.addUserIntoGroup(userId, theme2Group.getGroupId());
|
|
- user2ThemeService.createOperationRelation(userId, courseId, "view");
|
|
|
|
|
|
+ user2ThemeService.createOperationRelation(userId, courseId, User2Theme.AUTH_VIEW);
|
|
return this.getCourse(courseId);
|
|
return this.getCourse(courseId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public CourseResourceVO createCourseRecourse(CourseResourceVO courseResourceVO) {
|
|
|
|
|
|
+ public CourseResourceVO createCourseResource(CourseResourceVO courseResourceVO) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
- checkCourseResource(courseResourceVO);
|
|
|
|
|
|
+
|
|
|
|
+ // 检验章节信息
|
|
|
|
+ checkCourseResource(userId, courseResourceVO);
|
|
|
|
+ // 根据课程的公开类型 设置章节的公开类型
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(courseResourceVO.getThemeId());
|
|
|
|
+ courseResourceVO.setPublicStatus(themeDetail.getPublicStatus());
|
|
|
|
+ // 根据课程的公开类型 设置章节的默认预览状态
|
|
|
|
+ if(themeDetail.getPublicStatus() == ThemeDetail.IS_PUBLIC){
|
|
|
|
+ courseResourceVO.setPreviewable(false);
|
|
|
|
+ }else{
|
|
|
|
+ courseResourceVO.setPreviewable(true);
|
|
|
|
+ }
|
|
courseResourceVO.setOwnerId(userId);
|
|
courseResourceVO.setOwnerId(userId);
|
|
- courseResourceVO.setPublicStatus(CourseResource.IS_PRIVATE);
|
|
|
|
- CourseResource courseRecourse = courseResourceService.createCourseRecourse(courseResourceVOWrapper.unwrap(courseResourceVO));
|
|
|
|
- ThemeEntityRelations entityRelation = themeService.createEntityRelation(courseResourceVO.getThemeId(), courseRecourse.getId(), EntityTypeEnum.COURSE_RESOURCE, 0, Boolean.TRUE);
|
|
|
|
- CourseResourceVO wrapResult = courseResourceVOWrapper.wrap(courseRecourse);
|
|
|
|
|
|
+ CourseResource courseResource = courseResourceService.createCourseResource(courseResourceVOWrapper.unwrap(courseResourceVO));
|
|
|
|
+ Timestamp releasedTime = themeDetail.getBeginTime();
|
|
|
|
+ Integer updateStatus = themeEntityRelationsStatusService.updateStatusByTime(releasedTime.getTime());
|
|
|
|
+ ThemeEntityRelations entityRelation = themeService.createEntityRelation(courseResourceVO.getThemeId(), courseResource.getId(), EntityTypeEnum.COURSE_RESOURCE, 0, courseResourceVO.isPreviewable(), releasedTime, updateStatus);
|
|
|
|
+ themeEntityRelationsSchedulerService.createEntityRelationScheduler(entityRelation);
|
|
|
|
+ CourseResourceVO wrapResult = courseResourceVOWrapper.wrap(courseResource);
|
|
|
|
+ wrapResult.setCanEdit(true);
|
|
wrapResult.setThemeId(entityRelation.getThemeId());
|
|
wrapResult.setThemeId(entityRelation.getThemeId());
|
|
wrapResult.setEntityId(entityRelation.getEntityId());
|
|
wrapResult.setEntityId(entityRelation.getEntityId());
|
|
|
|
+ wrapResult.setPreviewable(entityRelation.isPreviewable());
|
|
|
|
+ wrapResult.setReleasedTime(releasedTime.getTime());
|
|
|
|
+ wrapResult.setReleasedStatus(entityRelation.getReleaseStatus());
|
|
return wrapResult;
|
|
return wrapResult;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public CourseResourceVO updateCourseResource(CourseResourceVO courseResourceVO) {
|
|
public CourseResourceVO updateCourseResource(CourseResourceVO courseResourceVO) {
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
- checkCourseResource(courseResourceVO);
|
|
|
|
|
|
+ // 检验章节信息
|
|
|
|
+ checkCourseResource(userId, courseResourceVO);
|
|
|
|
+ // 根据课程的公开类型 设置章节的公开类型
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(courseResourceVO.getThemeId());
|
|
|
|
+ courseResourceVO.setPublicStatus(themeDetail.getPublicStatus());
|
|
CourseResourceVO resourceById = getCourseResourceById(courseResourceVO.getId());
|
|
CourseResourceVO resourceById = getCourseResourceById(courseResourceVO.getId());
|
|
if(resourceById.getOwnerId() != null && !resourceById.getOwnerId().equals(userId)){
|
|
if(resourceById.getOwnerId() != null && !resourceById.getOwnerId().equals(userId)){
|
|
throw new HttpBadRequestException("该章节不属于本用户,不可修改");
|
|
throw new HttpBadRequestException("该章节不属于本用户,不可修改");
|
|
}
|
|
}
|
|
CourseResourceVO courseResourceById = getCourseResourceById(courseResourceVO.getId());
|
|
CourseResourceVO courseResourceById = getCourseResourceById(courseResourceVO.getId());
|
|
courseResourceVO.setOwnerId(courseResourceById.getOwnerId());
|
|
courseResourceVO.setOwnerId(courseResourceById.getOwnerId());
|
|
- CourseResource courseRecourse = courseResourceService.updateCourseRecourse(courseResourceVOWrapper.unwrap(courseResourceVO));
|
|
|
|
- return courseResourceVOWrapper.wrap(courseRecourse);
|
|
|
|
|
|
+ CourseResource courseResource = courseResourceService.updateCourseResource(courseResourceVOWrapper.unwrap(courseResourceVO));
|
|
|
|
+ CourseResourceVO wrapResult = courseResourceVOWrapper.wrap(courseResource);
|
|
|
|
+ wrapResult.setCanEdit(true);
|
|
|
|
+ wrapResult.setReleasedTime(courseResourceVO.getReleasedTime());
|
|
|
|
+
|
|
|
|
+ return wrapResult;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -806,10 +890,19 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
if(courseResourceVO.getOwnerId() != null && courseResourceVO.getOwnerId().equals(userId) && courseResourceVO.getPublicStatus() == CourseResource.IS_PRIVATE){
|
|
if(courseResourceVO.getOwnerId() != null && courseResourceVO.getOwnerId().equals(userId) && courseResourceVO.getPublicStatus() == CourseResource.IS_PRIVATE){
|
|
// 删除关联表信息
|
|
// 删除关联表信息
|
|
result = themeService.deleteRelationBetweenThemeAndEntity(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
result = themeService.deleteRelationBetweenThemeAndEntity(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
- CourseResource courseResource = courseResourceVOWrapper.unwrap(courseResourceVO);
|
|
|
|
- courseResource.setDeleted(CourseResource.IS_Deleted);
|
|
|
|
- // 更新章节表信息
|
|
|
|
- courseResourceService.updateCourseRecourse(courseResource);
|
|
|
|
|
|
+// CourseResource courseResource = courseResourceVOWrapper.unwrap(courseResourceVO);
|
|
|
|
+// courseResource.setDeleted(CourseResource.IS_Deleted);
|
|
|
|
+// // 更新章节表信息
|
|
|
|
+// courseResourceService.updateCourseResource(courseResource);
|
|
|
|
+ // 对于与课程没有关联的章节进行伪删除(仅限于自己创建的章节)
|
|
|
|
+ List<CourseResource> courseResourceLists = courseResourceService.getCourseResourceByUserId(userId, CourseResource.NOT_Deleted);
|
|
|
|
+ courseResourceLists.stream().map(courseResource -> {
|
|
|
|
+ if(operationRecourseService.getOperationResourceListByResourceId(courseResource.getId()).size() <= 0){
|
|
|
|
+ courseResource.setDeleted(CourseResource.IS_Deleted);
|
|
|
|
+ courseResourceService.updateCourseResource(courseResource);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
}else{
|
|
}else{
|
|
log.info("该章节不属于本用户,只能删除关联表");
|
|
log.info("该章节不属于本用户,只能删除关联表");
|
|
result = themeService.deleteRelationBetweenThemeAndEntity(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
result = themeService.deleteRelationBetweenThemeAndEntity(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
@@ -823,88 +916,147 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ThemeEntityRelations addCourseRecourse(EntityVO entityVO) {
|
|
|
|
- ThemeEntityRelations themeEntityRelations = themeService
|
|
|
|
- .checkRelationBetweenThemeAndEntity(entityVO.getThemeId(), entityVO.getEntityId(), EntityTypeEnum.COURSE_RESOURCE);
|
|
|
|
- if (themeEntityRelations != null) {
|
|
|
|
- CourseResourceVO courseResourceById = getCourseResourceById(themeEntityRelations.getEntityId());
|
|
|
|
- throw new HttpNotFoundException("课程中已包含章节\""+ courseResourceById.getTitle() +"\",请勿重复添加!");
|
|
|
|
- }
|
|
|
|
- ThemeEntityRelations entityRelation = themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), EntityTypeEnum.COURSE_RESOURCE, 0, Boolean.TRUE);
|
|
|
|
- return entityRelation;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ThemeEntityRelations> addRecourseList(List<EntityVO> entityVOList) {
|
|
|
|
-// List<CourseResourceVO> resourceRepeatList = new ArrayList<>();
|
|
|
|
-// // 对于章节实体
|
|
|
|
-// List<ThemeEntityRelations> entityRelationsList = entityVOList.stream().filter(entityVO -> entityVO.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).map(entityVO -> {
|
|
|
|
-// ThemeEntityRelations themeEntityRelations = themeService
|
|
|
|
-// .checkRelationBetweenThemeAndEntity(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType());
|
|
|
|
-// if (themeEntityRelations != null) {
|
|
|
|
-// CourseResourceVO courseResourceById = getCourseResourceById(themeEntityRelations.getEntityId());
|
|
|
|
-// resourceRepeatList.add(courseResourceById);
|
|
|
|
-// }
|
|
|
|
-// return themeEntityRelations;
|
|
|
|
-// }).collect(Collectors.toList());
|
|
|
|
-// // 存在章节实体
|
|
|
|
-// List<ThemeEntityRelations> entityRelations = new ArrayList<>();
|
|
|
|
-//
|
|
|
|
-// if(entityRelationsList.size() > 0){
|
|
|
|
-// if (resourceRepeatList.size() > 0) {
|
|
|
|
-// List<Long> resourceRepeatIds = new ArrayList<>();
|
|
|
|
-// for(CourseResourceVO courseResourceVO : resourceRepeatList){
|
|
|
|
-// resourceRepeatIds.add(courseResourceVO.getId());
|
|
|
|
-// }
|
|
|
|
-// entityRelations = entityVOList.stream().filter(entityVO -> !resourceRepeatIds.contains(entityVO.getEntityId()) && entityVO.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).map(entityVO -> themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, Boolean.TRUE)).collect(Collectors.toList());
|
|
|
|
-//
|
|
|
|
-// }else{
|
|
|
|
-// entityRelations = entityVOList.stream().filter(entityVO -> entityVO.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).map(entityVO -> themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, Boolean.TRUE)).collect(Collectors.toList());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- // 对于章节实体
|
|
|
|
|
|
+ public List<CourseResourceVO> addRecourseList(List<EntityVO> entityVOList) {
|
|
|
|
+ if(entityVOList.size() <= 0){
|
|
|
|
+ throw new HttpBadRequestException("您未选择章节进行导入,可能导入的章节列表已全部在课程中!");
|
|
|
|
+ }
|
|
|
|
+ Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
+ // 章节实体
|
|
|
|
+ List<CourseResourceVO> courseResourceVOS = entityVOList.stream().filter(entityVO -> entityVO.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).map(entityVO -> {
|
|
|
|
+ // 判断对add的章节是否是 已授权的非自定义课程中的章节
|
|
|
|
+ boolean canAdd = true;
|
|
|
|
+ String message = "";
|
|
|
|
+ CourseResource resource = courseResourceService.getCourseResourceByResourceId(entityVO.getEntityId());
|
|
|
|
+ // 如果存在公开的章节则需要判断
|
|
|
|
+ if(resource.getPublicStatus() == CourseResource.IS_PUBLIC){
|
|
|
|
+ // 根据这些公开章节获取所有已使用当前章节的 公开课程
|
|
|
|
+ List<OperationResource> operationRecourseList = operationRecourseService.getOperationResourceList(userId, User2Theme.AUTH_VIEW, resource.getId(), CourseResource.NOT_Deleted, CourseResource.IS_PUBLIC, ThemeDetail.IS_PUBLIC, ThemeDetail.COURSE, ThemeDetail.NOT_DELETED);
|
|
|
|
+ if(operationRecourseList.size() <= 0){
|
|
|
|
+ canAdd = false;
|
|
|
|
+ message += " \"" + resource.getTitle() + "\"";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- // 对于考试和练习
|
|
|
|
-// List<EntityVO> entityVOS = entityVOList.stream().filter(entityVO -> entityVO.getEntityType().equals(EntityTypeEnum.EXAM)).collect(Collectors.toList());
|
|
|
|
-// // 存在考试和练习实体
|
|
|
|
-// if(entityVOS.size() > 0){
|
|
|
|
-// entityRelations = entityVOList.stream().map(entityVO -> themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, Boolean.TRUE)).collect(Collectors.toList());
|
|
|
|
-// }
|
|
|
|
- List<ThemeEntityRelations> entityRelations = entityVOList.stream().map(entityVO -> themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, Boolean.TRUE)).collect(Collectors.toList());
|
|
|
|
- return entityRelations;
|
|
|
|
|
|
+ if(!canAdd){
|
|
|
|
+ throw new HttpBadRequestException("添加"+message+"章节失败,您未此章节所属公开课程的使用权限!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // entityVO.getThemeId()此时entityVO中传了当前课程的id
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(entityVO.getThemeId());
|
|
|
|
+ // 根据课程的公开类型 设置章节的默认预览状态
|
|
|
|
+ boolean canPreview = true;
|
|
|
|
+ if(themeDetail.getPublicStatus() == ThemeDetail.IS_PUBLIC){
|
|
|
|
+ canPreview = false;
|
|
|
|
+ }
|
|
|
|
+ Integer updateStatus = themeEntityRelationsStatusService.updateStatusByTime(themeDetail.getBeginTime().getTime());
|
|
|
|
+ ThemeEntityRelations entityRelation = themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, canPreview, themeDetail.getBeginTime(), updateStatus);
|
|
|
|
+ if(entityRelation == null){
|
|
|
|
+ throw new HttpBadRequestException("此课程中已包含此章节!");
|
|
|
|
+ }
|
|
|
|
+ themeEntityRelationsSchedulerService.createEntityRelationScheduler(entityRelation);
|
|
|
|
+ CourseResourceVO courseResourceVO = courseResourceVOWrapper.wrap(courseResourceService.getCourseResourceByResourceId(entityRelation.getEntityId()));
|
|
|
|
+ courseResourceVO.setThemeId(entityRelation.getThemeId());
|
|
|
|
+ courseResourceVO.setEntityId(entityRelation.getEntityId());
|
|
|
|
+ courseResourceVO.setEntityType(entityRelation.getEntityType());
|
|
|
|
+ courseResourceVO.setReleasedTime(entityRelation.getReleaseTime().getTime());
|
|
|
|
+ courseResourceVO.setReleasedStatus(entityRelation.getReleaseStatus());
|
|
|
|
+ courseResourceVO.setPreviewable(entityRelation.isPreviewable());
|
|
|
|
+ // 根据课程的所属者 设置章节可编辑状态
|
|
|
|
+ if(courseResourceVO.getOwnerId().equals(userId)){
|
|
|
|
+ courseResourceVO.setCanEdit(true);
|
|
|
|
+ }else{
|
|
|
|
+ courseResourceVO.setCanEdit(false);
|
|
|
|
+ }
|
|
|
|
+ return courseResourceVO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return courseResourceVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ThemeEntityRelationsVO> addExamRecourseList(List<EntityVO> entityVOList) {
|
|
|
|
+ // 考试和练习实体
|
|
|
|
+ List<ThemeEntityRelations> entityRelations = entityVOList.stream().filter(entityVO -> entityVO.getEntityType().equals(EntityTypeEnum.EXAM)).map(entityVO -> {
|
|
|
|
+ ThemeEntityRelations entityRelation = themeService.createEntityRelation(entityVO.getThemeId(), entityVO.getEntityId(), entityVO.getEntityType(), 0, Boolean.TRUE, null, ThemeEntityRelations.RELEASED);
|
|
|
|
+ return entityRelation;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ List<ThemeEntityRelationsVO> relationsVOS = entityRelations.stream().map(themeEntityRelationsVOWrapper::wrapperThemeEntityRelations).collect(Collectors.toList());
|
|
|
|
+ return relationsVOS;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ThemeEntityRelationsVO updateCourseResourcePreview(Long themeId, Long entityId) {
|
|
public ThemeEntityRelationsVO updateCourseResourcePreview(Long themeId, Long entityId) {
|
|
- Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
- boolean isAdmin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
- ThemeDetailVO themeDetailByThemeId = getThemeDetailByThemeId(themeId);
|
|
|
|
- if(themeDetailByThemeId.getPublicStatus() == ThemeDetail.IS_PRIVATE && !themeDetailByThemeId.getOwnerId().equals(userId)){
|
|
|
|
- throw new HttpBadRequestException("当前用户并非此课程的创建者,对此课程没有编辑权限");
|
|
|
|
- }else if(themeDetailByThemeId.getPublicStatus() == ThemeDetail.IS_PUBLIC && !isAdmin){
|
|
|
|
- throw new HttpBadRequestException("当前用户并非管理员,对此公开课程没有编辑权限");
|
|
|
|
|
|
+ checkEditCourseAuth(themeId);
|
|
|
|
+ ThemeEntityRelations relation = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
|
|
+ if (relation == null){
|
|
|
|
+ throw new HttpNotFoundException("课程中不包含此章节");
|
|
}
|
|
}
|
|
|
|
+ relation.setPreviewable(!relation.isPreviewable());
|
|
|
|
+ ThemeEntityRelations themeEntityRelations = themeService.updateEntityRelation(relation);
|
|
|
|
+ return themeEntityRelationsVOWrapper.wrapperThemeEntityRelations(themeEntityRelations);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ThemeEntityRelationsVO updateCourseResourceReleasedTime(Long themeId, Long entityId, Long releasedTime){
|
|
|
|
+ checkEditCourseAuth(themeId);
|
|
ThemeEntityRelations relation = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
ThemeEntityRelations relation = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
if (relation == null){
|
|
if (relation == null){
|
|
throw new HttpNotFoundException("课程中不包含此章节");
|
|
throw new HttpNotFoundException("课程中不包含此章节");
|
|
}
|
|
}
|
|
- ThemeEntityRelations themeEntityRelations = themeService.updateEntityRelation(relation.getId(), themeId, entityId, EntityTypeEnum.COURSE_RESOURCE, relation.getSortId(), !relation.isPreviewable());
|
|
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+ if(releasedTime < themeDetail.getBeginTime().getTime() || releasedTime > themeDetail.getEndTime().getTime()){
|
|
|
|
+ throw new HttpNotFoundException("章节的发布时间应该在课程有效时间区间内");
|
|
|
|
+ }
|
|
|
|
+ ThemeEntityRelations entityRelations = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeId, entityId, EntityTypeEnum.COURSE_RESOURCE);
|
|
|
|
+ themeEntityRelationsSchedulerService.cancelEntityRelationScheduler(entityRelations);
|
|
|
|
+ Integer updateStatus = themeEntityRelationsStatusService.updateStatusByTime(releasedTime);
|
|
|
|
+ entityRelations.setReleaseStatus(updateStatus);
|
|
|
|
+ entityRelations.setReleaseTime(new Timestamp(releasedTime));
|
|
|
|
+ ThemeEntityRelations themeEntityRelations = themeService.updateEntityRelation(entityRelations);
|
|
|
|
+ themeEntityRelationsSchedulerService.createEntityRelationScheduler(themeEntityRelations);
|
|
return themeEntityRelationsVOWrapper.wrapperThemeEntityRelations(themeEntityRelations);
|
|
return themeEntityRelationsVOWrapper.wrapperThemeEntityRelations(themeEntityRelations);
|
|
}
|
|
}
|
|
|
|
|
|
- private void checkCourseResource(CourseResourceVO courseResourceVO) {
|
|
|
|
|
|
+ private void checkEditCourseAuth(Long themeId) {
|
|
|
|
+ Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
|
|
+ boolean isAdmin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+ if (themeDetail.getPublicStatus() == ThemeDetail.IS_PRIVATE && !themeDetail.getOwnerId().equals(userId)) {
|
|
|
|
+ throw new HttpBadRequestException("当前用户并非此课程的创建者,对此课程没有编辑权限");
|
|
|
|
+ } else if (themeDetail.getPublicStatus() == ThemeDetail.IS_PUBLIC && !isAdmin) {
|
|
|
|
+ throw new HttpBadRequestException("当前用户并非管理员,对此公开课程没有编辑权限");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void checkCourseResource(Long userId, CourseResourceVO courseResourceVO) {
|
|
if(courseResourceVO.getTitle() == null){
|
|
if(courseResourceVO.getTitle() == null){
|
|
throw new HttpBadRequestException("章节标题不可为空");
|
|
throw new HttpBadRequestException("章节标题不可为空");
|
|
}
|
|
}
|
|
if(courseResourceVO.getDescription() == null){
|
|
if(courseResourceVO.getDescription() == null){
|
|
throw new HttpBadRequestException("章节描述不可为空");
|
|
throw new HttpBadRequestException("章节描述不可为空");
|
|
}
|
|
}
|
|
|
|
+ List<CourseResource> courseResourceList = courseResourceService.getCourseResourceByUserId(userId, CourseResource.NOT_Deleted).stream()
|
|
|
|
+ .filter(courseResource -> courseResource.getTitle().trim().equals(courseResourceVO.getTitle().trim())).collect(Collectors.toList());
|
|
|
|
+ if(courseResourceList.size() > 0){
|
|
|
|
+ if(courseResourceVO.getId() == null)
|
|
|
|
+ throw new HttpBadRequestException("您已使用过当前章节名称建立章节,请修改章节名称!");
|
|
|
|
+
|
|
|
|
+ courseResourceList.stream().map(courseResource -> {
|
|
|
|
+ if(!courseResource.getId().equals(courseResourceVO.getId())){
|
|
|
|
+ throw new HttpBadRequestException("您已使用过当前章节名称建立章节,请修改章节名称!");
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ThemeInfoVO getThemeInfoByThemeId(Long themeId) {
|
|
public ThemeInfoVO getThemeInfoByThemeId(Long themeId) {
|
|
ThemeInfoVO themeInfoVO = new ThemeInfoVO();
|
|
ThemeInfoVO themeInfoVO = new ThemeInfoVO();
|
|
ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+ if(themeDetail.getReleased() == ThemeDetail.UNRELEASED){
|
|
|
|
+ throw new HttpBadRequestException("当前课程未发布,不可查看教学进度!");
|
|
|
|
+ }
|
|
ThemeDetailVO themeDetailVO = themeVOWrapper.wrapperThemeDetail(themeDetail);
|
|
ThemeDetailVO themeDetailVO = themeVOWrapper.wrapperThemeDetail(themeDetail);
|
|
themeInfoVO.setThemeDetailVO(themeDetailVO);
|
|
themeInfoVO.setThemeDetailVO(themeDetailVO);
|
|
// 获取课程时间进度
|
|
// 获取课程时间进度
|
|
@@ -925,10 +1077,9 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
for(User student : studentList){
|
|
for(User student : studentList){
|
|
studentIds.add(student.getId());
|
|
studentIds.add(student.getId());
|
|
}
|
|
}
|
|
-
|
|
|
|
CourseVO resource = getCourseOfCourseResource(themeId);
|
|
CourseVO resource = getCourseOfCourseResource(themeId);
|
|
List<EntityVO> entityResourceVOList = resource.getEntityVOList().stream().filter(resourceEntity -> resourceEntity.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
List<EntityVO> entityResourceVOList = resource.getEntityVOList().stream().filter(resourceEntity -> resourceEntity.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
- if(entityResourceVOList.size() > 0){
|
|
|
|
|
|
+ if(entityResourceVOList.size() > 0 && studentIds.size() > 0){
|
|
// 课程中存在章节
|
|
// 课程中存在章节
|
|
List<Long> resourceIds = entityResourceVOList.stream().map(EntityVO::getEntityId).collect(Collectors.toList());
|
|
List<Long> resourceIds = entityResourceVOList.stream().map(EntityVO::getEntityId).collect(Collectors.toList());
|
|
int studyRecordNumber = themeService.getStudyRecord(themeId, resourceIds, studentIds, EntityTypeEnum.COURSE_RESOURCE);
|
|
int studyRecordNumber = themeService.getStudyRecord(themeId, resourceIds, studentIds, EntityTypeEnum.COURSE_RESOURCE);
|
|
@@ -973,11 +1124,46 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
}else{
|
|
}else{
|
|
themeInfoVO.setExerciseCompletedRate((float) (totalExerciseCommitNumber/(exerciseCount*studentNumber*1.0)));
|
|
themeInfoVO.setExerciseCompletedRate((float) (totalExerciseCommitNumber/(exerciseCount*studentNumber*1.0)));
|
|
}
|
|
}
|
|
-
|
|
|
|
return themeInfoVO;
|
|
return themeInfoVO;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public List<StudentCourseResultVO> getStudentThemeInfoByThemeId(Long themeId, String keyword){
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+ if(themeDetail.getReleased() == ThemeDetail.UNRELEASED){
|
|
|
|
+ throw new HttpBadRequestException("当前课程未发布,不可查看教学进度!");
|
|
|
|
+ }
|
|
|
|
+ ThemeDetailVO themeDetailVO = themeVOWrapper.wrapperThemeDetail(themeDetail);
|
|
|
|
+ CourseVO resource = getCourseOfCourseResource(themeId);
|
|
|
|
+ List<EntityVO> entityResourceVOList = resource.getEntityVOList().stream().filter(resourceEntity -> resourceEntity.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE)).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 获取每个学生的完整章节的信息
|
|
|
|
+ // 获取课程下所有章节的id
|
|
|
|
+ List<Long> totalCourseResourceIds = entityResourceVOList.stream().map(EntityVO::getEntityId).collect(Collectors.toList());
|
|
|
|
+ // 获取当前课程下的所有学生
|
|
|
|
+ List<User> userList = groupService.getUserByGroupId(themeDetailVO.getGroupId());
|
|
|
|
+ List<StudentCourseResultVO> studentCourseResultVOList = userList.stream().filter(user -> user.getName().contains(keyword.trim())).map(user -> {
|
|
|
|
+ StudentCourseResultVO studentCourseResultVO = new StudentCourseResultVO();
|
|
|
|
+ studentCourseResultVO.setUserVO(userVOWrapper.wrap(user));
|
|
|
|
+ // 获取当前学生课程所有章节学习记录(可能有已删除的章节的记录)
|
|
|
|
+ List<StudyRecord> studyCompletenessByThemeId = themeService.getStudyCompletenessByThemeId(themeId, user.getId(), EntityTypeEnum.COURSE_RESOURCE);
|
|
|
|
+ List<Long> studyCompletenessEntityId = studyCompletenessByThemeId.stream().map(StudyRecord::getEntityId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 去重 获取当前学生课程有效的已完成的章节学习记录
|
|
|
|
+ List<Long> courseResourceIdRest = new ArrayList<>(totalCourseResourceIds);
|
|
|
|
+ List<Long> courseResourceIdCommon = new ArrayList<>(totalCourseResourceIds);
|
|
|
|
+ courseResourceIdRest.removeAll(studyCompletenessEntityId);
|
|
|
|
+ courseResourceIdCommon.removeAll(courseResourceIdRest);
|
|
|
|
+ studentCourseResultVO.setCompleteCourseResourceId(courseResourceIdCommon);
|
|
|
|
+ studentCourseResultVO.setCompleteCourseResourceCount(courseResourceIdCommon.size());
|
|
|
|
+ studentCourseResultVO.setTotalCourseResourceId(totalCourseResourceIds);
|
|
|
|
+ studentCourseResultVO.setTotalCourseResourceCount(totalCourseResourceIds.size());
|
|
|
|
+ return studentCourseResultVO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return studentCourseResultVOList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public void createStudyRecord(Long themeId, Long courseId, Long userId) {
|
|
public void createStudyRecord(Long themeId, Long courseId, Long userId) {
|
|
StudyRecord studyRecord = themeService.getStudyRecordByThemeId(themeId, courseId, userId, EntityTypeEnum.COURSE_RESOURCE);
|
|
StudyRecord studyRecord = themeService.getStudyRecordByThemeId(themeId, courseId, userId, EntityTypeEnum.COURSE_RESOURCE);
|
|
if(studyRecord == null){
|
|
if(studyRecord == null){
|
|
@@ -1003,4 +1189,151 @@ public class ThemeLogicImpl implements ThemeLogic {
|
|
}
|
|
}
|
|
return themeVOWrapper.wrapperThemeDetail(themeService.deleteThemeDetailById(themeId));
|
|
return themeVOWrapper.wrapperThemeDetail(themeService.deleteThemeDetailById(themeId));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ThemeDetailVO> searchCourse(String courseName, Long userId){
|
|
|
|
+ boolean isAdmin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
+ if(!isAdmin){
|
|
|
|
+ throw new HttpBadRequestException("当前用户无此操作权限");
|
|
|
|
+ }
|
|
|
|
+ List<ThemeDetail> themeDetailList = themeService.getThemeDetailByCourseName(courseName);
|
|
|
|
+ return themeDetailList.stream().map(themeVOWrapper::wrapperThemeDetail).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ThemeDetailVO> getTeacherAuthorisedCourses(Long teacherId){
|
|
|
|
+ List<OperationCourse> operationCourseList = themeService.getTeacherAuthorizedCourseListByUse(teacherId, User2Theme.AUTH_USE);
|
|
|
|
+ return operationCourseList.stream().filter(operationCourse -> operationCourse.getPublicStatus() == ThemeDetail.IS_PUBLIC).map(operationCourse -> {
|
|
|
|
+ ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
|
|
|
|
+ return themeVOWrapper.wrapperThemeDetail(convert);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean authorisedCoursesList(Long teacherId, List<Long> courseIdList){
|
|
|
|
+ // 判断教师是否具有自定义课程教师的角色
|
|
|
|
+ List<Role> roleIdsOfUser = roleService.getRolesOfUser(teacherId);
|
|
|
|
+ Role courseTeacher = roleService.getRoleByRoleName("courseTeacher");
|
|
|
|
+ if(!roleIdsOfUser.contains(courseTeacher)){
|
|
|
|
+ throw new HttpBadRequestException("当前教师并无自定义课程的权限,请先赋予教师权限后进行操作!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(courseIdList.size() <= 0){
|
|
|
|
+ throw new HttpBadRequestException("未选择授权课程!");
|
|
|
|
+ }
|
|
|
|
+ courseIdList.stream().peek(courseId -> {
|
|
|
|
+ List<User2Theme> user2ThemeList = user2ThemeService.findAllByUserIdAndThemeId(teacherId, courseId);
|
|
|
|
+ if(user2ThemeList.size() > 0){
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(courseId);
|
|
|
|
+ user2ThemeList.stream().peek(user2Theme -> {
|
|
|
|
+ if(user2Theme.getOperation().equals(User2Theme.AUTH_USE)){
|
|
|
|
+ throw new HttpBadRequestException("该教师已有\""+themeDetail.getTitle()+"\"课程的使用权限!");
|
|
|
|
+ }else if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){
|
|
|
|
+ throw new HttpBadRequestException("该教师已有\""+themeDetail.getTitle()+"\"课程的所有权限!");
|
|
|
|
+ }
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ courseIdList.stream().peek(courseId -> {
|
|
|
|
+ user2ThemeService.createOperationRelation(teacherId, courseId, User2Theme.AUTH_USE);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void authorisedCourseTeacherRole(Long teacherId, Long userId){
|
|
|
|
+ // 为教师赋予慕测教师、教师自定义课程的角色
|
|
|
|
+ List<Role> roleIdsOfUser = roleService.getRolesOfUser(teacherId);
|
|
|
|
+ Role courseTeacher = roleService.findById(9L);
|
|
|
|
+// Role mooctestTeacher = roleService.getRoleByRoleName("mooctestTeacher");
|
|
|
|
+// if(!roleIdsOfUser.contains(mooctestTeacher)){
|
|
|
|
+// user2RoleService.addRole2User(teacherId, mooctestTeacher.getId());
|
|
|
|
+// }
|
|
|
|
+ if(!roleIdsOfUser.contains(courseTeacher)){
|
|
|
|
+ user2RoleService.addRole2User(teacherId, courseTeacher.getId());
|
|
|
|
+ }else{
|
|
|
|
+ List<User2Role> user2RoleList = user2RoleService.getRole2User(teacherId, courseTeacher.getId());
|
|
|
|
+ user2RoleService.deleteRole2User(user2RoleList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean checkCourseTeacherRole(Long teacherId, Long userId){
|
|
|
|
+ // 查看教师是否具有教师自定义课程的角色
|
|
|
|
+ List<Role> roleIdsOfUser = roleService.getRolesOfUser(teacherId);
|
|
|
|
+ Role courseTeacher = roleService.findById(9L);
|
|
|
|
+ return roleIdsOfUser.contains(courseTeacher);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean deleteAuthorisedCourse(Long teacherId, Long courseId){
|
|
|
|
+ // 判断教师是否具有自定义课程教师的角色
|
|
|
|
+ List<Role> roleIdsOfUser = roleService.getRolesOfUser(teacherId);
|
|
|
|
+ Role courseTeacher = roleService.getRoleByRoleName("courseTeacher");
|
|
|
|
+ if(!roleIdsOfUser.contains(courseTeacher)){
|
|
|
|
+ throw new HttpBadRequestException("当前教师并无自定义课程的权限,请先赋予教师权限后进行操作!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ User2Theme user2Theme = user2ThemeService.findByUserIdAndThemeIdAndOperation(teacherId, courseId, User2Theme.AUTH_USE);
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(courseId);
|
|
|
|
+ if(user2Theme == null){
|
|
|
|
+ throw new HttpBadRequestException("当前教师并无\""+themeDetail.getTitle()+"\"的使用权限!");
|
|
|
|
+ }
|
|
|
|
+ user2ThemeService.delete(user2Theme);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CourseVO orderThemeDetailEntity(Long themeId, List<EntityVO> entityVOList){
|
|
|
|
+ int index = 0;
|
|
|
|
+ for(EntityVO entityVO: entityVOList){
|
|
|
|
+ index++;
|
|
|
|
+ ThemeEntityRelations entityRelations = themeService.getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(themeId, entityVO.getEntityId(), entityVO.getEntityType());
|
|
|
|
+ entityRelations.setSortId(index);
|
|
|
|
+ themeService.updateEntityRelation(entityRelations);
|
|
|
|
+ }
|
|
|
|
+ ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
|
|
|
|
+ return getCourseVO(themeDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean initEntityRelationReleaseStatus(Long userId){
|
|
|
|
+ boolean admin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
+ if(!admin){
|
|
|
|
+ throw new HttpBadRequestException("不是管理员用户,没有此权限!");
|
|
|
|
+ }
|
|
|
|
+ List<ThemeDetail> themeDetailList = themeService.getThemeDetailByIdList(Lists.newArrayList(29L));
|
|
|
|
+ themeDetailList.stream().map(themeDetail -> {
|
|
|
|
+ return themeService.getThemeEntityRelations(themeDetail.getId()).stream().filter(themeEntityRelations -> themeEntityRelations.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE))
|
|
|
|
+ .map(themeEntityRelations -> {
|
|
|
|
+ themeEntityRelations.setReleaseTime(themeDetail.getBeginTime());
|
|
|
|
+ themeEntityRelations.setReleaseStatus(ThemeEntityRelations.RELEASED);
|
|
|
|
+ System.out.println(themeEntityRelations.getEntityId());
|
|
|
|
+ themeService.updateEntityRelation(themeEntityRelations);
|
|
|
|
+ return null;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean initEntityRelationListReleaseStatus(Long userId, List<Long> themeIdList){
|
|
|
|
+ boolean admin = SecurityUtils.getSubject().hasRole("admin");
|
|
|
|
+ if(!admin){
|
|
|
|
+ throw new HttpBadRequestException("不是管理员用户,没有此权限!");
|
|
|
|
+ }
|
|
|
|
+ List<ThemeDetail> themeDetailList = themeService.getThemeDetailByIdList(themeIdList);
|
|
|
|
+ themeDetailList.stream().map(themeDetail -> {
|
|
|
|
+ return themeService.getThemeEntityRelations(themeDetail.getId()).stream().filter(themeEntityRelations -> themeEntityRelations.getEntityType().equals(EntityTypeEnum.COURSE_RESOURCE))
|
|
|
|
+ .map(themeEntityRelations -> {
|
|
|
|
+ themeEntityRelations.setReleaseTime(themeDetail.getBeginTime());
|
|
|
|
+ themeEntityRelations.setReleaseStatus(ThemeEntityRelations.RELEASED);
|
|
|
|
+ System.out.println(themeEntityRelations.getEntityId());
|
|
|
|
+ themeService.updateEntityRelation(themeEntityRelations);
|
|
|
|
+ return null;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|