package com.ktg.iscs.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktg.common.core.text.Convert;
import com.ktg.common.utils.DateUtils;
import com.ktg.iscs.domain.IsMaterialsRestitutionRules;
import com.ktg.iscs.mapper.IsMaterialsRestitutionRulesMapper;
import com.ktg.iscs.service.IIsMaterialsRestitutionRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物资借出规则Service业务层处理
 *
 * @author cgj
 * @date 2024-11-08
 */
@Service
public class IsMaterialsRestitutionRulesServiceImpl extends ServiceImpl<IsMaterialsRestitutionRulesMapper, IsMaterialsRestitutionRules> implements IIsMaterialsRestitutionRulesService
{
    @Autowired
    private IsMaterialsRestitutionRulesMapper isMaterialsRestitutionRulesMapper;

    /**
     * 查询物资借出规则
     *
     * @param ruleId 物资借出规则主键
     * @return 物资借出规则
     */
    @Override
    public IsMaterialsRestitutionRules selectIsMaterialsRestitutionRulesByRuleId(Long ruleId)
    {
        return isMaterialsRestitutionRulesMapper.selectIsMaterialsRestitutionRulesByRuleId(ruleId);
    }

    /**
     * 查询物资借出规则列表
     *
     * @param isMaterialsRestitutionRules 物资借出规则
     * @return 物资借出规则
     */
    @Override
    public List<IsMaterialsRestitutionRules> selectIsMaterialsRestitutionRulesList(IsMaterialsRestitutionRules isMaterialsRestitutionRules)
    {
        return isMaterialsRestitutionRulesMapper.selectIsMaterialsRestitutionRulesList(isMaterialsRestitutionRules);
    }

    /**
     * 新增物资借出规则
     *
     * @param isMaterialsRestitutionRules 物资借出规则
     * @return 结果
     */
    @Override
    public int insertIsMaterialsRestitutionRules(IsMaterialsRestitutionRules isMaterialsRestitutionRules)
    {
        isMaterialsRestitutionRules.setCreateTime(DateUtils.getNowDate());
        return isMaterialsRestitutionRulesMapper.insertIsMaterialsRestitutionRules(isMaterialsRestitutionRules);
    }

    /**
     * 修改物资借出规则
     *
     * @param isMaterialsRestitutionRules 物资借出规则
     * @return 结果
     */
    @Override
    public int updateIsMaterialsRestitutionRules(IsMaterialsRestitutionRules isMaterialsRestitutionRules)
    {
        isMaterialsRestitutionRules.setUpdateTime(DateUtils.getNowDate());
        return isMaterialsRestitutionRulesMapper.updateIsMaterialsRestitutionRules(isMaterialsRestitutionRules);
    }

    /**
     * 批量删除物资借出规则
     *
     * @param ruleIds 需要删除的物资借出规则主键
     * @return 结果
     */
    @Override
    public int deleteIsMaterialsRestitutionRulesByRuleIds(String ruleIds)
    {
        Assert.notBlank(ruleIds, "请选择需要删除的数据!");
        Long[] longIds = Convert.toLongArray(ruleIds);
        return isMaterialsRestitutionRulesMapper.deleteIsMaterialsRestitutionRulesByRuleIds(longIds);
    }

    /**
     * 删除物资借出规则信息
     *
     * @param ruleId 物资借出规则主键
     * @return 结果
     */
    @Override
    public int deleteIsMaterialsRestitutionRulesByRuleId(Long ruleId)
    {
        return isMaterialsRestitutionRulesMapper.deleteIsMaterialsRestitutionRulesByRuleId(ruleId);
    }
}
