|
|
@@ -1,11 +1,17 @@
|
|
|
package nju.seec.helper.web.controller;
|
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
import nju.seec.helper.logic.service.SlideService;
|
|
|
import nju.seec.helper.logic.vo.SlideVO;
|
|
|
import nju.seec.helper.web.dto.SlideDTO;
|
|
|
import nju.seec.helper.web.response.EmptyResponse;
|
|
|
import nju.seec.helper.web.response.PageResourceResponse;
|
|
|
import nju.seec.helper.web.response.ResourceResponse;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.web.PageableDefault;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -14,6 +20,8 @@ import java.util.List;
|
|
|
/**
|
|
|
* @author cst
|
|
|
*/
|
|
|
+@Api(tags = "幻灯片")
|
|
|
+@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST})
|
|
|
@RestController
|
|
|
@RequestMapping("/api/slide")
|
|
|
public class SlideController {
|
|
|
@@ -23,34 +31,43 @@ public class SlideController {
|
|
|
this.slideService = slideService;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "教师基于课程ID和关键字获取创建的幻灯片列表", notes = "支持定制化分页排序,例:" + "/course/seec?page=3&size=10&sort=id,asc&sort=name,desc" + ",即以id正向排序再以name倒序排序,请求第3页,返回10条数据")
|
|
|
@GetMapping("/course/{courseId}")
|
|
|
public PageResourceResponse<SlideVO> getSlides(@PathVariable String courseId,
|
|
|
- @RequestParam(defaultValue = "1") int page,
|
|
|
- @RequestParam(defaultValue = Integer.MAX_VALUE + "") int size,
|
|
|
- @RequestParam(defaultValue = "") String key) {
|
|
|
- List<SlideVO> slideVOs = slideService.getSlides(courseId, page, size, key);
|
|
|
- return PageResourceResponse.of(slideVOs, PageResourceResponse.PageInfo.of(page, slideVOs.size()));
|
|
|
+ @RequestParam(defaultValue = "") String key,
|
|
|
+ @ApiParam(hidden = true) @PageableDefault(size = Integer.MAX_VALUE, sort = "updateTime", direction = Sort.Direction.DESC) Pageable pageable) {
|
|
|
+ List<SlideVO> slideVOs = slideService.getSlides(courseId, key, pageable);
|
|
|
+ return PageResourceResponse.of(slideVOs, PageResourceResponse.PageInfo.of(pageable.getPageNumber(), slideVOs.size()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "教师基于关键字获取创建的幻灯片列表", notes = "支持定制化分页排序,例:" + "/course/seec?page=3&size=10&sort=id,asc&sort=name,desc" + ",即以id正向排序再以name倒序排序,请求第3页,返回10条数据")
|
|
|
+ @GetMapping("")
|
|
|
+ public PageResourceResponse<SlideVO> getSlides(@RequestParam(defaultValue = "") String key,
|
|
|
+ @ApiParam(hidden = true) @PageableDefault(size = Integer.MAX_VALUE, sort = "updateTime", direction = Sort.Direction.DESC) Pageable pageable) {
|
|
|
+ List<SlideVO> slideVOs = slideService.getSlides(key, pageable);
|
|
|
+ return PageResourceResponse.of(slideVOs, PageResourceResponse.PageInfo.of(pageable.getPageNumber(), slideVOs.size()));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 迭代一只考虑返回给老师的结果
|
|
|
- *
|
|
|
- * @param slideId
|
|
|
- * @return
|
|
|
- */
|
|
|
@GetMapping("/{slideId:\\d+}")
|
|
|
public ResourceResponse<SlideVO> getSlide(@PathVariable int slideId) {
|
|
|
return ResourceResponse.of(slideService.getOneSlide(slideId));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
public ResourceResponse<SlideVO> create(@RequestBody @Validated SlideDTO slideDTO) {
|
|
|
return ResourceResponse.of(slideService.create(slideDTO));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
- public EmptyResponse update(@RequestBody @Validated SlideDTO slideDTO) {
|
|
|
- slideService.update(slideDTO);
|
|
|
+ public ResourceResponse<SlideVO> update(@RequestBody @Validated SlideDTO slideDTO) {
|
|
|
+ return ResourceResponse.of(slideService.update(slideDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete/{slideId:\\d+}")
|
|
|
+ public EmptyResponse delete(@PathVariable int slideId) {
|
|
|
+ slideService.delete(slideId);
|
|
|
return EmptyResponse.getInstance();
|
|
|
}
|
|
|
}
|