diff --git a/account-service/src/main/java/com/piggymetrics/account/controller/AccountController.java b/account-service/src/main/java/com/piggymetrics/account/controller/AccountController.java index 2361a912cb..fc298bbf72 100644 --- a/account-service/src/main/java/com/piggymetrics/account/controller/AccountController.java +++ b/account-service/src/main/java/com/piggymetrics/account/controller/AccountController.java @@ -17,22 +17,22 @@ public class AccountController { private AccountService accountService; @PreAuthorize("#oauth2.hasScope('server') or #name.equals('demo')") - @RequestMapping(path = "/{name}", method = RequestMethod.GET) + @GetMapping("/{name}") public Account getAccountByName(@PathVariable String name) { return accountService.findByName(name); } - @RequestMapping(path = "/current", method = RequestMethod.GET) + @GetMapping("/current") public Account getCurrentAccount(Principal principal) { return accountService.findByName(principal.getName()); } - @RequestMapping(path = "/current", method = RequestMethod.PUT) + @PutMapping("/current") public void saveCurrentAccount(Principal principal, @Valid @RequestBody Account account) { accountService.saveChanges(principal.getName(), account); } - @RequestMapping(path = "/", method = RequestMethod.POST) + @PostMapping("/") public Account createNewAccount(@Valid @RequestBody User user) { return accountService.create(user); } diff --git a/auth-service/src/main/java/com/piggymetrics/auth/controller/UserController.java b/auth-service/src/main/java/com/piggymetrics/auth/controller/UserController.java index c519721ace..3fcfa371b0 100644 --- a/auth-service/src/main/java/com/piggymetrics/auth/controller/UserController.java +++ b/auth-service/src/main/java/com/piggymetrics/auth/controller/UserController.java @@ -4,10 +4,7 @@ import com.piggymetrics.auth.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; -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.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.security.Principal; @@ -19,13 +16,13 @@ public class UserController { @Autowired private UserService userService; - @RequestMapping(value = "/current", method = RequestMethod.GET) + @GetMapping("/current") public Principal getUser(Principal principal) { return principal; } @PreAuthorize("#oauth2.hasScope('server')") - @RequestMapping(method = RequestMethod.POST) + @PostMapping public void createUser(@Valid @RequestBody User user) { userService.create(user); } diff --git a/notification-service/src/main/java/com/piggymetrics/notification/controller/RecipientController.java b/notification-service/src/main/java/com/piggymetrics/notification/controller/RecipientController.java index c7b2dac3e0..345d054e1b 100644 --- a/notification-service/src/main/java/com/piggymetrics/notification/controller/RecipientController.java +++ b/notification-service/src/main/java/com/piggymetrics/notification/controller/RecipientController.java @@ -3,10 +3,7 @@ import com.piggymetrics.notification.domain.Recipient; import com.piggymetrics.notification.service.RecipientService; import org.springframework.beans.factory.annotation.Autowired; -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.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.security.Principal; @@ -18,12 +15,12 @@ public class RecipientController { @Autowired private RecipientService recipientService; - @RequestMapping(path = "/current", method = RequestMethod.GET) + @GetMapping("/current") public Object getCurrentNotificationsSettings(Principal principal) { return recipientService.findByAccountName(principal.getName()); } - @RequestMapping(path = "/current", method = RequestMethod.PUT) + @PutMapping("/current") public Object saveCurrentNotificationsSettings(Principal principal, @Valid @RequestBody Recipient recipient) { return recipientService.save(principal.getName(), recipient); } diff --git a/statistics-service/src/main/java/com/piggymetrics/statistics/controller/StatisticsController.java b/statistics-service/src/main/java/com/piggymetrics/statistics/controller/StatisticsController.java index 788737bea0..2530917b8c 100644 --- a/statistics-service/src/main/java/com/piggymetrics/statistics/controller/StatisticsController.java +++ b/statistics-service/src/main/java/com/piggymetrics/statistics/controller/StatisticsController.java @@ -17,19 +17,19 @@ public class StatisticsController { @Autowired private StatisticsService statisticsService; - @RequestMapping(value = "/current", method = RequestMethod.GET) + @GetMapping("/current") public List getCurrentAccountStatistics(Principal principal) { return statisticsService.findByAccountName(principal.getName()); } @PreAuthorize("#oauth2.hasScope('server') or #accountName.equals('demo')") - @RequestMapping(value = "/{accountName}", method = RequestMethod.GET) + @GetMapping("/{accountName}") public List getStatisticsByAccountName(@PathVariable String accountName) { return statisticsService.findByAccountName(accountName); } @PreAuthorize("#oauth2.hasScope('server')") - @RequestMapping(value = "/{accountName}", method = RequestMethod.PUT) + @PutMapping("/{accountName}") public void saveAccountStatistics(@PathVariable String accountName, @Valid @RequestBody Account account) { statisticsService.save(accountName, account); }