package com.ruoyi.warehouseBusiness.service.impl;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.warehouseBusiness.domain.TEnclosure;
import com.ruoyi.warehouseBusiness.mapper.TEnclosureMapper;
import com.ruoyi.warehouseBusiness.service.ITEnclosureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 附件Service业务层处理
 *
 * @author ruoyi
 * @date 2020-12-11
 */
@Service
public class TEnclosureServiceImpl implements ITEnclosureService {
    @Autowired
    private TEnclosureMapper tEnclosureMapper;

    /**
     * 查询附件
     *
     * @param fId 附件ID
     * @return 附件
     */
    @Override
    public TEnclosure selectTEnclosureById(Long fId) {
        return tEnclosureMapper.selectTEnclosureById(fId);
    }

    /**
     * 查询附件列表
     *
     * @param tEnclosure 附件
     * @return 附件
     */
    @Override
    public List<TEnclosure> selectTEnclosureList(TEnclosure tEnclosure) {
        return tEnclosureMapper.selectTEnclosureList(tEnclosure);
    }

    /**
     * 新增附件
     *
     * @param tEnclosure 附件
     * @return 结果
     */
    @Override
    public int insertTEnclosure(TEnclosure tEnclosure) {
        tEnclosure.setCreateTime(DateUtils.getNowDate());
        return tEnclosureMapper.insertTEnclosure(tEnclosure);
    }

    /**
     * 修改附件
     *
     * @param tEnclosure 附件
     * @return 结果
     */
    @Override
    public int updateTEnclosure(TEnclosure tEnclosure) {
        tEnclosure.setUpdateTime(DateUtils.getNowDate());
        return tEnclosureMapper.updateTEnclosure(tEnclosure);
    }

    /**
     * 批量删除附件
     *
     * @param fIds 需要删除的附件ID
     * @return 结果
     */
    @Override
    public int deleteTEnclosureByIds(Long[] fIds) {
        return tEnclosureMapper.deleteTEnclosureByIds(fIds);
    }

    /**
     * 删除附件信息
     *
     * @param fId 附件ID
     * @return 结果
     */
    @Override
    public int deleteTEnclosureById(Long fId) {
        return tEnclosureMapper.deleteTEnclosureById(fId);
    }

    /**
     * 根据上级id查询附件集合
     *
     * @param fPid 上级id
     * @return
     */
    @Override
    public AjaxResult selectInfoByPid(Long fPid) {
        return AjaxResult.success(tEnclosureMapper.selectTEnclosureByPId(fPid));
    }

}
