insurerregservice/src/main/java/com/stackroute/pie/controller/InsurerController.java
//Method for registering a new Insurer
Method for registering a new Insurer
Method for registering a new Insurer
@PostMapping("/signup")
    public ResponseEntity<?> registerUser(@RequestBody SignUpForm signUpRequest) {
        if (insurerRepository.existsByInsurerLicense(signUpRequest.getInsurerLicense())) {
            return new ResponseEntity<>(new ResponseMessage("Fail -> Username is already taken!"),
                    HttpStatus.CONFLICT);
        }
        if (insurerRepository.existsByInsurerEmail(signUpRequest.getInsurerEmail())) {
            return new ResponseEntity<>(new ResponseMessage("Fail -> Email is already in use!"),
                    HttpStatus.CONFLICT);
        }
        signUpRequest.setPassword(bCryptPasswordEncoder.encode(signUpRequest.getPassword()));
        Insurer insurer = insurerService.addInsurer(signUpRequest);
        kafkaTemplate.send("company_1_json",insurer);
        return new ResponseEntity<>(new ResponseMessage("Insurer registered successfully!"), HttpStatus.CREATED);
    }
@ PostMapping ( "/signup" ) public ResponseEntity < ? > registerUser ( @ RequestBody SignUpForm signUpRequest ) { if ( insurerRepository . existsByInsurerLicense ( signUpRequest . getInsurerLicense ( ) ) ) { return new ResponseEntity < > ( new ResponseMessage ( "Fail -> Username is already taken!" ) , HttpStatus . CONFLICT ) ; } if ( insurerRepository . existsByInsurerEmail ( signUpRequest . getInsurerEmail ( ) ) ) { return new ResponseEntity < > ( new ResponseMessage ( "Fail -> Email is already in use!" ) , HttpStatus . CONFLICT ) ; } signUpRequest . setPassword ( bCryptPasswordEncoder . encode ( signUpRequest . getPassword ( ) ) ) ; Insurer insurer = insurerService . addInsurer ( signUpRequest ) ; kafkaTemplate . send ( "company_1_json" , insurer ) ; return new ResponseEntity < > ( new ResponseMessage ( "Insurer registered successfully!" ) , HttpStatus . CREATED ) ; }
Method for registering a new Insurer
Method for registering a new Insurer
//Calling InsurerService to add into the MongoDB //Kafka producing the Insurer pojo ,so that login microservice can consume it