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.YearPigPedigreeEntity;
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.YearPigPedigreeDao;
import com.huimv.management.entity.YearPigPedigreeEntity;
import com.huimv.management.service.YearPigPedigreeService;


@Service("yearPigPedigreeService")
public class YearPigPedigreeServiceImpl extends ServiceImpl<YearPigPedigreeDao, YearPigPedigreeEntity> implements YearPigPedigreeService {

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

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

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


        return new PageUtils(page);
    }

}