55 lines
1.6 KiB
55 lines
1.6 KiB
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.entity.resource.ResourceMysql; |
|
import com.teaching.backend.model.entity.resource.Resources; |
|
import com.teaching.backend.service.resource.ResourceService; |
|
import io.swagger.annotations.Api; |
|
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; |
|
|
|
|
|
@RestController |
|
@RequestMapping("/api/resource") |
|
@Api(tags= "资源管理") |
|
public class ResourceController { |
|
|
|
@Autowired |
|
private ResourceService resourceService; |
|
|
|
|
|
//添加知识点 |
|
@PostMapping("/upload") |
|
@ResponseBody |
|
@ApiOperation(value = "添加资源") |
|
public BaseResponse<Resources> uploadFile(@RequestPart("file") MultipartFile file) { |
|
return resourceService.upload(file); |
|
} |
|
|
|
//删除资源 |
|
@GetMapping ("delete") |
|
@ResponseBody |
|
@ApiOperation(value = "删除资源") |
|
public BaseResponse<String> deleteResource(@RequestParam("filename") String filename) { |
|
return resourceService.delete(filename); |
|
} |
|
|
|
@GetMapping("/read") |
|
@ApiOperation(value = "查询资源") |
|
public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) { |
|
return resourceService.readFile(filename); |
|
} |
|
|
|
|
|
}
|
|
|