package com.mx.cneeds.server.device.service.impl;

import com.mx.cneeds.common.annotation.DataFilter;
import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.pager.Query;
import com.mx.cneeds.server.dao.ProductSeriesDao;
import com.mx.cneeds.server.device.service.ProductSeriesService;
import com.mx.cneeds.server.entity.ProductSeriesEntity;
import com.mx.cneeds.server.entity.SysRoleEntity;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
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;


@Service("productSeriesService")
public class ProductSeriesServiceImpl extends ServiceImpl<ProductSeriesDao, ProductSeriesEntity> implements ProductSeriesService {

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

        QueryWrapper<ProductSeriesEntity> queryWrapper =new QueryWrapper<ProductSeriesEntity>();
        String seriesNum = (String) params.get("seriesNum");
        if (seriesNum != null && !"".equals(seriesNum)){
            queryWrapper.eq("series_num",seriesNum);
        }

        IPage<ProductSeriesEntity> page = this.page(
                new Query<ProductSeriesEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }


    @Override
    public List<ProductSeriesEntity> queryListById(Collection<Long> array){
        List<ProductSeriesEntity> productSeriesEntityList = getBaseMapper().selectBatchIds(array);
        return productSeriesEntityList;
    }

    @Override
    public List<ProductSeriesEntity> queryList(Map<String, Object> params) {

        return baseMapper.queryList(params);
    }

    @Override
    public ProductSeriesEntity queryOne(Long seriesId){
        ProductSeriesEntity seriesEntity = getById(seriesId);
        return seriesEntity;
    }

    @Override
    public ProductSeriesEntity queryBySeriesNum(String seriesNum){
        ProductSeriesEntity seriesEntity =
                getOne(new QueryWrapper<ProductSeriesEntity>().eq("series_num", seriesNum));
        return seriesEntity;
    }


}
