-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTotalSaleController.java
More file actions
36 lines (28 loc) · 949 Bytes
/
TotalSaleController.java
File metadata and controls
36 lines (28 loc) · 949 Bytes
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
package hello;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TotalSaleController {
@RequestMapping(value = "/sales", method = RequestMethod.GET)
public List<TotalSales> totalsales() {
List<TotalSales> total = new ArrayList<TotalSales>();
for(Employee e : Carshop.employees){
int totalCash = 0;
for (Sale s : Carshop.sales) {
if(s.getEmployeeId() == e.getId()) {
for (Carmodel c : Carshop.carmodels) {
if (c.getid() == s.getCarmodelId()) {
totalCash += c.price;
}
}
}
}
TotalSales sales = new TotalSales(e.getId(),e.getName(),totalCash);
total.add(sales);
}
return total;
}
}