Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/service/impl/UserServiceImpl.java
re02787e r2a552fe 1 1 package com.example.autopartz.service.impl; 2 2 3 import com.example.autopartz.model.Role; 4 import com.example.autopartz.model.User; 3 import com.example.autopartz.model.*; 4 import com.example.autopartz.repository.CarRepository; 5 import com.example.autopartz.repository.CarSampleRepository; 6 import com.example.autopartz.repository.ServiceBookRepository; 5 7 import com.example.autopartz.repository.UserRepository; 6 8 import com.example.autopartz.service.UserService; 7 9 import org.springframework.stereotype.Service; 8 10 9 import java .util.Collections;11 import javax.transaction.Transactional; 10 12 import java.util.List; 11 13 … … 13 15 public class UserServiceImpl implements UserService { 14 16 private final UserRepository userRepository; 17 private final CarRepository carRepository; 18 private final CarSampleRepository carSampleRepository; 19 private final ServiceBookRepository serviceBookRepository; 15 20 16 public UserServiceImpl(UserRepository userRepository ) {21 public UserServiceImpl(UserRepository userRepository, CarRepository carRepository, CarSampleRepository carSampleRepository, ServiceBookRepository serviceBookRepository) { 17 22 this.userRepository = userRepository; 23 this.carRepository = carRepository; 24 this.carSampleRepository = carSampleRepository; 25 this.serviceBookRepository = serviceBookRepository; 18 26 } 19 27 … … 32 40 return userRepository.findById(id).get(); 33 41 } 42 43 @Override 44 @Transactional 45 public void addCarSampleForUser(Integer vin, Integer year, Integer power, Integer displacement, String fuel, Integer km, Integer cartype, String username) { 46 CarSample cs = new CarSample(vin, year, power, displacement, fuel, km, (Client) this.findByUsername(username), carRepository.findById(cartype).get()); 47 carSampleRepository.save(cs); 48 serviceBookRepository.save(new ServiceBook(cs)); 49 } 34 50 }
Note:
See TracChangeset
for help on using the changeset viewer.