|
@@ -1,10 +1,13 @@
|
|
package com.platform.service.impl;
|
|
package com.platform.service.impl;
|
|
|
|
|
|
import com.platform.dao.CategoryDao;
|
|
import com.platform.dao.CategoryDao;
|
|
|
|
+import com.platform.dao.GoodsDao;
|
|
import com.platform.entity.CategoryEntity;
|
|
import com.platform.entity.CategoryEntity;
|
|
import com.platform.entity.Result;
|
|
import com.platform.entity.Result;
|
|
import com.platform.service.CategoryService;
|
|
import com.platform.service.CategoryService;
|
|
|
|
|
|
|
|
+import com.platform.service.GoodsService;
|
|
|
|
+import com.platform.utils.RRException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -24,7 +27,8 @@ import java.util.Map;
|
|
public class CategoryServiceImpl implements CategoryService {
|
|
public class CategoryServiceImpl implements CategoryService {
|
|
@Autowired
|
|
@Autowired
|
|
private CategoryDao categoryDao;
|
|
private CategoryDao categoryDao;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private GoodsDao goodsDao;
|
|
@Override
|
|
@Override
|
|
public CategoryEntity queryObject(Integer id) {
|
|
public CategoryEntity queryObject(Integer id) {
|
|
return categoryDao.queryObject(id);
|
|
return categoryDao.queryObject(id);
|
|
@@ -82,6 +86,13 @@ public class CategoryServiceImpl implements CategoryService {
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public int deleteBatch(Integer[] ids) {
|
|
public int deleteBatch(Integer[] ids) {
|
|
|
|
+ if(ids == null || ids.length <= 0){
|
|
|
|
+ throw new RRException("参数为空!");
|
|
|
|
+ }
|
|
|
|
+ Integer count = goodsDao.queryCountByCategoryIds(ids);
|
|
|
|
+ if(count > 0){
|
|
|
|
+ throw new RRException("该分类已绑定商品!");
|
|
|
|
+ }
|
|
categoryDao.deleteByParentBatch(ids);
|
|
categoryDao.deleteByParentBatch(ids);
|
|
return categoryDao.deleteBatch(ids);
|
|
return categoryDao.deleteBatch(ids);
|
|
}
|
|
}
|