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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.entity.property.SaasParkPropertyMeterType;
import com.yuchen.saas.park.api.request.SaasParkPropertyMeterTypeRequest;
import com.yuchen.saas.park.api.vo.request.PlDoorPointReq;
import com.yuchen.saas.park.service.mapper.property.SaasParkPropertyMeterTypeMapper;
import com.yuchen.saas.park.service.service.property.SaasParkPropertyMeterTypeService;
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 SaasParkPropertyMeterTypeServiceImpl extends BaseServiceImpl<SaasParkPropertyMeterTypeMapper, SaasParkPropertyMeterType> implements SaasParkPropertyMeterTypeService {

    @Override
    public IPage<SaasParkPropertyMeterType> pageByparam(SaasParkPropertyMeterTypeRequest req) {
        // 分页查询
        Query query = new Query();
        query.setCurrent(req.getCurrent());
        query.setSize(req.getSize());
        IPage<SaasParkPropertyMeterType> pages = page(Condition.getPage(query),
                new LambdaQueryWrapper<SaasParkPropertyMeterType>()
                        .eq(Func.isNotEmpty(req.getParkId()), SaasParkPropertyMeterType::getParkId,
                                req.getParkId())
                        .like(Func.isNotEmpty(req.getName()), SaasParkPropertyMeterType::getName,
                                req.getName())
                        .orderByDesc(SaasParkPropertyMeterType::getCreateTime));
        return pages;
    }

}
