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
44f97dc9
Commit
44f97dc9
authored
Nov 09, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zwracanie usupełnionego produktu w POST
parent
678333c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
23 deletions
+3
-23
RProducts.java
PC35-RestSerwer/src/main/java/rest/RProducts.java
+3
-23
No files found.
PC35-RestSerwer/src/main/java/rest/RProducts.java
View file @
44f97dc9
...
@@ -75,39 +75,19 @@ public class RProducts {
...
@@ -75,39 +75,19 @@ public class RProducts {
@POST
@POST
@Consumes
({
"application/json"
,
"application/xml"
})
@Consumes
({
"application/json"
,
"application/xml"
})
@Produces
({
"application/json"
})
@Produces
({
"application/json"
,
"application/xml"
})
// W metodach typu POST i PUT powinien znajdować się dokładnie jeden parametr nieozanczony żadną adnotacją.
// 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).
// 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.
// W adnotacji @Consumes określamy format, w jakim te dane mają być przysłane.
public
InformacjaZwrotna
saveProduct
(
Product
product
)
throws
DBException
{
public
Product
saveProduct
(
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
productDAO
.
save
(
product
);
db
.
commit
();
db
.
commit
();
return
new
InformacjaZwrotna
(
product
.
getProductId
());
return
product
;
}
}
public
static
class
InformacjaZwrotna
{
private
int
noweId
;
public
InformacjaZwrotna
()
{
}
public
InformacjaZwrotna
(
int
noweId
)
{
this
.
noweId
=
noweId
;
}
public
int
getNoweId
()
{
return
noweId
;
}
public
void
setNoweId
(
int
noweId
)
{
this
.
noweId
=
noweId
;
}
}
}
}
// Ta metoda zwraca wartość wybranego pola w rekordzie.
// Ta metoda zwraca wartość wybranego pola w rekordzie.
// W praktyce rzadko kiedy twozy się takie metody, ale gdybyśmy wiedzieli, że klient akurat takiej rzeczy może potrzebować,
// W praktyce rzadko kiedy twozy się takie metody, ale gdybyśmy wiedzieli, że klient akurat takiej rzeczy może potrzebować,
// to można taką dodatkową meotdę stworzyć.
// to można taką dodatkową meotdę stworzyć.
...
...
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