package com.huimv.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang.StringUtils;
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.BreedFeedWeigheDao;
import com.huimv.management.entity.BreedFeedWeigheEntity;
import com.huimv.management.service.BreedFeedWeigheService;


@Service("breedFeedWeigheService")
public class BreedFeedWeigheServiceImpl extends ServiceImpl<BreedFeedWeigheDao, BreedFeedWeigheEntity> implements BreedFeedWeigheService {

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

        LambdaQueryWrapper<BreedFeedWeigheEntity> lambdaQuery = Wrappers.lambdaQuery();

//构建查询条件

        //低频耳标号
        String eartag = (String) params.get("eartag_no");
        if (StringUtils.isNotEmpty(eartag)) {
            lambdaQuery.like(BreedFeedWeigheEntity::getEartagNo,eartag);
        }


        //牧场名称
        String sex = (String) params.get("farm_name");
        if (StringUtils.isNotEmpty(sex)) {
            lambdaQuery.eq(BreedFeedWeigheEntity::getFarmName,sex);
        }


        //品种
        String breed = (String) params.get("pig_home_name");
        if (StringUtils.isNotEmpty(breed)) {
            lambdaQuery.eq(BreedFeedWeigheEntity::getPigHomeName,breed);
        }


        IPage<BreedFeedWeigheEntity> page = page(this.page(
                new Query<BreedFeedWeigheEntity>().getPage(params)
        ), lambdaQuery);





       /*
        IPage<BreedFeedWeigheEntity> page = this.page(
                new Query<BreedFeedWeigheEntity>().getPage(params),
                new QueryWrapper<BreedFeedWeigheEntity>()
        );
*/
        return new PageUtils(page);
    }

}