@RequestMapping(value = "/update", method = RequestMethod.POST) public @ResponseBody UserDto update( @RequestParam String username, @RequestParam String firstName, @RequestParam String lastName, @RequestParam Integer role) { Role existingRole = new Role(); existingRole.setRole(role); User existingUser = new User(); existingUser.setUsername(username); existingUser.setFirstName(firstName); existingUser.setLastName(lastName); existingUser.setRole(existingRole); return UserMapper.map(service.update(existingUser)); }
@RequestMapping(value = "/create", method = RequestMethod.POST) public @ResponseBody UserDto create( @RequestParam String username, @RequestParam String password, @RequestParam String firstName, @RequestParam String lastName, @RequestParam Integer role) { Role newRole = new Role(); newRole.setRole(role); User newUser = new User(); newUser.setUsername(username); newUser.setPassword(password); newUser.setFirstName(firstName); newUser.setLastName(lastName); newUser.setRole(newRole); return UserMapper.map(service.create(newUser)); }