File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/main/java/com/hsbc/simpleapi/service Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11package com .hsbc .simpleapi .service ;
22
3+ import javax .persistence .EntityNotFoundException ;
4+
35import org .springframework .beans .factory .annotation .Autowired ;
46import org .springframework .stereotype .Service ;
57
68import com .hsbc .simpleapi .model .Customer ;
79import com .hsbc .simpleapi .dao .CustomerRepository ;
810
9- import javax .persistence .EntityNotFoundException ;
10-
1111@ Service
1212public class CustomerService {
1313
@@ -21,4 +21,9 @@ public CustomerService(CustomerRepository customerRepository) {
2121 public Customer insert (Customer customer ) {
2222 return customerRepository .save (customer );
2323 }
24+
25+ public Customer getCustomerBy (long id ) {
26+ return customerRepository .findById (id )
27+ .orElseThrow (() -> new EntityNotFoundException ("Customer under given id does not exist." ));
28+ }
2429}
You can’t perform that action at this time.
0 commit comments