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 io.swagger.annotations.Api; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiOperation; 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") @Api(tags= "资源管理") public class ResourceController { @Autowired private ResourceService resourceService; //添加知识点 @PostMapping("/upload") @ResponseBody @ApiOperation(value = "添加资源") public BaseResponse uploadFile(@RequestPart("file") MultipartFile file) { return resourceService.upload(file); } //删除资源 @GetMapping ("delete") @ResponseBody @ApiOperation(value = "删除资源") public BaseResponse deleteResource(@RequestParam("filename") String filename) { return resourceService.delete(filename); } @GetMapping("/read") @ApiOperation(value = "查询资源") public ResponseEntity readFile(@RequestParam String filename) { return resourceService.readFile(filename); } }