Helius
2021-01-16 9fbd7c475b86b79d2820fc6cf8b49c408dd279c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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<Long> list){
    
        return shoppingGoodsCategoryDao.deleteByIds(list);
    
    }
 
    @Override
    public int removeById(Long id){
        rescuRemove(id);
        return shoppingGoodsCategoryDao.deleteById(id);
    
    }
    
    @Override
    public List<ShoppingGoodsCategory> findInPage(ShoppingGoodsCategory shoppingGoodsCategory,  PaginationVO pageVo){
    
        return shoppingGoodsCategoryDao.selectInPage(shoppingGoodsCategory , pageVo);
    
    }
    
    @Override
    public List<ShoppingGoodsCategory> 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<ShoppingGoodsCategory> categories=shoppingGoodsCategoryDao.selectByModel(category);
        if(categories.size()>0){
            for (ShoppingGoodsCategory category2 : categories) {
                rescuRemove(category2.getId());
                shoppingGoodsCategoryDao.deleteById(category2.getId());
            }
        }
    }
 
    @Override
    public List<ShoppingGoodsCategory> findChildNodesByName(ShoppingGoodsCategory shoppingGoodsCategory) {
        return shoppingGoodsCategoryDao.selectChildNodesByName(shoppingGoodsCategory);
    }
}