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
af868a09
Commit
af868a09
authored
Jun 01, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ROrders i poprawki
parent
88cf0058
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
3 deletions
+50
-3
OrderRepository.java
...ersey/src/main/java/sklep/repository/OrderRepository.java
+7
-0
JerseyConfig.java
PC38-SpringJersey/src/main/java/sklep/rest/JerseyConfig.java
+2
-2
ROrders.java
PC38-SpringJersey/src/main/java/sklep/rest/ROrders.java
+41
-0
RProducts.java
PC38-SpringJersey/src/main/java/sklep/rest/RProducts.java
+0
-1
No files found.
PC38-SpringJersey/src/main/java/sklep/repository/OrderRepository.java
0 → 100644
View file @
af868a09
package
sklep
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
sklep.model.Order
;
public
interface
OrderRepository
extends
JpaRepository
<
Order
,
Integer
>
{
}
PC38-SpringJersey/src/main/java/sklep/rest/JerseyConfig.java
View file @
af868a09
...
@@ -9,12 +9,12 @@ public class JerseyConfig extends ResourceConfig {
...
@@ -9,12 +9,12 @@ public class JerseyConfig extends ResourceConfig {
* została wywołana metoda register dla wszystkich "resource classes", które wchodzą w skład aplikacji JAX-RS.
* została wywołana metoda register dla wszystkich "resource classes", które wchodzą w skład aplikacji JAX-RS.
* W wersji Springowej nie ma klasy typu Application.
* W wersji Springowej nie ma klasy typu Application.
*/
*/
public
JerseyConfig
()
{
public
JerseyConfig
()
{
register
(
Hello
.
class
);
register
(
Hello
.
class
);
register
(
DataCzas
.
class
);
register
(
DataCzas
.
class
);
register
(
Kalkulator
.
class
);
register
(
Kalkulator
.
class
);
// register(RProducts.class);
register
(
RProducts
.
class
);
register
(
ROrders
.
class
);
}
}
}
}
PC38-SpringJersey/src/main/java/sklep/rest/ROrders.java
0 → 100644
View file @
af868a09
package
sklep
.
rest
;
import
java.util.List
;
import
java.util.Optional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.server.ResponseStatusException
;
import
jakarta.ws.rs.Consumes
;
import
jakarta.ws.rs.GET
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
import
jakarta.ws.rs.Produces
;
import
sklep.model.Order
;
import
sklep.repository.OrderRepository
;
@Path
(
"/orders"
)
@Produces
(
"application/json"
)
@Consumes
(
"application/json"
)
public
class
ROrders
{
@Autowired
private
OrderRepository
orderRepository
;
@GET
public
List
<
Order
>
readAll
()
{
return
orderRepository
.
findAll
();
}
@Path
(
"/{id}"
)
@GET
public
Order
readOne
(
@PathParam
(
"id"
)
int
id
)
{
Optional
<
Order
>
order
=
orderRepository
.
findById
(
id
);
if
(
order
.
isPresent
())
{
return
order
.
get
();
}
else
{
throw
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
"Nie ma zamówienia o numerze "
+
id
);
}
}
}
PC38-SpringJersey/src/main/java/sklep/rest/RProducts.java
View file @
af868a09
...
@@ -5,7 +5,6 @@ import jakarta.ws.rs.core.Response;
...
@@ -5,7 +5,6 @@ import jakarta.ws.rs.core.Response;
import
jakarta.ws.rs.core.UriBuilder
;
import
jakarta.ws.rs.core.UriBuilder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
sklep.model.Product
;
import
sklep.model.Product
;
import
sklep.repository.ProductRepository
;
import
sklep.repository.ProductRepository
;
...
...
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