装修
This commit is contained in:
parent
4947025a25
commit
64e772a47c
@ -47,13 +47,17 @@ public class UserInfoService {
|
|||||||
userStr = null;
|
userStr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserDto userDto;
|
||||||
if (StrUtil.isNotBlank(userStr)) {
|
if (StrUtil.isNotBlank(userStr)) {
|
||||||
// 将 JSON 字符串转换为 UserDto 对象
|
// 将 JSON 字符串转换为 UserDto 对象
|
||||||
return JSONUtil.toBean(userStr, UserDto.class);
|
userDto = JSONUtil.toBean(userStr, UserDto.class);
|
||||||
|
} else {
|
||||||
|
// 如果 userStr 为空,尝试通过 token 获取用户信息
|
||||||
|
userDto = getUserByToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果 userStr 为空,尝试通过 token 获取用户信息
|
log.info("用户信息:{}", userDto);
|
||||||
return getUserByToken();
|
return userDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUserId() {
|
public Integer getUserId() {
|
||||||
|
|||||||
@ -150,15 +150,39 @@ public class ShopPageBaseController extends BaseControllerImpl {
|
|||||||
@ApiOperation(value = "页面表-通过page_id删除", notes = "页面表-通过page_id删除")
|
@ApiOperation(value = "页面表-通过page_id删除", notes = "页面表-通过page_id删除")
|
||||||
@RequestMapping(value = "/remove", method = RequestMethod.POST)
|
@RequestMapping(value = "/remove", method = RequestMethod.POST)
|
||||||
public CommonResult remove(@RequestParam(name = "page_id") Long page_id) {
|
public CommonResult remove(@RequestParam(name = "page_id") Long page_id) {
|
||||||
UserDto user = getCurrentUser();
|
try {
|
||||||
if (user == null || !user.isPlatform()) {
|
UserDto user = getCurrentUser();
|
||||||
throw new ApiException(ResultCode.FORBIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shopPageBaseService.remove(page_id)) {
|
// 用户未登录,禁止操作
|
||||||
return CommonResult.success();
|
if (user == null) {
|
||||||
} else {
|
throw new ApiException(ResultCode.FORBIDDEN);
|
||||||
return CommonResult.failed();
|
}
|
||||||
|
|
||||||
|
// 非平台管理员,只能删除自己店铺的页面
|
||||||
|
if (!user.isPlatform()) {
|
||||||
|
String storeId = user.getStore_id();
|
||||||
|
ShopPageBase shopPageBase = shopPageBaseService.getById(page_id);
|
||||||
|
// log.info("storeId:{}", storeId);
|
||||||
|
// log.info("shopPageBase:{}", shopPageBase);
|
||||||
|
|
||||||
|
// 页面不存在 或 当前用户无店铺信息 或 页面归属与当前店铺不符,则禁止删除
|
||||||
|
if (shopPageBase == null || StrUtil.isBlank(storeId) || !storeId.equals(shopPageBase.getStore_id().toString())) {
|
||||||
|
throw new ApiException(ResultCode.FORBIDDEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行删除操作
|
||||||
|
boolean isRemoved = shopPageBaseService.remove(page_id);
|
||||||
|
return isRemoved ? CommonResult.success() : CommonResult.failed();
|
||||||
|
|
||||||
|
} catch (ApiException e) {
|
||||||
|
// 已知业务异常,直接抛出
|
||||||
|
log.warn("删除页面失败,参数:{}", page_id, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 未知系统异常,记录日志并返回友好提示
|
||||||
|
log.error("删除页面发生系统异常,page_id: {}", page_id, e);
|
||||||
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user