package com.willalp.web.demo.twotable.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.willalp.web.demo.twotable.entity.Car;
import com.willalp.web.demo.twotable.entity.CarModel;
import com.willalp.web.demo.twotable.mapper.CarMapper;
import com.willalp.web.demo.twotable.service.ICarModelService;
import com.willalp.web.demo.twotable.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

@Transactional
@Service("carService")
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarService {
    @Autowired
    private ICarModelService carModelService;

    @Override
    public boolean removeById(Serializable id) {
        carModelService.remove(new QueryWrapper<CarModel>().eq("car_id",id));
        return super.removeById(id);
    }
}
