Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
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
java_dzienna_15_09
Commits
fb020083
Commit
fb020083
authored
Oct 06, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odsyłanie uzupełnionego rekordu w POST
parent
cad30a2c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletions
+4
-1
RProducts.java
PC34-RestSerwer/src/main/java/sklep/rest/RProducts.java
+4
-1
No files found.
PC34-RestSerwer/src/main/java/sklep/rest/RProducts.java
View file @
fb020083
...
@@ -79,9 +79,11 @@ public class RProducts {
...
@@ -79,9 +79,11 @@ public class RProducts {
// Powszechnie przyjętą praktyką w REST jest to, że
// Powszechnie przyjętą praktyką w REST jest to, że
// zapytanie typu POST przysłane pod adres katalogu (np. /products)
// zapytanie typu POST przysłane pod adres katalogu (np. /products)
// jest traktowane jako polecenie dodania nowego rekordu.
// jest traktowane jako polecenie dodania nowego rekordu.
// W tej wersji w odpowiedzi odsyłany jest cały rekord Product uzupełniony o pole ID.
@POST
@POST
@Consumes
(
"application/json"
)
@Consumes
(
"application/json"
)
public
void
addProduct
(
Product
product
)
throws
DBException
{
@Produces
(
"application/json"
)
public
Product
addProduct
(
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
ProductDAO
productDAO
=
db
.
productDAO
();
if
(
product
.
getProductId
()
!=
null
)
{
if
(
product
.
getProductId
()
!=
null
)
{
...
@@ -89,6 +91,7 @@ public class RProducts {
...
@@ -89,6 +91,7 @@ public class RProducts {
}
}
productDAO
.
insertNew
(
product
);
productDAO
.
insertNew
(
product
);
db
.
commit
();
db
.
commit
();
return
product
;
}
}
}
}
...
...
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