mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-22 00:39:32 +08:00
课程接口权限
This commit is contained in:
parent
0b47ddc173
commit
cc4833df60
@ -5,9 +5,11 @@ import org.springframework.context.ApplicationContext;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import xyz.playedu.api.PlayEduBackendThreadLocal;
|
import xyz.playedu.api.PlayEduBackendThreadLocal;
|
||||||
|
import xyz.playedu.api.constant.BPermissionConstant;
|
||||||
import xyz.playedu.api.domain.CourseChapter;
|
import xyz.playedu.api.domain.CourseChapter;
|
||||||
import xyz.playedu.api.event.CourseChapterDestroyEvent;
|
import xyz.playedu.api.event.CourseChapterDestroyEvent;
|
||||||
import xyz.playedu.api.exception.NotFoundException;
|
import xyz.playedu.api.exception.NotFoundException;
|
||||||
|
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||||
import xyz.playedu.api.request.backend.CourseChapterRequest;
|
import xyz.playedu.api.request.backend.CourseChapterRequest;
|
||||||
import xyz.playedu.api.service.CourseChapterService;
|
import xyz.playedu.api.service.CourseChapterService;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
@ -36,6 +38,7 @@ public class CourseChapterController {
|
|||||||
return JsonResponse.data(chapters);
|
return JsonResponse.data(chapters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
|
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
|
||||||
List<CourseChapter> chapters = chapterService.getChaptersByCourseId(courseId);
|
List<CourseChapter> chapters = chapterService.getChaptersByCourseId(courseId);
|
||||||
@ -44,18 +47,21 @@ public class CourseChapterController {
|
|||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public JsonResponse store(@PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseChapterRequest req) {
|
public JsonResponse store(@PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseChapterRequest req) {
|
||||||
chapterService.create(courseId, req.getName(), req.getSort());
|
chapterService.create(courseId, req.getName(), req.getSort());
|
||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public JsonResponse edit(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
public JsonResponse edit(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||||
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
||||||
return JsonResponse.data(chapter);
|
return JsonResponse.data(chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public JsonResponse update(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id, @RequestBody @Validated CourseChapterRequest req) throws NotFoundException {
|
public JsonResponse update(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id, @RequestBody @Validated CourseChapterRequest req) throws NotFoundException {
|
||||||
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
||||||
@ -63,6 +69,7 @@ public class CourseChapterController {
|
|||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public JsonResponse destroy(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
public JsonResponse destroy(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||||
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
CourseChapter chapter = chapterService.findOrFail(id, courseId);
|
||||||
|
@ -6,10 +6,12 @@ import org.springframework.context.ApplicationContext;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import xyz.playedu.api.PlayEduBackendThreadLocal;
|
import xyz.playedu.api.PlayEduBackendThreadLocal;
|
||||||
|
import xyz.playedu.api.constant.BPermissionConstant;
|
||||||
import xyz.playedu.api.domain.CourseHour;
|
import xyz.playedu.api.domain.CourseHour;
|
||||||
import xyz.playedu.api.event.CourseHourCreatedEvent;
|
import xyz.playedu.api.event.CourseHourCreatedEvent;
|
||||||
import xyz.playedu.api.event.CourseHourDestroyEvent;
|
import xyz.playedu.api.event.CourseHourDestroyEvent;
|
||||||
import xyz.playedu.api.exception.NotFoundException;
|
import xyz.playedu.api.exception.NotFoundException;
|
||||||
|
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||||
import xyz.playedu.api.request.backend.CourseHourRequest;
|
import xyz.playedu.api.request.backend.CourseHourRequest;
|
||||||
import xyz.playedu.api.service.CourseHourService;
|
import xyz.playedu.api.service.CourseHourService;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
@ -37,11 +39,13 @@ public class CourseHourController {
|
|||||||
return JsonResponse.data(hours);
|
return JsonResponse.data(hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
|
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
|
||||||
return JsonResponse.data(null);
|
return JsonResponse.data(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public JsonResponse store(@PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseHourRequest req) {
|
public JsonResponse store(@PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseHourRequest req) {
|
||||||
CourseHour courseHour = hourService.create(courseId, req.getChapterId(), req.getTitle(), req.getType(), req.getDuration(), req.getPublishedAt());
|
CourseHour courseHour = hourService.create(courseId, req.getChapterId(), req.getTitle(), req.getType(), req.getDuration(), req.getPublishedAt());
|
||||||
@ -49,12 +53,14 @@ public class CourseHourController {
|
|||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public JsonResponse edit(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
public JsonResponse edit(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||||
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
||||||
return JsonResponse.data(courseHour);
|
return JsonResponse.data(courseHour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public JsonResponse update(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id, @RequestBody @Validated CourseHourRequest req) throws NotFoundException {
|
public JsonResponse update(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id, @RequestBody @Validated CourseHourRequest req) throws NotFoundException {
|
||||||
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
||||||
@ -62,6 +68,7 @@ public class CourseHourController {
|
|||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public JsonResponse destroy(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
public JsonResponse destroy(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||||
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user