package com.huimv.management.service.impl;

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.BaseFeedFormulaDao;
import com.huimv.management.entity.BaseFeedFormulaEntity;
import com.huimv.management.service.BaseFeedFormulaService;


@Service("baseFeedFormulaService")
public class BaseFeedFormulaServiceImpl extends ServiceImpl<BaseFeedFormulaDao, BaseFeedFormulaEntity> implements BaseFeedFormulaService {

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

        String farmId = (String)params.get("formFarmId");

        QueryWrapper<BaseFeedFormulaEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("farm_id",farmId);

        String  ingredients = (String)params.get("ingredients");
        String  details = (String)params.get("details");
        String  stage = (String)params.get("stage");

        wrapper.like(StringUtils.isNotBlank(ingredients),"ingredients",ingredients);
        wrapper.like(StringUtils.isNotBlank(details),"details",details);
        wrapper.like(StringUtils.isNotBlank(stage),"stage",stage);

        IPage<BaseFeedFormulaEntity> page = this.page(
                new Query<BaseFeedFormulaEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

}