insurerregservice/src/main/java/com/stackroute/pie/controller/InsurerController.java
//Method for adding a new policy for existing insurer
Method for adding a new policy for existing insurer
Method for adding a new policy for existing insurer
@PutMapping("/policy/newpolicy")
    public ResponseEntity<?> addNewPolicy(@RequestBody Policy insurerPolicy){
        if (!insurerRepository.existsByInsurerName(insurerPolicy.getInsurerName())) {
            return new ResponseEntity<>(new ResponseMessage("Insurer Not Found"),
                    HttpStatus.NOT_FOUND);
        }
        Insurer insurer = insurerService.addNewPolicy(insurerPolicy);
        kafkaTemplate.send("insurer_policy_json",insurer);
        return new ResponseEntity<Insurer>(insurer, HttpStatus.CREATED);
    }
@ PutMapping ( "/policy/newpolicy" ) public ResponseEntity < ? > addNewPolicy ( @ RequestBody Policy insurerPolicy ) { if ( ! insurerRepository . existsByInsurerName ( insurerPolicy . getInsurerName ( ) ) ) { return new ResponseEntity < > ( new ResponseMessage ( "Insurer Not Found" ) , HttpStatus . NOT_FOUND ) ; } Insurer insurer = insurerService . addNewPolicy ( insurerPolicy ) ; kafkaTemplate . send ( "insurer_policy_json" , insurer ) ; return new ResponseEntity < Insurer > ( insurer , HttpStatus . CREATED ) ; }
Method for adding a new policy for existing insurer
Method for adding a new policy for existing insurer