增加一个检查店铺名是否可以使用接口

This commit is contained in:
Jack 2025-06-25 17:08:59 +08:00
parent 9fa875038b
commit 4ad20c0f51

View File

@ -278,13 +278,19 @@ 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) {
if (paramsJSON == null && StrUtil.isBlank(storeName)) {
return CommonResult.failed("参数错误");
}
if (paramsJSON != null) {
// 优先从请求体中获取店铺名称
String storeNameFromJson = paramsJSON.getStr("storeName");
if (StrUtil.isNotBlank(storeNameFromJson)) {
storeName = storeNameFromJson;
}
}
// 如果店铺名称为空直接返回失败结果
if (StrUtil.isBlank(storeName)) {
@ -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) {
// 捕获异常并返回统一的错误信息