Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
javab_20230617
Commits
33d9de06
Commit
33d9de06
authored
Aug 20, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"application/pdf" w RProducts
parent
eccb0d84
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
RProducts.java
PC32-RestSerwer/src/main/java/sklep/rest/RProducts.java
+6
-5
No files found.
PC32-RestSerwer/src/main/java/sklep/rest/RProducts.java
View file @
33d9de06
...
...
@@ -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
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment