package com.ruoyi.frequency.agreement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.agreement.entity.Agreement;
import com.ruoyi.frequency.agreement.mapper.AgreementMapper;
import com.ruoyi.frequency.agreement.service.AgreementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 协议Service业务层处理
 *
 * @author liwenlong
 * @date 2023-10-26
 */
@Service
public class AgreementServiceImpl extends ServiceImpl<AgreementMapper, Agreement>  implements AgreementService
{
    @Autowired
    private AgreementMapper agreementMapper;

    /**
     * 查询协议
     *
     * @param id 协议主键
     * @return 协议
     */
    @Override
    public Agreement selectAgreementById(Long id)
    {
        return agreementMapper.selectAgreementById(id);
    }

    /**
     * 查询协议列表
     *
     * @param agreement 协议
     * @return 协议
     */
    @Override
    public List<Agreement> selectAgreementList(Agreement agreement)
    {
        return agreementMapper.selectAgreementList(agreement);
    }

    /**
     * 新增协议
     *
     * @param agreement 协议
     * @return 结果
     */
    @Override
    public int insertAgreement(Agreement agreement)
    {
        agreement.setCreateTime(DateUtils.getNowDate());
        return agreementMapper.insert(agreement);
    }

    /**
     * 修改协议
     *
     * @param agreement 协议
     * @return 结果
     */
    @Override
    public int updateAgreement(Agreement agreement)
    {
        agreement.setUpdateTime(DateUtils.getNowDate());
        return agreementMapper.updateById(agreement);
    }

    /**
     * 批量删除协议
     *
     * @param ids 需要删除的协议主键
     * @return 结果
     */
    @Override
    public int deleteAgreementByIds(Long[] ids,Integer delFalg)
    {
        this.lambdaUpdate().set(Agreement::getDelFlag,delFalg).in(Agreement::getId,ids).update();
        return ids.length;
    }

}
