增加一个检查店铺名是否可以使用接口
This commit is contained in:
parent
9fa875038b
commit
4ad20c0f51
@ -278,12 +278,18 @@ public class StoreController extends BaseControllerImpl {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("检查店铺名是否已存在?")
|
@ApiOperation("检查店铺名是否已存在?")
|
||||||
@RequestMapping(value = "/check-store-name-exists", method = RequestMethod.POST)
|
@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) {
|
@RequestParam(name = "storeName", required = false) String storeName) {
|
||||||
// 优先从请求体中获取店铺名称
|
if (paramsJSON == null && StrUtil.isBlank(storeName)) {
|
||||||
String storeNameFromJson = paramsJSON.getStr("storeName");
|
return CommonResult.failed("参数错误");
|
||||||
if (StrUtil.isNotBlank(storeNameFromJson)) {
|
}
|
||||||
storeName = storeNameFromJson;
|
|
||||||
|
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)) {
|
if (Boolean.TRUE.equals(exists)) {
|
||||||
// 店铺名已存在
|
// 店铺名已存在
|
||||||
return CommonResult.success(new JSONObject().set("flag", 2), "店铺名已被使用!");
|
return CommonResult.success(new JSONObject().set("flag", 2), storeName + "店铺名已被使用!");
|
||||||
} else {
|
} else {
|
||||||
// 店铺名不存在
|
// 店铺名不存在
|
||||||
return CommonResult.success(new JSONObject().set("flag", 1), "店铺名可以使用!");
|
return CommonResult.success(new JSONObject().set("flag", 1), storeName + "店铺名可以使用!");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 捕获异常并返回统一的错误信息
|
// 捕获异常并返回统一的错误信息
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user