增加一个检查店铺名是否可以使用接口
This commit is contained in:
parent
cf2605ae64
commit
9fa875038b
@ -3,6 +3,7 @@ package com.suisung.mall.shop.store.controller.mobile;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -251,18 +252,60 @@ public class StoreController extends BaseControllerImpl {
|
||||
|
||||
@ApiOperation(value = "获取附近店铺列表", notes = "获取附近店铺列表")
|
||||
@RequestMapping(value = "/near/list", method = RequestMethod.GET)
|
||||
public CommonResult nearStoreList(@RequestParam(value = "provinceId",required = false) String provinceId,
|
||||
public CommonResult nearStoreList(@RequestParam(value = "provinceId", required = false) String provinceId,
|
||||
@RequestParam("cityId") String cityId,
|
||||
@RequestParam("countyId") String countyId,
|
||||
@RequestParam("userLng") String userLng,
|
||||
@RequestParam("userLat") String userLat,
|
||||
@RequestParam(value = "storeCategoryId", required = false) Integer storeCategoryId,
|
||||
@RequestParam(value = "subSiteId",required = false) Integer subSiteId,
|
||||
@RequestParam(value = "storeName",required = false) String storeName,
|
||||
@RequestParam(value = "subSiteId", required = false) Integer subSiteId,
|
||||
@RequestParam(value = "storeName", required = false) String storeName,
|
||||
@RequestParam("pageNum") Integer pageNum,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
IPage<Map> storeList = shopStoreBaseService.getNearShop2(provinceId, cityId, countyId, userLng, userLat, storeCategoryId, subSiteId, storeName, pageNum, pageSize);
|
||||
return CommonResult.success(storeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查店铺名称是否已存在。
|
||||
* <p>
|
||||
* 支持通过请求体或请求参数传入店铺名称。若两者都未提供,则返回错误信息。
|
||||
* 若店铺名存在,返回状态码 1;否则返回状态码 2。
|
||||
*
|
||||
* @param paramsJSON 请求体中的 JSON 参数(可选)
|
||||
* @param storeName 请求参数中的店铺名称(可选)
|
||||
* @return CommonResult 返回检查结果
|
||||
*/
|
||||
@ApiOperation("检查店铺名是否已存在?")
|
||||
@RequestMapping(value = "/check-store-name-exists", method = RequestMethod.POST)
|
||||
public CommonResult checkStoreNameExists(@RequestBody JSONObject paramsJSON,
|
||||
@RequestParam(name = "storeName", required = false) String storeName) {
|
||||
// 优先从请求体中获取店铺名称
|
||||
String storeNameFromJson = paramsJSON.getStr("storeName");
|
||||
if (StrUtil.isNotBlank(storeNameFromJson)) {
|
||||
storeName = storeNameFromJson;
|
||||
}
|
||||
|
||||
// 如果店铺名称为空,直接返回失败结果
|
||||
if (StrUtil.isBlank(storeName)) {
|
||||
return CommonResult.failed("请输入店铺名");
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用服务层检查店铺名称是否存在
|
||||
Boolean exists = shopStoreBaseService.isExistsByStoreName(storeName);
|
||||
|
||||
if (Boolean.TRUE.equals(exists)) {
|
||||
// 店铺名已存在
|
||||
return CommonResult.success(new JSONObject().set("flag", 2), "店铺名已被使用!");
|
||||
} else {
|
||||
// 店铺名不存在
|
||||
return CommonResult.success(new JSONObject().set("flag", 1), "店铺名可以使用!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 捕获异常并返回统一的错误信息
|
||||
throw new ApiException("检查店铺名称是否存在时发生异常:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user