浏览代码

商品分类接口修改

zhh 6 年之前
父节点
当前提交
96fc15e003

+ 9 - 1
mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java

@@ -65,8 +65,16 @@ public class PmsProductCategoryController {
         return new CommonResult().pageSuccess(productCategoryList);
     }
 
+    @ApiOperation("根据id获取商品分类")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    @ResponseBody
+    public Object getItem(@PathVariable Long id) {
+        PmsProductCategory productCategory = productCategoryService.getItem(id);
+        return new CommonResult().success(productCategory);
+    }
+
     @ApiOperation("删除商品分类")
-    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
+    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
     @ResponseBody
     public Object delete(@PathVariable Long id) {
         int count = productCategoryService.delete(id);

+ 1 - 0
mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java

@@ -20,4 +20,5 @@ public interface PmsProductCategoryService {
     List<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum);
 
     int delete(Long id);
+    PmsProductCategory getItem(Long id);
 }

+ 6 - 0
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java

@@ -29,6 +29,7 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
     @Override
     public int create(PmsProductCategoryParam pmsProductCategoryParam) {
         PmsProductCategory productCategory = new PmsProductCategory();
+        productCategory.setProductCount(0);
         BeanUtils.copyProperties(pmsProductCategoryParam, productCategory);
         //没有父分类时为一级分类
         setCategoryLevel(productCategory);
@@ -64,6 +65,11 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
         return productCategoryMapper.deleteByPrimaryKey(id);
     }
 
+    @Override
+    public PmsProductCategory getItem(Long id) {
+        return productCategoryMapper.selectByPrimaryKey(id);
+    }
+
     /**
      * 根据分类的parentId设置分类的level
      */