package com.goldenwater.slgc.service.impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.goldenwater.slgc.domain.SlgcWaterUnit;
import com.goldenwater.slgc.mapper.SlgcWaterUnitMapper;
import com.goldenwater.slgc.service.WaterUnitService;

/** 水管单位 业务实现 */
@Service
public class WaterUnitServiceImpl implements WaterUnitService {
    @Autowired
    private SlgcWaterUnitMapper slgcWaterUnitMapper;

    @Override
    public List<SlgcWaterUnit> selectWaterUnitList(SlgcWaterUnit slgcWaterUnit) {
        return slgcWaterUnitMapper.selectSlgcWaterUnitList(slgcWaterUnit);
    }

    @Override
    public SlgcWaterUnit selectWaterUnitById(String id) {
        return slgcWaterUnitMapper.selectSlgcWaterUnitById(id);
    }

    @Override
    public int insertWaterUnit(SlgcWaterUnit slgcWaterUnit) {
        if (slgcWaterUnit.getId() == null || slgcWaterUnit.getId().isEmpty()) {
            slgcWaterUnit.setIsDelete("0");
            slgcWaterUnit.setCreateTime(new Date());
            slgcWaterUnit.setUpdateTime(new Date());
            Integer maxId = slgcWaterUnitMapper.findMaxId();
            slgcWaterUnit.setId(String.valueOf(maxId));
        }
        return slgcWaterUnitMapper.insertSlgcWaterUnit(slgcWaterUnit);
    }

    @Override
    public int updateWaterUnit(SlgcWaterUnit slgcWaterUnit) {
        return slgcWaterUnitMapper.updateSlgcWaterUnit(slgcWaterUnit);
    }

    @Override
    public int deleteWaterUnitByIds(String[] ids) {
        return slgcWaterUnitMapper.deleteSlgcWaterUnitByIds(ids);
    }
}
