use of org.c4sg.dto.CreateUserDTO in project c4sg-services by Code4SocialGood.
the class UserController method createUser.
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Add a new user")
public UserDTO createUser(@ApiParam(value = "User object to return", required = true) @RequestBody CreateUserDTO createUserDTO) {
//calculate lat and long
try {
UserDTO userDTO = userService.createUser(createUserDTO);
GeoCodeUtil geoCodeUtil = new GeoCodeUtil(userDTO);
Map<String, BigDecimal> geoCode = geoCodeUtil.getGeoCode();
userDTO.setLatitude(geoCode.get("lat"));
userDTO.setLongitude(geoCode.get("lon"));
return userService.saveUser(userDTO);
} catch (Exception e) {
throw new NotFoundException("Error getting geocode");
}
}
Aggregations