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.YearPigHistoryImgEntity;
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.YearPigHistoryImgDao;
import com.huimv.management.entity.YearPigHistoryImgEntity;
import com.huimv.management.service.YearPigHistoryImgService;


@Service("yearPigHistoryImgService")
public class YearPigHistoryImgServiceImpl extends ServiceImpl<YearPigHistoryImgDao, YearPigHistoryImgEntity> implements YearPigHistoryImgService {

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

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

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


        return new PageUtils(page);
    }

}