package com.ruoyi.dxp.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dxp.mapper.CatalogueMapper;
import com.ruoyi.dxp.domain.Catalogue;
import com.ruoyi.dxp.service.ICatalogueService;

/**
 * 目录Service业务层处理
 * 
 * @author jy
 * @date 2022-11-11
 */
@Service
public class CatalogueServiceImpl implements ICatalogueService 
{
    @Autowired
    private CatalogueMapper catalogueMapper;

    /**
     * 查询目录
     * 
     * @param id 目录主键
     * @return 目录
     */
    @Override
    public Catalogue selectCatalogueById(Long id)
    {
        return catalogueMapper.selectCatalogueById(id);
    }

    /**
     * 查询目录列表
     * 
     * @param catalogue 目录
     * @return 目录
     */
    @Override
    public List<Catalogue> selectCatalogueList(Catalogue catalogue)
    {
        return catalogueMapper.selectCatalogueList(catalogue);
    }

    /**
     * 新增目录
     * 
     * @param catalogue 目录
     * @return 结果
     */
    @Override
    public int insertCatalogue(Catalogue catalogue)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        catalogue.setCreateBy(loginUser.getUsername());
        catalogue.setCreateTime(DateUtils.getNowDate());
        return catalogueMapper.insertCatalogue(catalogue);
    }

    /**
     * 修改目录
     * 
     * @param catalogue 目录
     * @return 结果
     */
    @Override
    public int updateCatalogue(Catalogue catalogue)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        catalogue.setUpdateBy(loginUser.getUsername());
        catalogue.setUpdateTime(DateUtils.getNowDate());
        return catalogueMapper.updateCatalogue(catalogue);
    }

    /**
     * 批量删除目录
     * 
     * @param ids 需要删除的目录主键
     * @return 结果
     */
    @Override
    public int deleteCatalogueByIds(Long[] ids)
    {
        return catalogueMapper.deleteCatalogueByIds(ids);
    }

    /**
     * 删除目录信息
     * 
     * @param id 目录主键
     * @return 结果
     */
    @Override
    public int deleteCatalogueById(Long id)
    {
        return catalogueMapper.deleteCatalogueById(id);
    }
}
