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.SlgcWaterUnitRecord;
import com.goldenwater.slgc.mapper.SlgcWaterUnitRecordMapper;
import com.goldenwater.slgc.service.WaterUnitRecordService;

/** 审核记录 业务实现 */
@Service
public class WaterUnitRecordServiceImpl implements WaterUnitRecordService {
    @Autowired
    private SlgcWaterUnitRecordMapper slgcWaterUnitRecordMapper;

    @Override
    public List<SlgcWaterUnitRecord> selectWaterUnitRecordList(String unitId) {
        return slgcWaterUnitRecordMapper.selectSlgcWaterUnitRecordList(unitId);
    }

    @Override
    public SlgcWaterUnitRecord selectWaterUnitRecordById(String id) {
        return slgcWaterUnitRecordMapper.selectSlgcWaterUnitRecordById(id);
    }

    @Override
    public int insertWaterUnitRecord(SlgcWaterUnitRecord record) {
        if (record.getId() == null || record.getId().isEmpty()) {
            record.setIsDelete("0");
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            Integer maxId = slgcWaterUnitRecordMapper.findMaxId();
            record.setId(String.valueOf(maxId));
        }
        return slgcWaterUnitRecordMapper.insertSlgcWaterUnitRecord(record);
    }

    @Override
    public int updateWaterUnitRecord(SlgcWaterUnitRecord record) {
        return slgcWaterUnitRecordMapper.updateSlgcWaterUnitRecord(record);
    }

    @Override
    public int deleteWaterUnitRecordByIds(String[] ids) {
        return slgcWaterUnitRecordMapper.deleteSlgcWaterUnitRecordByIds(ids);
    }
}
