package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.ArrayList;
import com.ruoyi.common.core.domain.Ztree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BaseDatadictionarydetailMapper;
import com.ruoyi.system.domain.BaseDatadictionarydetail;
import com.ruoyi.system.service.IBaseDatadictionarydetailService;
import com.ruoyi.common.core.text.Convert;

/**
 * 行业树表Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-07
 */
@Service
public class BaseDatadictionarydetailServiceImpl implements IBaseDatadictionarydetailService 
{
    @Autowired
    private BaseDatadictionarydetailMapper baseDatadictionarydetailMapper;

    /**
     * 查询行业树表
     * 
     * @param datadictionarydetailid 行业树表ID
     * @return 行业树表
     */
    @Override
    public BaseDatadictionarydetail selectBaseDatadictionarydetailById(String datadictionarydetailid)
    {
        return baseDatadictionarydetailMapper.selectBaseDatadictionarydetailById(datadictionarydetailid);
    }

    /**
     * 查询行业树表列表
     * 
     * @param baseDatadictionarydetail 行业树表
     * @return 行业树表
     */
    @Override
    public List<BaseDatadictionarydetail> selectBaseDatadictionarydetailList(BaseDatadictionarydetail baseDatadictionarydetail)
    {
        return baseDatadictionarydetailMapper.selectBaseDatadictionarydetailList(baseDatadictionarydetail);
    }

    /**
     * 新增行业树表
     * 
     * @param baseDatadictionarydetail 行业树表
     * @return 结果
     */
    @Override
    public int insertBaseDatadictionarydetail(BaseDatadictionarydetail baseDatadictionarydetail)
    {
        return baseDatadictionarydetailMapper.insertBaseDatadictionarydetail(baseDatadictionarydetail);
    }

    /**
     * 修改行业树表
     * 
     * @param baseDatadictionarydetail 行业树表
     * @return 结果
     */
    @Override
    public int updateBaseDatadictionarydetail(BaseDatadictionarydetail baseDatadictionarydetail)
    {
        return baseDatadictionarydetailMapper.updateBaseDatadictionarydetail(baseDatadictionarydetail);
    }

    /**
     * 删除行业树表对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBaseDatadictionarydetailByIds(String ids)
    {
        return baseDatadictionarydetailMapper.deleteBaseDatadictionarydetailByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除行业树表信息
     * 
     * @param datadictionarydetailid 行业树表ID
     * @return 结果
     */
    public int deleteBaseDatadictionarydetailById(String datadictionarydetailid)
    {
        return baseDatadictionarydetailMapper.deleteBaseDatadictionarydetailById(datadictionarydetailid);
    }

    /**
     * 查询行业树表树列表
     * 
     * @return 所有行业树表信息
     */
    @Override
    public List<Ztree> selectBaseDatadictionarydetailTree()
    {
        List<BaseDatadictionarydetail> baseDatadictionarydetailList = baseDatadictionarydetailMapper.selectBaseDatadictionarydetailList(new BaseDatadictionarydetail());
        List<Ztree> ztrees = new ArrayList<Ztree>();
        for (BaseDatadictionarydetail baseDatadictionarydetail : baseDatadictionarydetailList)
        {
            Ztree ztree = new Ztree();
            ztree.setId(baseDatadictionarydetail.getDatadictionarydetailid());
            ztree.setpId(baseDatadictionarydetail.getParentid());
            ztree.setName(baseDatadictionarydetail.getDatadictionarydetailid());
            ztree.setTitle(baseDatadictionarydetail.getDatadictionarydetailid());
            ztrees.add(ztree);
        }
        return ztrees;
    }
}
