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
fc67d50b
Commit
fc67d50b
authored
Aug 20, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zapiszProdukt i dużo komentarzy :-)
parent
909a39c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
+15
-1
RProducts.java
PC32-RestSerwer/src/main/java/sklep/rest/RProducts.java
+15
-1
No files found.
PC32-RestSerwer/src/main/java/sklep/rest/RProducts.java
View file @
fc67d50b
...
...
@@ -5,6 +5,7 @@ import java.util.List;
import
jakarta.ws.rs.Consumes
;
import
jakarta.ws.rs.GET
;
import
jakarta.ws.rs.POST
;
import
jakarta.ws.rs.PUT
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
...
...
@@ -89,7 +90,20 @@ public class RProducts {
productDAO
.
update
(
product
);
db
.
commit
();
}
}
}
// W praktyce REST metoda POST jest używana do dodawania nowych rekordów do katalogu.
// Może być także używana w innych celach - gdy klient ma "przysłać dane na serwer", a serwer coś z tym zrobi (podobnie jak to było w SOAP). @POST
// POST w tym miejscu jest lepszy niż PUT, bo zapisując nowy rekord, nie wiemy z góry jakie będzie będzie jego ID,
// czyli nie wiemey, pod adresem zapisze się nowy produkt.
// POST potrafi "dodać rekord do katalogu".
public
void
zapiszProdukt
(
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
}
}
@GET
@Produces
(
"image/jpeg"
)
...
...
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