package com.fastbee.ggroup.service.impl;

import java.util.List;
import java.util.Objects;

import com.fastbee.common.exception.ServiceException;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.ggroup.domain.GSiteSluiceInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.ggroup.mapper.GSitePumpInfoMapper;
import com.fastbee.ggroup.domain.GSitePumpInfo;
import com.fastbee.ggroup.service.IGSitePumpInfoService;

/**
 * 泵站信息Service业务层处理
 * 
 * @author kerwincui
 * @date 2024-11-04
 */
@Service
public class GSitePumpInfoServiceImpl implements IGSitePumpInfoService 
{
    @Autowired
    private GSitePumpInfoMapper gSitePumpInfoMapper;

    /**
     * 查询泵站信息
     * 
     * @param SiteId 泵站信息主键
     * @return 泵站信息
     */
    @Override
    public GSitePumpInfo selectGSitePumpInfoBySiteId(Long SiteId)
    {
        return gSitePumpInfoMapper.selectGSitePumpInfoBySiteId(SiteId);
    }


    /**
     * 修改泵站信息
     * 
     * @param gSitePumpInfo 泵站信息
     * @return 结果
     */
    @Override
    public int updateGSiteSluiceInfo(GSitePumpInfo gSitePumpInfo){
        if (Objects.isNull(gSitePumpInfo.getSiteId())){
            throw new ServiceException("站点ID(siteId)字段不能为空！");
        }
        if (Objects.isNull(gSitePumpInfoMapper.selectGSitePumpInfoBySiteId(gSitePumpInfo.getSiteId()))){
            gSitePumpInfo.setCreateTime(DateUtils.getNowDate());
            return gSitePumpInfoMapper.insertGSitePumpInfo(gSitePumpInfo);
        }
        gSitePumpInfo.setUpdateTime(DateUtils.getNowDate());
        return gSitePumpInfoMapper.updateGSitePumpInfo(gSitePumpInfo);
    }

}
