package com.zksy.property.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.property.domain.APublicRentalHousing;
import com.zksy.property.service.APublicRentalHousingService;
import com.zksy.property.mapper.APublicRentalHousingMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【a_public_rental_housing(公租房租金收入情况)】的数据库操作Service实现
* @createDate 2025-06-27 09:49:32
*/
@Service
public class APublicRentalHousingServiceImpl extends ServiceImpl<APublicRentalHousingMapper, APublicRentalHousing>
    implements APublicRentalHousingService{

    @Override
    public Page<APublicRentalHousing> findByPage(long pageNum, long pageSize, String receiptNumber, String building, String roomNumber) {
        Page<APublicRentalHousing> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<APublicRentalHousing> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(receiptNumber != null,APublicRentalHousing::getReceiptNumber,receiptNumber);
        queryWrapper.like(building != null,APublicRentalHousing::getBuilding,building);
        queryWrapper.like(roomNumber != null,APublicRentalHousing::getRoomNumber,roomNumber);
        queryWrapper.orderByDesc(APublicRentalHousing::getUpdateTime);
        Page<APublicRentalHousing> page1 = this.page(page, queryWrapper);
        return page1;
    }

    @Override
    public List<APublicRentalHousing> getAPublicRentalHousingList(String receiptNumber, String building, String roomNumber) {
        LambdaQueryWrapper<APublicRentalHousing> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(receiptNumber != null,APublicRentalHousing::getReceiptNumber,receiptNumber);
        queryWrapper.like(building != null,APublicRentalHousing::getBuilding,building);
        queryWrapper.like(roomNumber != null,APublicRentalHousing::getRoomNumber,roomNumber);
        queryWrapper.orderByDesc(APublicRentalHousing::getUpdateTime);
        List<APublicRentalHousing> list = this.list(queryWrapper);
        return list;
    }
}




