Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
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_20230928
Commits
223eb2cc
Commit
223eb2cc
authored
Nov 08, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pierwszy POST
parent
7c80fed7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
RProducts.java
PC35-RestSerwer/src/main/java/rest/RProducts.java
+15
-2
No files found.
PC35-RestSerwer/src/main/java/rest/RProducts.java
View file @
223eb2cc
...
...
@@ -2,7 +2,9 @@ package rest;
import
java.util.List
;
import
jakarta.ws.rs.Consumes
;
import
jakarta.ws.rs.GET
;
import
jakarta.ws.rs.POST
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
import
jakarta.ws.rs.Produces
;
...
...
@@ -34,12 +36,23 @@ public class RProducts {
}
}
@POST
@Consumes
(
"application/json"
)
// W metodach typu POST i PUT powinien znajdować się dokładnie jeden parametr nieozanczony żadną adnotacją.
// Do tego parametru zostanie przekazana wartość utworzona na podstawie treści zapytania (content / body / entity).
// W adnotacji @Consumes określamy format, w jakim te dane mają być przysłane.
public
void
saveProduct
(
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
}
}
@GET
@Path
(
"/{id}/photo"
)
@Produces
(
"image/jpeg"
)
public
byte
[]
getPhoto
(
@PathParam
(
"id"
)
int
productId
)
throws
DBException
,
RecordNotFound
{
return
PhotoUtil
.
readBytes
(
productId
);
}
}
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