Package com.cyran.tp.server.products
Class ProductControllerRDBS
java.lang.Object
com.cyran.tp.server.products.ProductControllerRDBS
@RestController
public class ProductControllerRDBS
extends java.lang.Object
Managing products and storing information about them
- Author:
- Jakub Perdek
-
Constructor Summary
Constructors Constructor Description ProductControllerRDBS()
-
Method Summary
Modifier and Type Method Description java.lang.String
createProduct(javax.servlet.http.HttpServletRequest request, java.lang.String body, javax.servlet.http.HttpServletResponse response)
Method for product creationProductsDTO[]
getFirstProducts(javax.servlet.http.HttpServletRequest request, java.lang.Integer count, javax.servlet.http.HttpServletResponse response)
Method for obtaining first n products from DB to be displayed in main pagejava.lang.String
updateProduct(javax.servlet.http.HttpServletRequest request, java.lang.String body, javax.servlet.http.HttpServletResponse response)
Method for updating product
-
Constructor Details
-
ProductControllerRDBS
public ProductControllerRDBS()
-
-
Method Details
-
getFirstProducts
@RequestMapping(path="/firstProducts", method=GET, produces="application/json") @ResponseBody @CrossOrigin public ProductsDTO[] getFirstProducts(javax.servlet.http.HttpServletRequest request, @RequestParam java.lang.Integer count, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedExceptionMethod for obtaining first n products from DB to be displayed in main page- Parameters:
request
- - request for obtaining firs n productscount
- - number of products which should be obtained from DBresponse
- - response which should be send back- Returns:
- obtained n products from DB
- Throws:
java.lang.InterruptedException
- if something interrupts it
-
createProduct
@RequestMapping(path="/product/insert", method=POST, produces="application/json") @ResponseBody @CrossOrigin public java.lang.String createProduct(javax.servlet.http.HttpServletRequest request, @RequestBody java.lang.String body, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedException, org.json.simple.parser.ParseExceptionMethod for product creation- Parameters:
request
- - request for product creationbody
- - body of post request with all information about productresponse
- - response which should be send back- Returns:
- string that confirms of product creation, otherwise denial of it or some error message
- Throws:
java.lang.InterruptedException
- if something interrupts itorg.json.simple.parser.ParseException
- if parsing of body JSON went wrong
-
updateProduct
@RequestMapping(path="/product/update", method=POST, produces="application/json") @ResponseBody @CrossOrigin public java.lang.String updateProduct(javax.servlet.http.HttpServletRequest request, @RequestBody java.lang.String body, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedException, org.json.simple.parser.ParseExceptionMethod for updating product- Parameters:
request
- - request for updating productbody
- - body of post request with all information for updating product - name identifies product and cant be changedresponse
- - response which should be send back- Returns:
- string that confirms of product update, otherwise error information
- Throws:
java.lang.InterruptedException
- if something interrupts itorg.json.simple.parser.ParseException
- if parsing of body JSON went wrong
-