package cn.iocoder.yudao.module.inspection.service.impl;

import java.util.List;

import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.util.DateUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionHomePartner;
import cn.iocoder.yudao.module.inspection.mapper.InspectionHomePartnerMapper;
import cn.iocoder.yudao.module.inspection.service.IInspectionHomePartnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-02
 */
@Service
public class InspectionHomePartnerServiceImpl implements IInspectionHomePartnerService
{
    @Autowired
    private InspectionHomePartnerMapper InspectionHomePartnerMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public InspectionHomePartner selectInspectionHomePartnerById(Long id)
    {
        return InspectionHomePartnerMapper.selectInspectionHomePartnerById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param InspectionHomePartner 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<InspectionHomePartner> selectInspectionHomePartnerList(InspectionHomePartner InspectionHomePartner)
    {
        return InspectionHomePartnerMapper.selectInspectionHomePartnerList(InspectionHomePartner);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param InspectionHomePartner 【请填写功能名称】
     * @return 结果
     */
    @Override
    public void insertInspectionHomePartner(InspectionHomePartner InspectionHomePartner)
    {
        List<InspectionHomePartner> InspectionHomePartnerList = InspectionHomePartnerMapper.selectInspectionHomePartnerList(InspectionHomePartner);
        if (CollectionUtil.isEmpty(InspectionHomePartnerList)){
             InspectionHomePartnerMapper.insertInspectionHomePartner(InspectionHomePartner);
        }else {
            InspectionHomePartnerMapper.deleteInspectionHomePartnerById(InspectionHomePartner.getPartnerId());
        }
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param InspectionHomePartner 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateInspectionHomePartner(InspectionHomePartner InspectionHomePartner)
    {
        InspectionHomePartner.setUpdateTime(DateUtils.getNowDate());
        return InspectionHomePartnerMapper.updateInspectionHomePartner(InspectionHomePartner);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInspectionHomePartnerByIds(Long[] ids)
    {
        return InspectionHomePartnerMapper.deleteInspectionHomePartnerByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInspectionHomePartnerById(Long id)
    {
        return InspectionHomePartnerMapper.deleteInspectionHomePartnerById(id);
    }
}
