package com.lz.modules.equipment.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.ISelect;
import com.lz.common.utils.PageUtils;
import com.lz.modules.equipment.dao.EquipmentSpecsMapper;
import com.lz.modules.equipment.entity.EquipmentSpecs;
import com.lz.modules.equipment.entity.EquipmentSpecsReq;
import com.lz.modules.equipment.service.EquipmentSpecsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* <p>
*  服务类
* </p>
*
* @author quyixiao
* @since 2020-07-29
*/

@Service
public class EquipmentSpecsServiceImpl extends ServiceImpl<EquipmentSpecsMapper, EquipmentSpecs> implements EquipmentSpecsService {


    @Autowired
	private EquipmentSpecsMapper equipmentSpecsMapper;



	@Override
	public EquipmentSpecs selectEquipmentSpecsById(Long id){
		return equipmentSpecsMapper.selectEquipmentSpecsById(id);
	}



	@Override
	public Long insertEquipmentSpecs(EquipmentSpecs equipmentSpecs){
		return equipmentSpecsMapper.insertEquipmentSpecs(equipmentSpecs);
	}



	@Override
	public int updateEquipmentSpecsById(EquipmentSpecs equipmentSpecs){
		return equipmentSpecsMapper.updateEquipmentSpecsById(equipmentSpecs);
	}



	@Override
	public int updateCoverEquipmentSpecsById(EquipmentSpecs equipmentSpecs){
		return equipmentSpecsMapper.updateCoverEquipmentSpecsById(equipmentSpecs);
	}



	@Override
	public int deleteEquipmentSpecsById(Long id){
		return equipmentSpecsMapper.deleteEquipmentSpecsById(id);
	}

    @Override
    public EquipmentSpecs selectEquipmentSpecsByTypeBrandSpecss(Long typeId, Long brandId, String specs) {
        return equipmentSpecsMapper.selectEquipmentSpecsByTypeBrandSpecss(typeId,brandId,specs);
    }

    @Override
    public PageUtils selectByCondition(EquipmentSpecsReq req) {
		PageUtils pageUtils = PageUtils.startPage(req.getPage(), req.getRows()).doSelect(
				page -> equipmentSpecsMapper.selectByCondition(page, req)
		);
		return pageUtils;
		/*return PageUtils.startPage(req.getPage(),req.getRows()).doSelect(new ISelect() {
			@Override
			public List doSelect(Page page) {
				return equipmentSpecsMapper.selectByCondition(page,req);
			}
		});*/
    }


	@Override
	public List<EquipmentSpecs> selectEquipmentSpecsByTypeBrandLikeSpecss(Long typeId, Long brandId, String specs) {
		return equipmentSpecsMapper.selectEquipmentSpecsByTypeBrandLikeSpecss(typeId,brandId,specs);
	}

	@Override
	public EquipmentSpecs selectSpecs(String specs) {
		return equipmentSpecsMapper.selectSpecs(specs);
	}
}
