package com.zksy.WaterSupply.WaterPumpStation.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
import com.zksy.WaterSupply.WaterPumpStation.mapper.WaterPumpStationMapper;
import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class WaterPumpStationServiceImpl extends ServiceImpl<WaterPumpStationMapper, WaterPumpStation>
        implements IWaterPumpStationService {

    @Override
    public IPage<WaterPumpStation> queryPage(Page<WaterPumpStation> page,
                                             String stationCode,
                                             String stationName,
                                             String status,
                                             String principal,
                                             LocalDateTime startTime,
                                             LocalDateTime endTime) {
        List<WaterPumpStation> list = baseMapper.selectStationList(stationCode, stationName, status, principal, startTime, endTime);
        page.setRecords(list);
        page.setTotal(list.size());
        return page;
    }

    @Override
    public IPage<WaterPumpStation> queryDeletedPage(Page<WaterPumpStation> page,
                                                    String stationCode,
                                                    String stationName,
                                                    String status,
                                                    LocalDateTime startTime,
                                                    LocalDateTime endTime) {
        List<WaterPumpStation> list = baseMapper.selectDeletedList(stationCode, stationName, status, startTime, endTime);
        page.setRecords(list);
        page.setTotal(list.size());
        return page;
    }

    @Override
    public boolean restoreByIds(List<Long> ids, String updateBy) {
        if (ids == null || ids.isEmpty()) {
            return false;
        }
        return baseMapper.restoreByIds(ids, updateBy) > 0;
    }

    @Override
    public boolean deleteByIdsPhysically(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            return false;
        }
        return baseMapper.deleteByIdsPhysically(ids) > 0;
    }
}