From 4ad20c0f51b436476bb01e8c2eb2fa7aa07f591c Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Wed, 25 Jun 2025 17:08:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=BA=97=E9=93=BA=E5=90=8D=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/mobile/StoreController.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/StoreController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/StoreController.java index e93ac01c..f18a4b90 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/StoreController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/StoreController.java @@ -278,12 +278,18 @@ public class StoreController extends BaseControllerImpl { */ @ApiOperation("检查店铺名是否已存在?") @RequestMapping(value = "/check-store-name-exists", method = RequestMethod.POST) - public CommonResult checkStoreNameExists(@RequestBody JSONObject paramsJSON, + public CommonResult checkStoreNameExists(@RequestBody(required = false) JSONObject paramsJSON, @RequestParam(name = "storeName", required = false) String storeName) { - // 优先从请求体中获取店铺名称 - String storeNameFromJson = paramsJSON.getStr("storeName"); - if (StrUtil.isNotBlank(storeNameFromJson)) { - storeName = storeNameFromJson; + if (paramsJSON == null && StrUtil.isBlank(storeName)) { + return CommonResult.failed("参数错误"); + } + + if (paramsJSON != null) { + // 优先从请求体中获取店铺名称 + String storeNameFromJson = paramsJSON.getStr("storeName"); + if (StrUtil.isNotBlank(storeNameFromJson)) { + storeName = storeNameFromJson; + } } // 如果店铺名称为空,直接返回失败结果 @@ -297,10 +303,10 @@ public class StoreController extends BaseControllerImpl { if (Boolean.TRUE.equals(exists)) { // 店铺名已存在 - return CommonResult.success(new JSONObject().set("flag", 2), "店铺名已被使用!"); + return CommonResult.success(new JSONObject().set("flag", 2), storeName + "店铺名已被使用!"); } else { // 店铺名不存在 - return CommonResult.success(new JSONObject().set("flag", 1), "店铺名可以使用!"); + return CommonResult.success(new JSONObject().set("flag", 1), storeName + "店铺名可以使用!"); } } catch (Exception e) { // 捕获异常并返回统一的错误信息