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
bcf17be7
Commit
bcf17be7
authored
May 10, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dodatkowe metody usługi Sklep
parent
cddd9468
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
Sklep.java
PC24-SklepSoap/src/main/java/sklep/soap/Sklep.java
+38
-3
No files found.
PC24-SklepSoap/src/main/java/sklep/soap/Sklep.java
View file @
bcf17be7
package
sklep
.
soap
;
package
sklep
.
soap
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
jakarta.jws.WebService
;
import
jakarta.jws.WebService
;
import
sklep.db.DBConnection
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.DBException
;
import
sklep.db.OrderDAO
;
import
sklep.db.ProductDAO
;
import
sklep.db.ProductDAO
;
import
sklep.db.RecordNotFound
;
import
sklep.model.Order
;
import
sklep.model.Product
;
import
sklep.model.Product
;
@WebService
@WebService
...
@@ -18,10 +22,41 @@ public class Sklep {
...
@@ -18,10 +22,41 @@ public class Sklep {
}
}
}
}
// TODO dodaj metody findByPrice, findById, który odczytują tylko wybrane produkty
public
List
<
Product
>
readProductsByPrice
(
BigDecimal
minPrice
,
BigDecimal
maxPrice
)
throws
DBException
{
// wykorzystując metody klasy ProductDAO
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
findByPrice
(
minPrice
,
maxPrice
);
}
}
public
Product
readOneProduct
(
int
productId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
findById
(
productId
);
}
}
// zapisywanie produktu (Product jest parametrem wejściowym)
public
void
saveProduct
(
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
}
}
// dla chętnych kolejne metody: zapisywanie produktu (Product jest parametrem weejściowym)
// odczyt zamówienia wg ID a może też odczyt wszystkich zamówień wskazanego klienta
// odczyt zamówienia wg ID a może też odczyt wszystkich zamówień wskazanego klienta
public
Order
readOneOrder
(
int
orderId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
OrderDAO
orderDAO
=
db
.
orderDAO
();
return
orderDAO
.
findById
(
orderId
);
}
}
public
List
<
Order
>
readCustomerOrders
(
String
email
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
OrderDAO
orderDAO
=
db
.
orderDAO
();
return
orderDAO
.
customerOrders
(
email
);
}
}
}
}
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