SHARE
TWEET

Untitled

a guest Oct 19th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top