Changeset dfd5d87 for phonelux-backend/src/main/java/finki
- Timestamp:
- 08/29/22 22:31:57 (2 years ago)
- Branches:
- master
- Children:
- dbd4834
- Parents:
- b68ae8d
- Location:
- phonelux-backend/src/main/java/finki/it/phoneluxbackend
- Files:
-
- 18 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/PhoneController.java
rb68ae8d rdfd5d87 19 19 } 20 20 21 22 // handle request parameters for filtering phones 21 23 @GetMapping 22 24 public List<Phone> getPhones(){ … … 24 26 } 25 27 26 @PostMapping(path = "{phoneId}")27 public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){28 return phoneService.getOffersForPhone(phoneId);29 }30 31 28 } -
phonelux-backend/src/main/java/finki/it/phoneluxbackend/entities/Phone.java
rb68ae8d rdfd5d87 25 25 private String model; 26 26 27 @Column(name = "image_url") 28 private String image_url; 29 27 30 @OneToMany(fetch = FetchType.LAZY, mappedBy = "phone") 28 31 @JsonIgnore -
phonelux-backend/src/main/java/finki/it/phoneluxbackend/entities/PhoneOffer.java
rb68ae8d rdfd5d87 77 77 @JsonIgnore 78 78 private Phone phone; 79 80 public PhoneOffer(String offer_shop, String offer_name, 81 Integer price, String ram_memory, 82 String rom_memory, String color, 83 String front_camera, String back_camera, 84 String chipset, String battery, 85 String operating_system, String cpu, 86 String image_url, String offer_url, 87 Date last_updated, Boolean is_validated, 88 String offer_description, String offer_shop_code, Phone phone) { 89 this.offer_shop = offer_shop; 90 this.offer_name = offer_name; 91 this.price = price; 92 this.ram_memory = ram_memory; 93 this.rom_memory = rom_memory; 94 this.color = color; 95 this.front_camera = front_camera; 96 this.back_camera = back_camera; 97 this.chipset = chipset; 98 this.battery = battery; 99 this.operating_system = operating_system; 100 this.cpu = cpu; 101 this.image_url = image_url; 102 this.offer_url = offer_url; 103 this.last_updated = last_updated; 104 this.is_validated = is_validated; 105 this.offer_description = offer_description; 106 this.offer_shop_code = offer_shop_code; 107 this.phone = phone; 108 } 79 109 } -
phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneService.java
rb68ae8d rdfd5d87 21 21 } 22 22 23 public List<PhoneOffer> getOffersForPhone(Long phoneId) {24 boolean exists = phoneRepository.existsById(phoneId);25 if(!exists)26 throw new IllegalStateException("Phone with id "+phoneId+" does not exist");27 28 return phoneRepository.findById(phoneId).get().getPhoneOffers();29 }30 23 }
Note:
See TracChangeset
for help on using the changeset viewer.