Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package ee.taltech.twentyonebackend.controller;
  2.  
  3.  
  4. import ee.taltech.twentyonebackend.exception.ValidationException;
  5. import ee.taltech.twentyonebackend.pojo.DataAuthenticator;
  6. import ee.taltech.twentyonebackend.pojo.UpdateGameData;
  7. import ee.taltech.twentyonebackend.pojo.request.CookForm;
  8. import ee.taltech.twentyonebackend.pojo.request.CraftForm;
  9. import ee.taltech.twentyonebackend.pojo.response.ResponseMessage;
  10. import org.springframework.http.ResponseEntity;
  11. import org.springframework.web.bind.annotation.*;
  12.  
  13. import javax.annotation.Resource;
  14.  
  15. @CrossOrigin(origins = "*", maxAge = 3600)
  16. @RestController
  17. @RequestMapping("/crafting")
  18. public class CraftingController {
  19.  
  20. @Resource
  21. DataAuthenticator dataAuthenticator;
  22.  
  23. @Resource
  24. UpdateGameData updateGameData;
  25.  
  26. @PostMapping("/craft")
  27. public ResponseEntity<?> authenticateUser(@RequestBody CraftForm craftForm) {
  28. if (!dataAuthenticator.authenticateSkill(craftForm.getUsername(), craftForm.getCraft())) {
  29. throw new ValidationException();
  30. }
  31.  
  32. updateGameData.cook(craftForm.getUsername(), craftForm.getCraft());
  33.  
  34. return ResponseEntity.ok(new ResponseMessage("Craft was made"));
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement