|
@@ -0,0 +1,65 @@
|
|
|
+package com.example.controller.user;
|
|
|
+
|
|
|
+import com.example.dto.PageQueryDTO;
|
|
|
+import com.example.dto.ResourceDTO;
|
|
|
+import com.example.entity.Resource;
|
|
|
+import com.example.result.PageResult;
|
|
|
+import com.example.result.Result;
|
|
|
+import com.example.service.ResourceService;
|
|
|
+import com.example.vo.ResourceVO;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.ibatis.annotations.Delete;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@Slf4j
|
|
|
+@Api(tags = "共享资源库相关接口")
|
|
|
+@RequestMapping("/resources")
|
|
|
+public class ResourceController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResourceService resourceService;
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "共享资料库上传")
|
|
|
+ public Result upload(@RequestBody ResourceDTO resourceDTO) {
|
|
|
+ log.info("共享资料库上传:{}", resourceDTO);
|
|
|
+ resourceService.upload(resourceDTO);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/{id}")
|
|
|
+ @ApiOperation(value = "更新指定资料库")
|
|
|
+ public Result update(@RequestBody ResourceDTO resourceDTO, @PathVariable Long id) {
|
|
|
+ log.info("更新指定共享资料库:{}", resourceDTO);
|
|
|
+ resourceService.update(resourceDTO, id);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ @ApiOperation(value = "删除指定资料")
|
|
|
+ public Result delete(@PathVariable Long id) {
|
|
|
+ log.info("删除指定资料:{}", id);
|
|
|
+ resourceService.delete(id);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ @ApiOperation(value = "查询指定资料")
|
|
|
+ public Result<ResourceVO> getById(@PathVariable Long id) {
|
|
|
+ log.info("查询指定资料:{}", id);
|
|
|
+ ResourceVO resourceVO = resourceService.getById(id);
|
|
|
+ return Result.success(resourceVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ public Result<PageResult> getAll(PageQueryDTO pageQueryDTO){
|
|
|
+ log.info("资料库分页展示,参数:{},{}",pageQueryDTO.getPage(),pageQueryDTO.getPageSize());
|
|
|
+
|
|
|
+ PageResult pageResult=resourceService.getAll(pageQueryDTO);
|
|
|
+ return Result.success(pageResult);
|
|
|
+ }
|
|
|
+}
|