Skip to content

Commit 204704c

Browse files
committed
Initial Commit
1 parent 9c3fe72 commit 204704c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/main/java/com/webservice/mobile/app/ui/controller/UserController.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ public UserRest createUser(@RequestBody UserDetailsRequestModel userDetails) thr
3737

3838
UserRest returnValue = new UserRest();
3939

40-
if (userDetails.getFirstName().isEmpty()) throw new
40+
if (userDetails.getFirstName().isEmpty() ||
41+
userDetails.getLastName().isEmpty() ||
42+
userDetails.getEmail().isEmpty() ||
43+
userDetails.getPassword().isEmpty()
44+
) throw new
4145
UserServiceException(ErrorMessages.MISSING_REQUIRED_FIELD.getErrorMessage());
4246

4347
UserDTO userDTO = new UserDTO();
@@ -50,9 +54,22 @@ public UserRest createUser(@RequestBody UserDetailsRequestModel userDetails) thr
5054
}
5155

5256

53-
@PutMapping
54-
public String updateUser(){
55-
return "update user was called";
57+
@PutMapping(path = "/{id}",consumes = {MediaType.APPLICATION_XML_VALUE,
58+
MediaType.APPLICATION_JSON_VALUE},
59+
produces = {MediaType.APPLICATION_XML_VALUE,
60+
MediaType.APPLICATION_JSON_VALUE})
61+
public UserRest updateUser(@PathVariable String id, @RequestBody UserDetailsRequestModel userDetails){
62+
63+
UserRest returnValue = new UserRest();
64+
65+
UserDTO userDTO = new UserDTO();
66+
BeanUtils.copyProperties(userDetails,userDTO);
67+
68+
UserDTO updateUser = userService.updateUser(userDTO);
69+
BeanUtils.copyProperties(updateUser,returnValue);
70+
71+
72+
return returnValue;
5673
}
5774

5875
@DeleteMapping

0 commit comments

Comments
 (0)