package com.huimv.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huimv.management.entity.IndoorEnvironmentEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.Query;

import com.huimv.management.dao.IndoorEnvironmentDao;
import com.huimv.management.entity.IndoorEnvironmentEntity;
import com.huimv.management.service.IndoorEnvironmentService;


@Service("indoorEnvironmentService")
public class IndoorEnvironmentServiceImpl extends ServiceImpl<IndoorEnvironmentDao, IndoorEnvironmentEntity> implements IndoorEnvironmentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        LambdaQueryWrapper<IndoorEnvironmentEntity> lambdaQuery = Wrappers.lambdaQuery();
        String keywords = (String) params.get("keywords");
        //没有参数
        if (keywords == null || keywords.equals("")){
            IPage<IndoorEnvironmentEntity> page = this.page(
                    new Query<IndoorEnvironmentEntity>().getPage(params),
                    new QueryWrapper<IndoorEnvironmentEntity>()
            );
            return new PageUtils(page);
        }

        lambdaQuery.like(IndoorEnvironmentEntity::getPigstyId,keywords);
        IPage<IndoorEnvironmentEntity> page = page(this.page(
                new Query<IndoorEnvironmentEntity>().getPage(params)
        ), lambdaQuery);


        return new PageUtils(page);
    }
    
    /*@Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<IndoorEnvironmentEntity> page = this.page(
                new Query<IndoorEnvironmentEntity>().getPage(params),
                new QueryWrapper<IndoorEnvironmentEntity>()
        );

        return new PageUtils(page);
    }*/

}