package com.muyu.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.CarType;
import com.muyu.common.domain.resp.CarTypeResp;
import com.muyu.server.mapper.CarTypeMapper;
import com.muyu.server.service.CarTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService{
@Autowired
private CarTypeMapper carTypeMapper;
    @Override
    public List<CarType> selectCarTypeList() {
        QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
        return carTypeMapper.selectList(carTypeQueryWrapper);
    }

    @Override
    public CarTypeResp selectCarTypeRespList(Long id) {
        return carTypeMapper.selectCarTypeRespList(id);
    }

    @Override
    public CarType findCarTypeById(Long carTypeId) {
        QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
        carTypeQueryWrapper.eq("car_type_id", carTypeId);
        CarType carType = carTypeMapper.selectOne(carTypeQueryWrapper);
        return carType;
    }

    @Override
    public List<CarTypeResp> findAllCars() {
        return carTypeMapper.findAllCars();
    }
}
