Skip to content

Commit 5cfe0d7

Browse files
committed
building binded backend
1 parent c2ee185 commit 5cfe0d7

File tree

3 files changed

+16
-49
lines changed

3 files changed

+16
-49
lines changed
Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { Building } from '../modals/building';
3+
import { BuildingService } from '../services/building.service';
34

45
@Component({
56
selector: 'app-buildings-section',
@@ -9,55 +10,15 @@ import { Building } from '../modals/building';
910
export class BuildingsSectionComponent implements OnInit {
1011

1112

12-
public buildingList: Building[]= [
13-
{
14-
name: "Comfort Apt",
15-
price: 2500,
16-
address: "West Street",
17-
beds:3,
18-
baths:2,
19-
carSpaces:1,
20-
size:125,
21-
listingType: 'Mo',
22-
priceUnit: '$'
23-
},
24-
{
25-
name: "Comfort Apt",
26-
price: 2500,
27-
address: "West Street",
28-
beds:3,
29-
baths:2,
30-
carSpaces:1,
31-
size:125,
32-
listingType: 'Mo',
33-
priceUnit: '$'
34-
},
35-
{
36-
name: "Comfort Apt",
37-
price: 2500,
38-
address: "West Street",
39-
beds:3,
40-
baths:2,
41-
carSpaces:1,
42-
size:125,
43-
listingType: 'Mo',
44-
priceUnit: '$'
45-
},
46-
{
47-
name: "Comfort Apt",
48-
price: 2500,
49-
address: "West Street",
50-
beds:3,
51-
baths:2,
52-
carSpaces:1,
53-
size:125,
54-
listingType: 'Mo',
55-
priceUnit: '$'
56-
}
57-
]
58-
constructor() { }
13+
public buildingList: Building[]=[];
14+
15+
constructor(private service: BuildingService) { }
5916

6017
ngOnInit() {
18+
this.service.getBuildings().subscribe(building=>{
19+
this.buildingList = building;
20+
console.log(building);
21+
});
6122
}
6223

6324
}

leasesoft/src/main/java/com/alper/leasesoftprov2/leasesoft/buildings/Building.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Building {
1818
@GeneratedValue(strategy = GenerationType.IDENTITY)
1919
private Integer id;
2020

21+
@JsonProperty("name")
2122
@Column(name = "block_name")
2223
private String blockName;
2324

@@ -27,9 +28,11 @@ public class Building {
2728
@Column(name = "building_size")
2829
private Double size;
2930

31+
@JsonProperty("beds")
3032
@Column(name = "num_bedrooms")
3133
private Integer bedrooms;
3234

35+
@JsonProperty("baths")
3336
@Column(name = "num_bathrooms")
3437
private Integer bathrooms;
3538

@@ -47,5 +50,7 @@ public class Building {
4750
@Column(name="lot", precision = 10, scale=7)
4851
private BigDecimal lot;
4952

53+
@Column(name = "address")
54+
private String address;
5055

5156
}

leasesoft/src/main/java/com/alper/leasesoftprov2/leasesoft/buildings/BuildingController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
import org.springframework.web.bind.annotation.RestController;
77

88
import java.util.List;
9+
import java.util.stream.Collectors;
910

1011
@RestController
1112
@RequestMapping("api/v1/buildings")
1213
public class BuildingController {
1314
@Autowired
1415
public BuildingService service;
1516

16-
@GetMapping("") //add filter, error handling.
17+
@GetMapping("") //add filter, error handling. add pagination
1718
public List<Building> getAllBuildings(){
18-
return this.service.getBuildings();
19+
return this.service.getBuildings().stream().limit(12).collect(Collectors.toList());
1920
}
2021
}

0 commit comments

Comments
 (0)