Commit 33d9de06 by Patryk Czarnik

"application/pdf" w RProducts

parent eccb0d84
......@@ -16,6 +16,7 @@ import sklep.db.DBException;
import sklep.db.ProductDAO;
import sklep.db.RecordNotFound;
import sklep.model.Product;
import sklep.model.ProductList;
/* W tej klasie wejdziemy nawet do wnętrza produktów i udostępnimy osobno cenę
* /products/2/price
......@@ -32,11 +33,11 @@ import sklep.model.Product;
public class RProducts {
@GET
@Produces({"application/json", "application/xml", "text/plain"})
public List<Product> readAll() throws DBException {
@Produces({"application/json", "application/xml", "text/plain", "application/pdf"})
public ProductList readAll() throws DBException {
try(DBConnection db = DBConnection.open()) {
ProductDAO productDAO = db.productDAO();
return productDAO.readAll();
return new ProductList(productDAO.readAll());
}
}
......@@ -45,7 +46,7 @@ public class RProducts {
@GET
@Produces("text/html;charset=UTF-8")
public String readAllHTML() throws DBException {
List<Product> products = readAll();
List<Product> products = readAll().getProducts();
StringBuilder txt = new StringBuilder("<!DOCTYPE html>\n<html><body>\n");
txt.append("<h1>Lista produktów</h1>\n");
for(Product product : products) {
......@@ -56,7 +57,7 @@ public class RProducts {
}
@GET
@Produces({"application/json", "application/xml", "text/plain"})
@Produces({"application/json", "application/xml", "text/plain", "application/pdf"})
@Path("/{id}")
public Product readOne(@PathParam("id") int productId) throws DBException, RecordNotFound {
try(DBConnection db = DBConnection.open()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment