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.ARentalProperty;
import com.zksy.property.service.ARentalPropertyService;
import com.zksy.property.mapper.ARentalPropertyMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【a_rental_property(公租房租赁情况表)】的数据库操作Service实现
* @createDate 2025-06-27 08:58:04
*/
@Service
public class ARentalPropertyServiceImpl extends ServiceImpl<ARentalPropertyMapper, ARentalProperty>
    implements ARentalPropertyService{

    @Override
    public Page findByPage(long pageNum, long pageSize, String tenantCompany, String electricMeterNumber, String roomNumber) {
        Page<ARentalProperty> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<ARentalProperty> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(tenantCompany != null,ARentalProperty::getTenantCompany,tenantCompany);
        queryWrapper.like(electricMeterNumber != null,ARentalProperty::getElectricMeterNumber,electricMeterNumber);
        queryWrapper.like(roomNumber != null,ARentalProperty::getRoomNumber,roomNumber);
        queryWrapper.orderByDesc(ARentalProperty::getUpdateTime);
        Page<ARentalProperty> page1 = this.page(page, queryWrapper);
        return page1;
    }

    @Override
    public List<ARentalProperty> getARentalPropertyList(String licenseCertificateName, String electricMeterNumber, String roomNumber) {
        LambdaQueryWrapper<ARentalProperty> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(licenseCertificateName != null,ARentalProperty::getTenantCompany,licenseCertificateName);
        queryWrapper.like(electricMeterNumber != null,ARentalProperty::getElectricMeterNumber,electricMeterNumber);
        queryWrapper.like(roomNumber != null,ARentalProperty::getRoomNumber,roomNumber);
        queryWrapper.orderByDesc(ARentalProperty::getUpdateTime);
        List<ARentalProperty> list = this.list(queryWrapper);
        return list;
    }
}




