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.BreedParentsDao;
import com.huimv.management.entity.BreedParentsEntity;
import com.huimv.management.service.BreedParentsService;


@Service("breedParentsService")
public class BreedParentsServiceImpl extends ServiceImpl<BreedParentsDao, BreedParentsEntity> implements BreedParentsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String farmId = (String)params.get("formFarmId");

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

        //耳标
        String eartag = (String)params.get("eartagNo");
        wrapper.like(StringUtils.isNotBlank(eartag),"eartag_no",eartag);

        //类型
        String type = (String)params.get("type");
        wrapper.eq(StringUtils.isNotBlank(type),"type",type);

        //性别
        String gender = (String)params.get("gender");
        wrapper.eq(StringUtils.isNotBlank(gender),"gender",gender);

        //血统(种类)
        String blood = (String)params.get("blood");
        wrapper.eq(StringUtils.isNotBlank(blood),"blood",blood);

        //原产地(来源)
        String origin = (String)params.get("origin");
        wrapper.eq(StringUtils.isNotBlank(origin),"origin",origin);

        IPage<BreedParentsEntity> page = this.page(
                new Query<BreedParentsEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}