From fcedb14704bebc79f305a4cc1a065ea238639ebc Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Thu, 24 Dec 2020 16:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=96=87=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jxc/file/controller/FileController.java | 19 +++++++++++-------- .../jxc/controller/FileController.java | 16 ++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/java/cloud/web/file/src/main/java/cn/toesbieya/jxc/file/controller/FileController.java b/java/cloud/web/file/src/main/java/cn/toesbieya/jxc/file/controller/FileController.java index 884acbc..4efc3ba 100644 --- a/java/cloud/web/file/src/main/java/cn/toesbieya/jxc/file/controller/FileController.java +++ b/java/cloud/web/file/src/main/java/cn/toesbieya/jxc/file/controller/FileController.java @@ -2,31 +2,34 @@ package cn.toesbieya.jxc.file.controller; import cn.toesbieya.jxc.common.model.vo.R; import cn.toesbieya.jxc.file.service.FileService; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -@Controller +@RestController @RequestMapping("file") public class FileController { @Resource private FileService service; @GetMapping("delete") - @ResponseBody public R delete(@RequestParam String url) throws UnsupportedEncodingException { service.delete(URLDecoder.decode(url, "utf-8")); return R.success("删除成功"); } + @PostMapping("deleteBatch") + public R deleteBatch(@RequestBody String[] urls) { + if (urls.length == 0) { + return R.fail("参数错误"); + } + service.deleteBatch(urls); + return R.success("批量删除成功"); + } + @GetMapping("getToken") - @ResponseBody public R getToken() { return R.success(null, service.getToken()); } diff --git a/java/local/src/main/java/cn/toesbieya/jxc/controller/FileController.java b/java/local/src/main/java/cn/toesbieya/jxc/controller/FileController.java index 53ff67a..16fe2c3 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/controller/FileController.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/controller/FileController.java @@ -2,11 +2,7 @@ package cn.toesbieya.jxc.controller; import cn.toesbieya.jxc.model.vo.R; import cn.toesbieya.jxc.service.FileService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; @@ -14,7 +10,6 @@ import java.net.URLDecoder; @RestController @RequestMapping("file") -@Slf4j public class FileController { @Resource private FileService service; @@ -25,6 +20,15 @@ public class FileController { return R.success("删除成功"); } + @PostMapping("deleteBatch") + public R deleteBatch(@RequestBody String[] urls) { + if (urls.length == 0) { + return R.fail("参数错误"); + } + service.deleteBatch(urls); + return R.success("批量删除成功"); + } + @GetMapping("getToken") public R getToken() { return R.success(null, service.getToken());