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.EquipmentBrandMapper;
import com.lz.modules.equipment.entity.EquipmentBrand;
import com.lz.modules.equipment.entity.EquipmentBrandReq;
import com.lz.modules.equipment.service.EquipmentBrandService;
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 EquipmentBrandServiceImpl extends ServiceImpl<EquipmentBrandMapper, EquipmentBrand> implements EquipmentBrandService {


    @Autowired
	private EquipmentBrandMapper equipmentBrandMapper;



	@Override
	public EquipmentBrand selectEquipmentBrandById(Long id){
		return equipmentBrandMapper.selectEquipmentBrandById(id);
	}



	@Override
	public Long insertEquipmentBrand(EquipmentBrand equipmentBrand){
		return equipmentBrandMapper.insertEquipmentBrand(equipmentBrand);
	}



	@Override
	public int updateEquipmentBrandById(EquipmentBrand equipmentBrand){
		return equipmentBrandMapper.updateEquipmentBrandById(equipmentBrand);
	}



	@Override
	public int updateCoverEquipmentBrandById(EquipmentBrand equipmentBrand){
		return equipmentBrandMapper.updateCoverEquipmentBrandById(equipmentBrand);
	}



	@Override
	public int deleteEquipmentBrandById(Long id){
		return equipmentBrandMapper.deleteEquipmentBrandById(id);
	}

    @Override
    public EquipmentBrand selectEquipmentBrandByTypeBrand(Long typeId, String brand) {
        return equipmentBrandMapper.selectEquipmentBrandByTypeBrand(typeId,brand);
    }

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


	@Override
	public List<EquipmentBrand> selectEquipmentBrandByTypeAndLikeBrand(Long typeId, String bran) {
		return equipmentBrandMapper.selectEquipmentBrandByTypeAndLikeBrand(typeId,bran);
	}

    @Override
    public List<EquipmentBrand> selectAll() {
        return equipmentBrandMapper.selectAll();
    }

	@Override
	public List<EquipmentBrand> selectByTypeId(Long typeId) {
		return equipmentBrandMapper.selectByTypeId(typeId);
	}

	@Override
	public EquipmentBrand selectByBrand(String brand) {
		return equipmentBrandMapper.selectByBrand(brand);
	}
}
