瀏覽代碼

修改获取教师已授权课程列表(不包含自定义课程)

guochao 5 年之前
父節點
當前提交
2de184b490

+ 2 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/OperationCourseDao.java

@@ -16,4 +16,6 @@ public interface OperationCourseDao extends PagingAndSortingRepository<Operation
     List<OperationCourse> findAllByUserId(Long userId);
 
     List<OperationCourse> findAllByUserIdAndOperationNotAndIsDeleted(Long userId, String operation, int isDeleted);
+
+    List<OperationCourse> findAllByUserIdAndOperationAndIsDeleted(Long userId, String operation, int isDeleted);
 }

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/ThemeService.java

@@ -72,5 +72,5 @@ public interface ThemeService {
 
     List<ThemeDetail> getThemeDetailByCourseName(String courseName);
 
-    List<OperationCourse> getTeacherAuthorizedCourseList(Long teacherId, String operation);
+    List<OperationCourse> getTeacherAuthorizedCourseListByUse(Long teacherId, String operation);
 }

+ 2 - 2
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/impl/ThemeServiceImpl.java

@@ -515,7 +515,7 @@ public class ThemeServiceImpl implements ThemeService {
     }
 
     @Override
-    public List<OperationCourse> getTeacherAuthorizedCourseList(Long teacherId, String operation){
-        return operationCourseDao.findAllByUserIdAndOperationNotAndIsDeleted(teacherId, operation, 0);
+    public List<OperationCourse> getTeacherAuthorizedCourseListByUse(Long teacherId, String operation){
+        return operationCourseDao.findAllByUserIdAndOperationAndIsDeleted(teacherId, operation, 0);
     }
 }

+ 10 - 13
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ThemeLogicImpl.java

@@ -151,7 +151,7 @@ public class ThemeLogicImpl implements ThemeLogic {
             themeSchedulerService.createNewThemeScheduler(themeDetail);
             themeDetailVO.setId(themeDetail.getId());
             theme2GroupService.create(themeDetailVO.getGroupId(), themeDetailVO.getId());
-            user2ThemeService.createOperationRelation(userId,themeDetail.getId(),"*");
+            user2ThemeService.createOperationRelation(userId,themeDetail.getId(),User2Theme.AUTH_ALL);
             ThemeDetailVO themeDetailVOResult = themeVOWrapper.wrapperThemeDetail(themeDetail);
             themeDetailVOResult.setCanEdit(true);
             courseVO.setThemeDetailVO(themeDetailVOResult);
@@ -181,7 +181,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         themeDetail = themeService.createThemeDetail(themeDetail);
         themeSchedulerService.createNewThemeScheduler(themeDetail);
         theme2GroupService.create(forkThemeDetailVO.getGroupId(), themeDetail.getId());
-        user2ThemeService.createOperationRelation(userId, themeDetail.getId(),"*");
+        user2ThemeService.createOperationRelation(userId, themeDetail.getId(),User2Theme.AUTH_ALL);
         courseVO.setThemeDetailVO(themeVOWrapper.wrapperThemeDetail(themeDetail));
         // fork course resource
         List<EntityVO> entityVOS = new ArrayList<>();
@@ -292,8 +292,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         }
         themeDetailVO.setCanEdit(false);
         for (User2Theme user2Theme : user2ThemeList){
-            System.out.println(user2Theme.getOperation());
-            if(user2Theme.getOperation().equals("*")){
+            if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){
                 themeDetailVO.setCanEdit(true);
                 break;
             }
@@ -364,7 +363,7 @@ public class ThemeLogicImpl implements ThemeLogic {
     @Override
     public Page<ThemeDetailVO> getAuthorisedCourses(Pageable pageable, Map<String, String> extraCondition, String keyword) {
         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 -> {
             ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
             return themeVOWrapper.wrapperThemeDetail(convert);
@@ -378,7 +377,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
 
         // 获取所有已授权的课程(除了当前课程)
-        List<OperationCourse> operationCourseList = themeService.getOperationCourseList(userId, "view").stream()
+        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){
@@ -405,7 +404,7 @@ public class ThemeLogicImpl implements ThemeLogic {
     @Override
     public Page<ThemeDetailVO> getCustomizeCourses(Pageable pageable, String keyword) {
         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 -> {
             ThemeDetail convert = Converter.convert(ThemeDetail.class, operationCourse);
             return themeVOWrapper.wrapperThemeDetail(convert);
@@ -541,8 +540,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         // 判断是否有权限编辑课程
         courseVO.getThemeDetailVO().setCanEdit(false);
         for (User2Theme user2Theme : user2ThemeList){
-            System.out.println(user2Theme.getOperation());
-            if(user2Theme.getOperation().equals("*")){
+            if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){
                 courseVO.getThemeDetailVO().setCanEdit(true);
                 break;
             }
@@ -812,7 +810,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         if (groupService.isUserInGroup(userId, theme2Group.getGroupId()))
             throw new HttpBadRequestException("请勿重复加入");
         groupService.addUserIntoGroup(userId, theme2Group.getGroupId());
-        user2ThemeService.createOperationRelation(userId, courseId, "view");
+        user2ThemeService.createOperationRelation(userId, courseId, User2Theme.AUTH_VIEW);
         return this.getCourse(courseId);
     }
 
@@ -1098,8 +1096,8 @@ public class ThemeLogicImpl implements ThemeLogic {
 
     @Override
     public  List<ThemeDetailVO>  getTeacherAuthorisedCourses(Long teacherId){
-        List<OperationCourse> operationCourseList = themeService.getTeacherAuthorizedCourseList(teacherId, "view");
-        return operationCourseList.stream().map(operationCourse -> {
+        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());
@@ -1122,7 +1120,6 @@ public class ThemeLogicImpl implements ThemeLogic {
             if(user2ThemeList.size() > 0){
                 ThemeDetail themeDetail = themeService.getThemeDetailById(courseId);
                 user2ThemeList.stream().peek(user2Theme -> {
-                    System.out.println(user2Theme.getOperation());
                     if(user2Theme.getOperation().equals(User2Theme.AUTH_USE)){
                         throw new HttpBadRequestException("该教师已有\""+themeDetail.getTitle()+"\"课程的使用权限!");
                     }else if(user2Theme.getOperation().equals(User2Theme.AUTH_ALL)){