Przeglądaj źródła

增加管理员授权课程接口

guochao 5 lat temu
rodzic
commit
97728fddf7

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/ThemeDetailDao.java

@@ -38,7 +38,7 @@ public interface ThemeDetailDao extends PagingAndSortingRepository<ThemeDetail,L
     @Query("update ThemeDetail t set t.status = :status where t.id= :id")
     void updateStatusById(@Param("id") Long id, @Param("status") int status);
 
-
+    List<ThemeDetail> findAllByTitleLikeAndVisibilityAndReleasedAndIsDeleted(String courseName,int visibility,int released, int isDeleted);
 
     List<ThemeDetail> findAllByVisibilityIsNot(int visibility);
 }

+ 9 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/User2ThemeDao.java

@@ -1,8 +1,12 @@
 package cn.iselab.mooctest.site.dao;
 
 import cn.iselab.mooctest.site.models.User2Theme;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
 
+import javax.transaction.Transactional;
 import java.util.List;
 
 /**
@@ -11,8 +15,13 @@ import java.util.List;
  * @author: menduo
  * @create: 2019-06-03 15:04
  **/
+@Transactional
 public interface User2ThemeDao extends CrudRepository<User2Theme,Long> {
     User2Theme findByUserIdAndThemeId(long userId,long themeId);
     List<User2Theme> findByUserId(long userId);
+
+    @Modifying
+    @Query("update User2Theme u2t set u2t.operation = :operation where u2t.id= :id")
+    void updateOperationById(@Param("id") long id, @Param("operation") String operation);
 }
 

+ 2 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/models/ThemeDetail.java

@@ -30,6 +30,8 @@ public class ThemeDetail {
     public static final Integer IS_PUBLIC = 0;
     public static final Integer IS_PRIVATE = 1;
 
+
+
 //    public static final Byte TYPE_Web = 0;
 //    public static final Byte TYPE_mobile = 1;
 //    public static final Byte TYPE_python = 2;

+ 5 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/models/User2Theme.java

@@ -18,6 +18,11 @@ import javax.persistence.*;
 @NoArgsConstructor
 @AllArgsConstructor
 public class User2Theme {
+
+    public static final String AUTH_VIEW = "view";
+    public static final String AUTH_USE = "use";
+    public static final String AUTH_ALL = "*";
+
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private long id;

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

@@ -69,4 +69,8 @@ public interface ThemeService {
     Page<ThemeDetail> getPlatformThemeDetails(Map<String, String> extraCondition, Map<String, String> excludeCondition, Pageable pageable, String keyword);
 
     ThemeEntityRelations getThemeEntityRelationsByThemeIdAndEntityIdAndEntityType(Long themeId, Long entityId, EntityTypeEnum courseResource);
+
+    List<ThemeDetail> getThemeDetailByCourseName(String courseName);
+
+    List<OperationCourse> getTeacherAuthorizedCourseList(Long teacherId, String operation);
 }

+ 3 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/User2ThemeService.java

@@ -1,6 +1,8 @@
 package cn.iselab.mooctest.site.service;
 
 import cn.iselab.mooctest.site.models.User2Theme;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
 
 import java.util.List;
 
@@ -14,5 +16,6 @@ public interface User2ThemeService {
     void createRelation(long userId, long themeId);
     void createOperationRelation(long userId, long themeId, String operation);
     User2Theme findByUserIdAndThemeId(long userId, long themeId);
+    void updateOperationById(long id, String operation);
     List<User2Theme> findByUserId(long userId);
 }

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

@@ -508,4 +508,14 @@ public class ThemeServiceImpl implements ThemeService {
             return predicate;
         };
     }
+
+    @Override
+    public List<ThemeDetail> getThemeDetailByCourseName(String courseName){
+        return themeDetailDao.findAllByTitleLikeAndVisibilityAndReleasedAndIsDeleted("%"+courseName+"%", CourseVisibility.PART_OPEN.getVisibility(), ThemeDetail.RELEASED, 0);
+    }
+
+    @Override
+    public List<OperationCourse> getTeacherAuthorizedCourseList(Long teacherId, String operation){
+        return operationCourseDao.findAllByUserIdAndOperationNotAndIsDeleted(teacherId, operation, 0);
+    }
 }

+ 5 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/impl/User2ThemeServiceImpl.java

@@ -34,6 +34,11 @@ public class User2ThemeServiceImpl implements User2ThemeService {
     }
 
     @Override
+    public void updateOperationById(long id, String operation) {
+        user2ThemeDao.updateOperationById(id, operation);
+    }
+
+    @Override
     public List<User2Theme> findByUserId(long userId) {
         return user2ThemeDao.findByUserId(userId);
     }

+ 116 - 70
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/ThemeController.java

@@ -17,6 +17,7 @@ import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
 import org.springframework.web.bind.annotation.*;
@@ -382,74 +383,6 @@ public class ThemeController extends BaseSearchController {
         return new ResponseVO<>(ServerCode.SUCCESS,themeDetailVO);
     }
 
-
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/case/{caseId}", method = RequestMethod.PUT)
-    @RequiresPermissions(value = "theme:create")
-    public ResponseVO<CaseExtendsVO> addCases2theme(@PathVariable("themeId")long themeId, @PathVariable("caseId") long caseId) {
-        CaseExtendsVO caseExtendsVO = themeLogic.createRelationBetweenThemeAndCase(themeId,caseId);
-        return new ResponseVO<>(ServerCode.SUCCESS, caseExtendsVO);
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/paper/{paperId}", method = RequestMethod.PUT)
-    @RequiresPermissions(value = "theme:create")
-    public ResponseVO addPapers2theme(@PathVariable("themeId")long themeId, @PathVariable("paperId") long paperId) {
-        PaperVO paperVO = themeLogic.createRelationBetweenThemeAndPaper(themeId, paperId);
-        return new ResponseVO<>(ServerCode.SUCCESS, paperVO);
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/exam/{examId}", method = RequestMethod.PUT)
-    @RequiresPermissions(value = "theme:create")
-    public ResponseVO addExams2theme(@PathVariable("themeId")long themeId, @PathVariable("examId") long examId) {
-        ExamVO examVO = themeLogic.createRelationBetweenThemeAndExam(themeId, examId);
-        return new ResponseVO<>(ServerCode.SUCCESS, examVO);
-    }
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/case/{caseId}", method = RequestMethod.DELETE)
-    @RequiresPermissions(value = "theme:delete")
-    public ResponseVO<Boolean> removeCaseFromtheme(@PathVariable("themeId")long themeId, @PathVariable("caseId") long caseId) {
-        boolean result = themeLogic.deleteRelationBetweenThemeAndCase(themeId,caseId);
-        return new ResponseVO<>(ServerCode.SUCCESS, result);
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/paper/{paperId}", method = RequestMethod.DELETE)
-    @RequiresPermissions(value = "theme:delete")
-    public ResponseVO<Boolean> removePaperFromtheme(@PathVariable("themeId")long themeId, @PathVariable("paperId") long paperId) {
-        boolean result = themeLogic.deleteRelationBetweenThemeAndPaper(themeId,paperId);
-        return new ResponseVO<>(ServerCode.SUCCESS, result);
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/exam/{examId}", method = RequestMethod.DELETE)
-    @RequiresPermissions(value = "theme:delete")
-    public ResponseVO<Boolean> removeExamFromtheme(@PathVariable("themeId")long themeId, @PathVariable("examId") long examId) {
-        boolean result = themeLogic.deleteRelationBetweenThemeAndExam(themeId, examId);
-        return new ResponseVO<>(ServerCode.SUCCESS, result);
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/case/{caseId}", method = RequestMethod.GET)
-    public ResponseVO<List<ThemeDetailVO>> getThemesHasTheCase(@PathVariable("caseId")long caseId) {
-        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(caseId));
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/paper/{paperId}", method = RequestMethod.GET)
-    public ResponseVO<List<ThemeDetailVO>> getThemesHasThePaper(@PathVariable("paperId")long paperId) {
-        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(paperId));
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/exam/{examId}", method = RequestMethod.GET)
-    public ResponseVO<List<ThemeDetailVO>> getThemesHasTheExam(@PathVariable("examId")long examId) {
-        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(examId));
-    }
-
-    @RequestMapping(value = UrlConstants.API + "theme/courses", method = RequestMethod.GET)
-    public ResponseVO<List<CourseVO>> getCourses() {
-        List<CourseVO> courseVOList = themeLogic.getCourses();
-        return new ResponseVO<>(ServerCode.SUCCESS,courseVOList);
-    }
-
-    @Override
-    public Page<?> search(String searchCondition) {
-        return null;
-    }
-
     @RequestMapping(value = UrlConstants.API + "theme/buy/{themeId}", method = RequestMethod.GET)
     @RequiresPermissions(value = "theme:buy")
     public ResponseVO buyTheme(@PathVariable("themeId")long themeId) {
@@ -537,7 +470,11 @@ public class ThemeController extends BaseSearchController {
         return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getParticipantCourses(userId, extraCondition, keyword, pageable));
     }
 
-    // 教师查看课程
+    /**
+     * 教师查看课程
+     * @param courseId
+     * @return
+     */
     @GetMapping(value = UrlConstants.API + "course/{courseId}")
     public ResponseVO<CourseVO> course(@PathVariable("courseId")Long courseId) {
         Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
@@ -550,7 +487,11 @@ public class ThemeController extends BaseSearchController {
         return new ResponseVO<>(ServerCode.SUCCESS, courseVO);
     }
 
-    // 学生查看课程
+    /**
+     * 学生查看课程
+     * @param courseId
+     * @return
+     */
     @GetMapping(value = UrlConstants.API + "student/course/{courseId}")
     public ResponseVO<CourseVO> getCourseByStudent(@PathVariable("courseId")Long courseId) {
         Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
@@ -595,4 +536,109 @@ public class ThemeController extends BaseSearchController {
         log.info("加入课程,课程ID:{},用户ID为:{}",courseId ,userId);
         return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.joinCourse(courseId,userId));
     }
+
+    /**
+     * 管理员为教师授权课程-查找课程(公共的、已发布的、未删除的、付费课程)
+     * @param courseName
+     * @return
+     */
+    @RequiresRoles(value = "manager")
+    @GetMapping(value = UrlConstants.API + "manage/course/search/{courseName}")
+    public ResponseVO<List<ThemeDetailVO>> searchCourse( @PathVariable("courseName") String courseName) {
+        Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
+        log.info("查找课程名称:{},用户ID为:{}",courseName ,userId);
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.searchCourse(courseName,userId));
+    }
+
+    /**
+     * 管理员为教师授权课程-获取教师已授权的课程(包含自定义未发布的课程)
+     * @param teacherId
+     * @return
+     */
+    @RequiresRoles(value = "manager")
+    @GetMapping(value = UrlConstants.API + "authorised/courses/{teacherId}")
+    public ResponseVO<List<ThemeDetailVO>> getTeacherAuthorisedCourses(@PathVariable(name = "teacherId") Long teacherId) {
+        Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
+        log.info("userId: {}获取教师已授权课程,参数:{}",userId,teacherId);
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getTeacherAuthorisedCourses(teacherId));
+    }
+
+    /**
+     * 管理员为教师授权课程-授权课程
+     * @return
+     */
+    @RequiresRoles(value = "manager")
+    @PostMapping(value = UrlConstants.API + "authorised/courses/{teacherId}")
+    public ResponseVO<Boolean> authorisedTeacherCourses(@PathVariable(name = "teacherId") Long teacherId, @RequestBody List<Long> courseIdList) {
+        Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
+        log.info("userId: {}授权课程,参数:{}",userId,teacherId);
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.authorisedCoursesList(teacherId,courseIdList));
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/case/{caseId}", method = RequestMethod.PUT)
+    @RequiresPermissions(value = "theme:create")
+    public ResponseVO<CaseExtendsVO> addCases2theme(@PathVariable("themeId")long themeId, @PathVariable("caseId") long caseId) {
+        CaseExtendsVO caseExtendsVO = themeLogic.createRelationBetweenThemeAndCase(themeId,caseId);
+        return new ResponseVO<>(ServerCode.SUCCESS, caseExtendsVO);
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/paper/{paperId}", method = RequestMethod.PUT)
+    @RequiresPermissions(value = "theme:create")
+    public ResponseVO addPapers2theme(@PathVariable("themeId")long themeId, @PathVariable("paperId") long paperId) {
+        PaperVO paperVO = themeLogic.createRelationBetweenThemeAndPaper(themeId, paperId);
+        return new ResponseVO<>(ServerCode.SUCCESS, paperVO);
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/exam/{examId}", method = RequestMethod.PUT)
+    @RequiresPermissions(value = "theme:create")
+    public ResponseVO addExams2theme(@PathVariable("themeId")long themeId, @PathVariable("examId") long examId) {
+        ExamVO examVO = themeLogic.createRelationBetweenThemeAndExam(themeId, examId);
+        return new ResponseVO<>(ServerCode.SUCCESS, examVO);
+    }
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/case/{caseId}", method = RequestMethod.DELETE)
+    @RequiresPermissions(value = "theme:delete")
+    public ResponseVO<Boolean> removeCaseFromtheme(@PathVariable("themeId")long themeId, @PathVariable("caseId") long caseId) {
+        boolean result = themeLogic.deleteRelationBetweenThemeAndCase(themeId,caseId);
+        return new ResponseVO<>(ServerCode.SUCCESS, result);
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/paper/{paperId}", method = RequestMethod.DELETE)
+    @RequiresPermissions(value = "theme:delete")
+    public ResponseVO<Boolean> removePaperFromtheme(@PathVariable("themeId")long themeId, @PathVariable("paperId") long paperId) {
+        boolean result = themeLogic.deleteRelationBetweenThemeAndPaper(themeId,paperId);
+        return new ResponseVO<>(ServerCode.SUCCESS, result);
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/{themeId}/exam/{examId}", method = RequestMethod.DELETE)
+    @RequiresPermissions(value = "theme:delete")
+    public ResponseVO<Boolean> removeExamFromtheme(@PathVariable("themeId")long themeId, @PathVariable("examId") long examId) {
+        boolean result = themeLogic.deleteRelationBetweenThemeAndExam(themeId, examId);
+        return new ResponseVO<>(ServerCode.SUCCESS, result);
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/case/{caseId}", method = RequestMethod.GET)
+    public ResponseVO<List<ThemeDetailVO>> getThemesHasTheCase(@PathVariable("caseId")long caseId) {
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(caseId));
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/paper/{paperId}", method = RequestMethod.GET)
+    public ResponseVO<List<ThemeDetailVO>> getThemesHasThePaper(@PathVariable("paperId")long paperId) {
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(paperId));
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/exam/{examId}", method = RequestMethod.GET)
+    public ResponseVO<List<ThemeDetailVO>> getThemesHasTheExam(@PathVariable("examId")long examId) {
+        return new ResponseVO<>(ServerCode.SUCCESS, themeLogic.getThemeDetailListByCase(examId));
+    }
+
+    @RequestMapping(value = UrlConstants.API + "theme/courses", method = RequestMethod.GET)
+    public ResponseVO<List<CourseVO>> getCourses() {
+        List<CourseVO> courseVOList = themeLogic.getCourses();
+        return new ResponseVO<>(ServerCode.SUCCESS,courseVOList);
+    }
+
+    @Override
+    public Page<?> search(String searchCondition) {
+        return null;
+    }
 }

+ 1 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/data/CourseResourceVO.java

@@ -25,6 +25,7 @@ public class CourseResourceVO extends EntityVO {
     private int sliderImagesCount;
     private String sliderCover;
     private String description;
+    private boolean previewable;
     private int publicStatus;
     private int released;
 }

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/data/EntityVO.java

@@ -17,6 +17,6 @@ public class EntityVO {
     private int sortedId;
     private Long releasedTime;
     private int releasedStatus;
-    private boolean previewable;
+//    private boolean previewable;
     private boolean inGroup;
 }

+ 6 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/ThemeLogic.java

@@ -122,4 +122,10 @@ public interface ThemeLogic{
     ThemeEntityRelationsVO updateCourseResourcePreview(Long themeId, Long entityId);
 
     ThemeEntityRelationsVO updateCourseResourceReleasedTime(Long themeId, Long entityId, Long releasedTime);
+
+    List<ThemeDetailVO> searchCourse(String courseName, Long userId);
+
+    List<ThemeDetailVO>  getTeacherAuthorisedCourses(Long teacherId);
+
+    Boolean authorisedCoursesList(Long teacherId, List<Long> courseIdList);
 }

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

@@ -23,6 +23,7 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import javax.mail.Session;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -588,10 +589,6 @@ public class ThemeLogicImpl implements ThemeLogic {
     @Override
     public CourseVO getCourseByStudent(Long id, Long userId) {
         ThemeDetail themeDetail = themeService.getThemeDetailById(id);
-        // 检查用户是否加入课程
-        Theme2Group t2g = theme2GroupService.findByThemeId(themeDetail.getId());
-        boolean inGroup = groupService.isUserInGroup(userId,t2g.getGroupId());
-
         //根据id查询,然后过滤存map
         List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(id);
         Theme theme = new Theme();
@@ -609,8 +606,15 @@ public class ThemeLogicImpl implements ThemeLogic {
             }
         }
         CourseVO courseVO = themeVOWrapper.wrapTheme2CourseVO(theme, themeEntityRelations);
-        List<EntityVO> entityVOS = courseVO.getEntityVOList().stream().peek(entityVO -> entityVO.setInGroup(inGroup)).collect(Collectors.toList());
-        courseVO.setEntityVOList(entityVOS);
+
+        // 检查用户是否加入课程
+
+        Theme2Group t2g = theme2GroupService.findByThemeId(themeDetail.getId());
+        if(t2g!= null){
+            boolean inGroup = groupService.isUserInGroup(userId,t2g.getGroupId());
+            List<EntityVO> entityVOS = courseVO.getEntityVOList().stream().peek(entityVO -> entityVO.setInGroup(inGroup)).collect(Collectors.toList());
+            courseVO.setEntityVOList(entityVOS);
+        }
         return courseVO;
     }
 
@@ -1009,10 +1013,9 @@ public class ThemeLogicImpl implements ThemeLogic {
         for(User student : studentList){
             studentIds.add(student.getId());
         }
-
         CourseVO resource = getCourseOfCourseResource(themeId);
         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());
             int studyRecordNumber = themeService.getStudyRecord(themeId, resourceIds, studentIds, EntityTypeEnum.COURSE_RESOURCE);
@@ -1087,4 +1090,51 @@ public class ThemeLogicImpl implements ThemeLogic {
         }
         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.getTeacherAuthorizedCourseList(teacherId, "view");
+        return operationCourseList.stream().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){
+        if(courseIdList.size() <= 0){
+            throw new HttpBadRequestException("未选择授权课程!");
+        }
+        courseIdList.stream().peek(courseId -> {
+            User2Theme user2Theme = user2ThemeService.findByUserIdAndThemeId(teacherId, courseId);
+            if(user2Theme != null){
+                ThemeDetail themeDetail = themeService.getThemeDetailById(user2Theme.getThemeId());
+                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());
+
+        courseIdList.stream().peek(courseId -> {
+            User2Theme user2Theme = user2ThemeService.findByUserIdAndThemeId(teacherId, courseId);
+            if(user2Theme != null){
+                user2ThemeService.updateOperationById(user2Theme.getId(), User2Theme.AUTH_USE);
+            }else{
+                user2ThemeService.createOperationRelation(teacherId, courseId, User2Theme.AUTH_USE);
+            }
+        }).collect(Collectors.toList());
+        return true;
+    }
 }