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; 
 | 
    } 
 | 
  
 | 
} 
 |