package com.matrix.system.hive.service.imp; import java.util.List; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.hive.bean.ShoppingGoodsCategory; import com.matrix.system.hive.dao.ShoppingGoodsCategoryDao; import com.matrix.system.hive.service.ShoppingGoodsCategoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * * @date 2016-07-30 09:54 */ @Service("shoppingGoodsCategoryService") public class ShoppingGoodsCategoryServiceImpl implements ShoppingGoodsCategoryService { @Autowired private ShoppingGoodsCategoryDao shoppingGoodsCategoryDao; @Override public int add(ShoppingGoodsCategory shoppingGoodsCategory){ return shoppingGoodsCategoryDao.insert(shoppingGoodsCategory); } @Override public int modify(ShoppingGoodsCategory shoppingGoodsCategory){ return shoppingGoodsCategoryDao.update(shoppingGoodsCategory); } @Override public int remove(List list){ return shoppingGoodsCategoryDao.deleteByIds(list); } @Override public int removeById(Long id){ rescuRemove(id); return shoppingGoodsCategoryDao.deleteById(id); } @Override public List findInPage(ShoppingGoodsCategory shoppingGoodsCategory, PaginationVO pageVo){ return shoppingGoodsCategoryDao.selectInPage(shoppingGoodsCategory , pageVo); } @Override public List findByModel(ShoppingGoodsCategory shoppingGoodsCategory){ return shoppingGoodsCategoryDao.selectByModel(shoppingGoodsCategory); } @Override public int findTotal(ShoppingGoodsCategory shoppingGoodsCategory){ return shoppingGoodsCategoryDao.selectTotalRecord(shoppingGoodsCategory); } @Override public ShoppingGoodsCategory findById(Long id){ return shoppingGoodsCategoryDao.selectById(id); } private void rescuRemove(Long id){ ShoppingGoodsCategory category=new ShoppingGoodsCategory(); category.setParentId(id); List categories=shoppingGoodsCategoryDao.selectByModel(category); if(categories.size()>0){ for (ShoppingGoodsCategory category2 : categories) { rescuRemove(category2.getId()); shoppingGoodsCategoryDao.deleteById(category2.getId()); } } } }