Untitled
unknown
plain_text
2 years ago
1.0 kB
6
Indexable
package com.codility.app;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@Controller
public class UsersController {
private final UsersService usersService;
@Autowired
public UsersController(UsersService usersService) {
this.usersService = usersService;
}
@GetMapping("/users/{username}/items/total")
@ResponseBody
public Map<String, Integer> totalItemsBought(@PathVariable String username) {
int totalItemsBought = usersService.getNumberOfItemsBought(username);
Map<String, Integer> response = new HashMap<>();
response.put("totalItemsBought", totalItemsBought);
return response;
}
}
Editor is loading...