|
@@ -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;
|
|
|
+ }
|
|
|
}
|