Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java2b_20250412
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
alx_java2b_20250412
Commits
66428269
Commit
66428269
authored
May 24, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RestServer jeszcze bardziej ostateczna wersja
parent
3ce733df
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
ROrder.java
PC26-RestSerwer/src/main/java/sklep/rest/ROrder.java
+1
-1
RProduct.java
PC26-RestSerwer/src/main/java/sklep/rest/RProduct.java
+7
-1
No files found.
PC26-RestSerwer/src/main/java/sklep/rest/ROrder.java
View file @
66428269
...
...
@@ -71,7 +71,7 @@ public class ROrder {
// wyślemy przekierowanie pod adres tego klienta.
// To jest lepsze z punktu widzenia "dobrych praktyk REST".
@GET
@Path
(
"/{id:[0-9]
[0-9]*
}/customer"
)
@Path
(
"/{id:[0-9]
+
}/customer"
)
public
Response
getCustomer
(
@PathParam
(
"id"
)
Integer
orderId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
OrderDAO
orderDAO
=
db
.
orderDAO
();
...
...
PC26-RestSerwer/src/main/java/sklep/rest/RProduct.java
View file @
66428269
package
sklep
.
rest
;
import
java.math.BigDecimal
;
import
java.net.URI
;
import
java.util.List
;
import
jakarta.ws.rs.Consumes
;
...
...
@@ -11,6 +12,9 @@ import jakarta.ws.rs.PUT;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
import
jakarta.ws.rs.Produces
;
import
jakarta.ws.rs.core.Context
;
import
jakarta.ws.rs.core.Response
;
import
jakarta.ws.rs.core.UriInfo
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.ProductDAO
;
...
...
@@ -46,11 +50,13 @@ public class RProduct {
// POST potrafi "dodać rekord do katalogu".
@POST
@Consumes
({
"application/json"
,
"application/xml"
})
public
void
saveProduct
(
Product
product
)
throws
DBException
{
public
Response
saveProduct
(
Product
product
,
@Context
UriInfo
uriInfo
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
URI
uri
=
uriInfo
.
getAbsolutePathBuilder
().
path
(
"/{id}"
).
build
(
product
.
getProductId
());
return
Response
.
created
(
uri
).
build
();
}
}
...
...
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