图谱-后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.1 KiB

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