package com.yuchen.saas.park.service.service.property.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuchen.saas.park.api.entity.property.SaasParkPropertyMeterReadingSet;
import com.yuchen.saas.park.api.entity.property.SaasParkPropertyMeterReadingSet;
import com.yuchen.saas.park.api.request.SaasParkPropertyMeterReadingSetRequest;
import com.yuchen.saas.park.service.mapper.property.SaasParkPropertyMeterReadingSetMapper;
import com.yuchen.saas.park.service.service.property.SaasParkPropertyMeterReadingSetService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.mp.support.Condition;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 仪表抄表-基础设置-抄表设置 服务实现类
 * </p>
 *
 * @author miaoqs
 * @since 2024-09-29
 */
@Service
public class SaasParkPropertyMeterReadingSetServiceImpl extends BaseServiceImpl<SaasParkPropertyMeterReadingSetMapper, SaasParkPropertyMeterReadingSet> implements SaasParkPropertyMeterReadingSetService {

    @Override
    public IPage<SaasParkPropertyMeterReadingSet> pageByparam(SaasParkPropertyMeterReadingSetRequest request) {
        Query query = new Query();
        query.setCurrent(request.getCurrent());
        query.setSize(request.getSize());
        IPage<SaasParkPropertyMeterReadingSet> pages = page(Condition.getPage(query),
                new LambdaQueryWrapper<SaasParkPropertyMeterReadingSet>()
                        .eq(Func.isNotEmpty(request.getParkId()), SaasParkPropertyMeterReadingSet::getParkId,
                                request.getParkId())
                        .like(Func.isNotEmpty(request.getApportionType()), SaasParkPropertyMeterReadingSet::getApportionType,
                                request.getApportionType())
                        .orderByDesc(SaasParkPropertyMeterReadingSet::getCreateTime));
        return pages;
    }
}
