package api;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import dtos.UserDTO;
import services.UserService;

@RestController
@RequestMapping("/api/user")
public final class UserController {
    private final UserService service;

    @Autowired
    public UserController(UserService service) {
        this.service = service;
    }

    @RequestMapping(method = RequestMethod.POST)
    @ResponseStatus(HttpStatus.CREATED)
    UserDTO create(@RequestBody @Valid UserDTO userEntry) {
        return service.create(userEntry);
    }

    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    UserDTO delete(@PathVariable("id") String id) {
        return service.delete(id);
    }

    @RequestMapping(value = "{id}", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    UserDTO findById(@PathVariable("id") String id) {
        return service.findById(id);
    }

    @RequestMapping(value = "{id}", method = RequestMethod.PUT)
    UserDTO update(@RequestBody @Valid UserDTO userEntry) {
        return service.update(userEntry);
    }

    @RequestMapping(method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    List<UserDTO> findAll() {
        return service.findAll();
    }
}

@@ -1,16 +1,28 @@
 package 
+com.routeme.
 api;%0A%0Aim
@@ -566,12 +566,23 @@
 ort 
-dtos
+com.routeme.dtl
 .Use
@@ -598,16 +598,27 @@
 ort 
+com.routeme.
 service
-s
 .Use
@@ -660,16 +660,24 @@
 Mapping(
+value = 
 %22/api/us
@@ -678,16 +678,17 @@
 api/user
+s
 %22)%0Apubli
@@ -908,12 +908,259 @@
 hod.
-POST
+GET, produces = %22application/json%22)%0A    @ResponseStatus(HttpStatus.OK)%0A    List%3CUserDTO%3E findAll() %7B%0A        return service.findAll();%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.POST, consumes = %22application/json%22, produces = %22application/json%22
 )%0A  
@@ -1327,32 +1327,33 @@
 apping(value = %22
+/
 %7Bid%7D%22, method = 
@@ -1372,16 +1372,47 @@
 d.DELETE
+, produces = %22application/json%22
 )%0A    Us
@@ -1520,32 +1520,33 @@
 apping(value = %22
+/
 %7Bid%7D%22, method = 
@@ -1554,32 +1554,63 @@
 equestMethod.GET
+, produces = %22application/json%22
 )%0A    @ResponseS
@@ -1757,16 +1757,17 @@
 alue = %22
+/
 %7Bid%7D%22, m
@@ -1795,231 +1795,273 @@
 .PUT
-)%0A    UserDTO update(@RequestBody @Valid UserDTO userEntry) %7B%0A        return service.update(userEntry);%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.GET)%0A    @ResponseStatus(HttpStatus.OK)%0A    List%3CUserDTO%3E findAll() %7B
+, consumes = %22application/json%22, produces = %22application/json%22)%0A    UserDTO update(@RequestBody @Valid UserDTO userEntry, @PathVariable(%22id%22) String id) %7B%0A        // TODO: Need not send whole user entity. For the user case of needing%0A        // to update one field.
 %0A   
@@ -2076,31 +2076,39 @@
 urn service.
-findAll(
+update(userEntry
 );%0A    %7D%0A%7D%0A
@@ -2105,10 +2105,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Fix user controller