|
|
|
package com.teaching.backend.controller.resource;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author:youhang
|
|
|
|
* @Date:2024-06-09-9:55
|
|
|
|
* @Description:
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import com.teaching.backend.common.BaseResponse;
|
|
|
|
import com.teaching.backend.model.dto.resource.ResourceUploadDto;
|
|
|
|
import com.teaching.backend.model.entity.resource.Resources;
|
|
|
|
import com.teaching.backend.service.resource.ResourceService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.core.io.InputStreamResource;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/api/resource")
|
|
|
|
public class ResourceController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private ResourceService resourceService;
|
|
|
|
|
|
|
|
|
|
|
|
//添加知识点
|
|
|
|
@PostMapping("/upload")
|
|
|
|
@ResponseBody
|
|
|
|
public BaseResponse<Resources> uploadFile(@RequestPart("file") MultipartFile file) {
|
|
|
|
return resourceService.upload(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除资源
|
|
|
|
@GetMapping ("delete")
|
|
|
|
@ResponseBody
|
|
|
|
public BaseResponse<String> deleteResource(@RequestParam("filename") String filename) {
|
|
|
|
return resourceService.delete(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/read")
|
|
|
|
public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) {
|
|
|
|
return resourceService.readFile(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/addRelationship/BetweenCourseAndResources")
|
|
|
|
public BaseResponse<String> addResourcesAndKnowByCourseId(@RequestParam String courseId, @RequestParam List<Long> resourcesIds){
|
|
|
|
return resourceService.addResourcesAndKnowByCourseId(courseId,resourcesIds);
|
|
|
|
}
|
|
|
|
@GetMapping("/addRelationship/BetweenChapterAndResources")
|
|
|
|
public BaseResponse<String> addResourcesAndKnowByChapterId(@RequestParam Long chapterId,@RequestParam List<Long> resourcesIds){
|
|
|
|
return resourceService.addResourcesAndKnowByChapterId(chapterId,resourcesIds);
|
|
|
|
}
|
|
|
|
@GetMapping("/addRelationship/BetweenKnowAndResources")
|
|
|
|
public BaseResponse<String> addResourcesAndKnowById(@RequestParam Long id, @RequestParam List<Long> resourcesIds){
|
|
|
|
return resourceService.addResourcesAndKnowById(id,resourcesIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询课程下资源
|
|
|
|
@GetMapping("/queryByCourseId")
|
|
|
|
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){
|
|
|
|
return resourceService.queryResourcesByCourseId(courseId);
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询章节下资源
|
|
|
|
@GetMapping("/queryByChapterId")
|
|
|
|
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){
|
|
|
|
return resourceService.queryResourcesByChapterId(chapterId);
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询二级节点下资源
|
|
|
|
@GetMapping("/queryBesidesKnow")
|
|
|
|
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long KnowId){
|
|
|
|
return resourceService.queryBesidesKnowToResources(KnowId);
|
|
|
|
}
|
|
|
|
//查询知识点下资源
|
|
|
|
@GetMapping("/queryResourcesByKnowId")
|
|
|
|
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long KnowId){
|
|
|
|
return resourceService.queryResourcesByKnowId(KnowId);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|