src/main/java/com/kshrd/derphsar_api/rest/restcontroller/UserRestController.java
/**
     * Post a user
     *
     * @param userRequestModel - User request model
     * @return - Return response message
     */
Post a user
@param userRequestModel - User request model
@return - Return response message
Post a user @param userRequestModel - User request model @return - Return response message
@PostMapping("/register")
    @ApiOperation(value = "user register", response = UserResponseModel.class)
    public ResponseEntity<BaseApiNoPaginationResponse<UserResponseModel>> createUser(
            @RequestBody UserRequestModel userRequestModel) {
        BaseApiNoPaginationResponse<UserResponseModel> response = new BaseApiNoPaginationResponse<>();
        ModelMapper mapper = new ModelMapper();
        UserDto userDto = mapper.map(userRequestModel, UserDto.class);
        try{
            if(!userRequestModel.getName().isEmpty() && !userRequestModel.getEmail().isEmpty() && userRequestModel.getAge() != 0 && !userRequestModel.getPassword().isEmpty()  && !userRequestModel.getPhone().isEmpty()){
                userDto.setPassword(encoder.encode(userDto.getPassword()));
                userDto.setStatus(true);
                UUID uuid = UUID.randomUUID();
                userDto.setUserId("DP"+uuid.toString().substring(0,10));
                userDto.setStatus(true);
                UserDto result = userServiceImp.insertUser(userDto);
                UserResponseModel lastResponse = userServiceImp.getOneUserById(result.getUserId());
                UserResponseModel result2 = mapper.map(lastResponse, UserResponseModel.class);
                response.setMessage(message.inserted("User"));
                response.setData(result2);
                response.setStatus(HttpStatus.OK);
                response.setTime(new Timestamp(System.currentTimeMillis()));
            }else {
                response.setMessage(message.insertError("User"));
                response.setStatus(HttpStatus.BAD_REQUEST);
            }
        }catch (Exception e){
            response.setMessage(e.getCause().getMessage());
            response.setStatus(HttpStatus.BAD_REQUEST);
            response.setData(null);
        }
        return ResponseEntity.ok(response);
    }
@ PostMapping ( "/register" ) @ ApiOperation ( value = "user register" , response = UserResponseModel . class ) public ResponseEntity < BaseApiNoPaginationResponse < UserResponseModel > > createUser ( @ RequestBody UserRequestModel userRequestModel ) { BaseApiNoPaginationResponse < UserResponseModel > response = new BaseApiNoPaginationResponse < > ( ) ; ModelMapper mapper = new ModelMapper ( ) ; UserDto userDto = mapper . map ( userRequestModel , UserDto . class ) ; try { if ( ! userRequestModel . getName ( ) . isEmpty ( ) && ! userRequestModel . getEmail ( ) . isEmpty ( ) && userRequestModel . getAge ( ) != 0 && ! userRequestModel . getPassword ( ) . isEmpty ( ) && ! userRequestModel . getPhone ( ) . isEmpty ( ) ) { userDto . setPassword ( encoder . encode ( userDto . getPassword ( ) ) ) ; userDto . setStatus ( true ) ; UUID uuid = UUID . randomUUID ( ) ; userDto . setUserId ( "DP" + uuid . toString ( ) . substring ( 0 , 10 ) ) ; userDto . setStatus ( true ) ; UserDto result = userServiceImp . insertUser ( userDto ) ; UserResponseModel lastResponse = userServiceImp . getOneUserById ( result . getUserId ( ) ) ; UserResponseModel result2 = mapper . map ( lastResponse , UserResponseModel . class ) ; response . setMessage ( message . inserted ( "User" ) ) ; response . setData ( result2 ) ; response . setStatus ( HttpStatus . OK ) ; response . setTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ; } else { response . setMessage ( message . insertError ( "User" ) ) ; response . setStatus ( HttpStatus . BAD_REQUEST ) ; } } catch ( Exception e ) { response . setMessage ( e . getCause ( ) . getMessage ( ) ) ; response . setStatus ( HttpStatus . BAD_REQUEST ) ; response . setData ( null ) ; } return ResponseEntity . ok ( response ) ; }
Post a user
 @param userRequestModel - User request model
 @return - Return response message
Post a user @param userRequestModel - User request model @return - Return response message