package com.zksy.WaterSupply.WaterUserInfo.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.WaterUserInfo.domain.WaterUserInfo;
import com.zksy.WaterSupply.WaterUserInfo.mapper.WaterUserInfoMapper;
import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class WaterUserInfoServiceImpl extends ServiceImpl<WaterUserInfoMapper, WaterUserInfo>
        implements IWaterUserInfoService {

    @Override
    public IPage<WaterUserInfo> queryPage(Page<WaterUserInfo> page,
                                          String userCode,
                                          String userName,
                                          String status,
                                          String userType,
                                          LocalDateTime startTime,
                                          LocalDateTime endTime) {
        List<WaterUserInfo> list = baseMapper.selectUserList(userCode, userName, status, userType, startTime, endTime);
        page.setRecords(list);
        page.setTotal(list.size());
        return page;
    }

    @Override
    public IPage<WaterUserInfo> queryDeletedPage(Page<WaterUserInfo> page,
                                                 String userCode,
                                                 String userName,
                                                 String status,
                                                 LocalDateTime startTime,
                                                 LocalDateTime endTime) {
        List<WaterUserInfo> list = baseMapper.selectDeletedList(userCode, userName, 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;
    }
}