|
@@ -191,6 +191,7 @@ public class GoodsCategoryMgrController extends BaseApiController {
|
|
|
@Log(title = "删除商品分类", businessType = BusinessType.DELETE)
|
|
|
@PostMapping(value = "/remove")
|
|
|
@PreAuthorize("@ss.hasPermi('business:category:remove')")
|
|
|
+ @ApiOperation("删除商品分类")
|
|
|
public AjaxResult remove(@RequestBody GoodsCategory goodsCategory) {
|
|
|
|
|
|
if (null == goodsCategory.getCategoryId() || 0 == goodsCategory.getCategoryId()) {
|
|
@@ -202,6 +203,12 @@ public class GoodsCategoryMgrController extends BaseApiController {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1024);
|
|
|
}
|
|
|
|
|
|
+ int count = goodsCategoryService.count(new LambdaQueryWrapper<GoodsCategory>()
|
|
|
+ .eq(GoodsCategory::getParentId, goodsCategory.getCategoryId()));
|
|
|
+ if (count > 0) {
|
|
|
+ return error("删除失败,分类下存在子分类");
|
|
|
+ }
|
|
|
+
|
|
|
boolean res = goodsCategoryService.removeById(goodsCategory.getCategoryId());
|
|
|
return res ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
|
|
|
}
|