From 0b27181f37334781e1cc552cf098616d162bb18d Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 9 Nov 2022 16:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AdminController.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index 223bc5cd..7fecb6e7 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -13,16 +13,10 @@ import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Api(tags = "管理员后台") @@ -37,16 +31,30 @@ public class AdminController { private String active; // 现有生效 - /** - * @param updateFile 更新包下载地址 - * @param active 重启完成后的配置环境 - * @return - */ +// /** +// * @param updateFile 更新包下载地址 +// * @param active 重启完成后的配置环境 +// * @return +// */ +// @PostMapping(value = "/update") +// public Result update(String updateFile, String active) { +// if (StringUtils.isEmpty(active)) { +// active = this.active; +// } +// boolean success = updateUtil.update(updateFile, active); +// return new Result().ok(String.valueOf(success)); +// } + @PostMapping(value = "/update") - public Result update(String updateFile, String active) { + public Result update(@RequestBody Map params) { + String updateFile = params.containsKey("updateFile") ? params.get("String updateFile") : null; + String active = params.containsKey("active") ? params.get("active") : null; if (StringUtils.isEmpty(active)) { active = this.active; } + if (StringUtils.isEmpty(updateFile)) { + return new Result().ok(String.valueOf(false)); + } boolean success = updateUtil.update(updateFile, active); return new Result().ok(String.valueOf(success)); }