File tree Expand file tree Collapse file tree 3 files changed +16
-49
lines changed
leasesoft/src/main/java/com/alper/leasesoftprov2/leasesoft/buildings
leasesoft-ui/src/app/buildings-section Expand file tree Collapse file tree 3 files changed +16
-49
lines changed Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { Building } from '../modals/building' ;
3
+ import { BuildingService } from '../services/building.service' ;
3
4
4
5
@Component ( {
5
6
selector : 'app-buildings-section' ,
@@ -9,55 +10,15 @@ import { Building } from '../modals/building';
9
10
export class BuildingsSectionComponent implements OnInit {
10
11
11
12
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 ) { }
59
16
60
17
ngOnInit ( ) {
18
+ this . service . getBuildings ( ) . subscribe ( building => {
19
+ this . buildingList = building ;
20
+ console . log ( building ) ;
21
+ } ) ;
61
22
}
62
23
63
24
}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ public class Building {
18
18
@ GeneratedValue (strategy = GenerationType .IDENTITY )
19
19
private Integer id ;
20
20
21
+ @ JsonProperty ("name" )
21
22
@ Column (name = "block_name" )
22
23
private String blockName ;
23
24
@@ -27,9 +28,11 @@ public class Building {
27
28
@ Column (name = "building_size" )
28
29
private Double size ;
29
30
31
+ @ JsonProperty ("beds" )
30
32
@ Column (name = "num_bedrooms" )
31
33
private Integer bedrooms ;
32
34
35
+ @ JsonProperty ("baths" )
33
36
@ Column (name = "num_bathrooms" )
34
37
private Integer bathrooms ;
35
38
@@ -47,5 +50,7 @@ public class Building {
47
50
@ Column (name ="lot" , precision = 10 , scale =7 )
48
51
private BigDecimal lot ;
49
52
53
+ @ Column (name = "address" )
54
+ private String address ;
50
55
51
56
}
Original file line number Diff line number Diff line change 6
6
import org .springframework .web .bind .annotation .RestController ;
7
7
8
8
import java .util .List ;
9
+ import java .util .stream .Collectors ;
9
10
10
11
@ RestController
11
12
@ RequestMapping ("api/v1/buildings" )
12
13
public class BuildingController {
13
14
@ Autowired
14
15
public BuildingService service ;
15
16
16
- @ GetMapping ("" ) //add filter, error handling.
17
+ @ GetMapping ("" ) //add filter, error handling. add pagination
17
18
public List <Building > getAllBuildings (){
18
- return this .service .getBuildings ();
19
+ return this .service .getBuildings (). stream (). limit ( 12 ). collect ( Collectors . toList ()) ;
19
20
}
20
21
}
You can’t perform that action at this time.
0 commit comments