-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarController.java
More file actions
61 lines (48 loc) · 1.79 KB
/
CarController.java
File metadata and controls
61 lines (48 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package ro.raffa.curs.controller.v1;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ro.raffa.curs.dto.CarDto;
import ro.raffa.curs.mapper.CarMapper;
import ro.raffa.curs.model.Car;
import ro.raffa.curs.repository.CarRepository;
import ro.raffa.curs.service.CarService;
@RestController
@RequestMapping("/v1")
public class CarController {
@Autowired
CarService carService;
@Autowired
CarRepository carRepository;
@Autowired
CarMapper carMapper;
@GetMapping("/car/list")
public List<CarDto> getCars() {
List<Car> list = carRepository.getAllCars();
return carMapper.map(list);
}
@GetMapping("/car/list/expensive")
public List<CarDto> getExpensiveCars(@RequestParam Integer percent) {
List<Car> list = carService.getExpensiveCars(percent);
return carMapper.map(list);
}
// TEMA
@GetMapping("/car/list/modify/stocks/increase")
public List<CarDto> getIncreasedStocks(@RequestParam Integer integer) {
List<Car> list = carService.increaseStocks(integer);
return carMapper.map(list);
}
@GetMapping("/car/list/modify/stocks/0")
public List<CarDto> setNoStocks() {
List<Car> list = carService.setCarStockEmpty();
return carMapper.map(list);
}
@GetMapping("/car/list/modify/stock/car")
public List<CarDto> modifyCarStock(@RequestParam String model, @RequestParam Integer integer) {
List<Car> list = carService.modifyCarStock(model, integer);
return carMapper.map(list);
}
}