liusheng
2025-03-07 380b95c9c8efb93419e21bd5e3b52b3c84cd0d81
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
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.smartor.service.impl;
 
import com.ruoyi.common.utils.DateUtils;
import com.smartor.domain.HeLibraryAssort;
import com.smartor.domain.IvrLibaExtemplateCategory;
import com.smartor.mapper.IvrLibaExtemplateCategoryMapper;
import com.smartor.service.IIvrLibaExtemplateCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * 通用模板分类Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@Slf4j
@Service
public class IvrLibaExtemplateCategoryServiceImpl implements IIvrLibaExtemplateCategoryService {
    @Autowired
    private IvrLibaExtemplateCategoryMapper ivrLibaExtemplateCategoryMapper;
 
    /**
     * 查询通用模板分类
     *
     * @param intertcatid 通用模板分类主键
     * @return 通用模板分类
     */
    @Override
    public IvrLibaExtemplateCategory selectIvrLibaExtemplateCategoryByIntertcatid(Long intertcatid) {
        return ivrLibaExtemplateCategoryMapper.selectIvrLibaExtemplateCategoryByIntertcatid(intertcatid);
    }
 
    /**
     * 查询通用模板分类列表
     *
     * @param ivrLibaExtemplateCategory 通用模板分类
     * @return 通用模板分类
     */
    @Override
    public List<IvrLibaExtemplateCategory> selectIvrLibaExtemplateCategoryList(IvrLibaExtemplateCategory ivrLibaExtemplateCategory) {
        return ivrLibaExtemplateCategoryMapper.selectIvrLibaExtemplateCategoryList(ivrLibaExtemplateCategory);
    }
 
    /**
     * 新增通用模板分类
     *
     * @param ivrLibaExtemplateCategory 通用模板分类
     * @return 结果
     */
    @Override
    public int insertIvrLibaExtemplateCategory(IvrLibaExtemplateCategory ivrLibaExtemplateCategory) {
        ivrLibaExtemplateCategory.setCreateTime(DateUtils.getNowDate());
        //获取序号最大值
        Integer seqMax = ivrLibaExtemplateCategoryMapper.selectSeqMax();
        if (seqMax != null) {
            ivrLibaExtemplateCategory.setSeqno(seqMax + 1);
        } else {
            ivrLibaExtemplateCategory.setSeqno(1);
        }
        return ivrLibaExtemplateCategoryMapper.insertIvrLibaExtemplateCategory(ivrLibaExtemplateCategory);
    }
 
    /**
     * 修改通用模板分类
     *
     * @param ivrLibaExtemplateCategory 通用模板分类
     * @return 结果
     */
    @Override
    public int updateIvrLibaExtemplateCategory(IvrLibaExtemplateCategory ivrLibaExtemplateCategory) {
        ivrLibaExtemplateCategory.setUpdateTime(DateUtils.getNowDate());
        return ivrLibaExtemplateCategoryMapper.updateIvrLibaExtemplateCategory(ivrLibaExtemplateCategory);
    }
 
    /**
     * 批量删除通用模板分类
     *
     * @param intertcatids 需要删除的通用模板分类主键
     * @return 结果
     */
    @Override
    public int deleteIvrLibaExtemplateCategoryByIntertcatids(Long[] intertcatids) {
        Integer i = null;
        for (Long intertcatid : intertcatids) {
            //负数的ID为默认值,不可以删除
            if (intertcatid < 0) {
                log.info("intertcatid的值为:{}", intertcatid);
                continue;
            }
            i = ivrLibaExtemplateCategoryMapper.deleteIvrLibaExtemplateCategoryByIntertcatid(intertcatid);
            //删除成功后,如果该删除的ID下有子数据,则将子数据放到未分配下面
            IvrLibaExtemplateCategory ivrLibaExtemplateCategory = new IvrLibaExtemplateCategory();
            ivrLibaExtemplateCategory.setPid(intertcatid);
            List<IvrLibaExtemplateCategory> ivrLibaExtemplateCategories = ivrLibaExtemplateCategoryMapper.selectIvrLibaExtemplateCategoryList(ivrLibaExtemplateCategory);
            if (CollectionUtils.isNotEmpty(ivrLibaExtemplateCategories)) {
                for (IvrLibaExtemplateCategory ivrLibaExtemplateCategory1 : ivrLibaExtemplateCategories) {
                    //设置未分配ID
                    ivrLibaExtemplateCategory1.setPid(-1L);
                    ivrLibaExtemplateCategoryMapper.updateIvrLibaExtemplateCategory(ivrLibaExtemplateCategory1);
                }
            }
        }
        return i;
    }
 
}