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
7f244aaa
Commit
7f244aaa
authored
Jun 01, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ROrders i RCustomers - poprawki w modelu, aby to działało
parent
aff1fefa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
12 deletions
+31
-12
build.gradle
PC38-SpringJersey/build.gradle
+2
-2
Order.java
PC38-SpringJersey/src/main/java/sklep/model/Order.java
+21
-8
OrderProduct.java
...-SpringJersey/src/main/java/sklep/model/OrderProduct.java
+2
-2
JerseyConfig.java
PC38-SpringJersey/src/main/java/sklep/rest/JerseyConfig.java
+1
-0
RCustomers.java
PC38-SpringJersey/src/main/java/sklep/rest/RCustomers.java
+3
-0
application.properties
PC38-SpringJersey/src/main/resources/application.properties
+2
-0
No files found.
PC38-SpringJersey/build.gradle
View file @
7f244aaa
...
...
@@ -18,10 +18,10 @@ repositories {
}
dependencies
{
implementation
'org.springframework.boot:spring-boot-starter-data-jpa'
implementation
'org.springframework.boot:spring-boot-starter-jersey'
implementation
'org.springframework.boot:spring-boot-starter-
security
'
implementation
'org.springframework.boot:spring-boot-starter-
data-jpa
'
implementation
'org.springframework.boot:spring-boot-starter-validation'
implementation
'org.springframework.boot:spring-boot-starter-security'
runtimeOnly
'org.postgresql:postgresql'
testImplementation
'org.springframework.boot:spring-boot-starter-test'
testImplementation
'org.springframework.security:spring-security-test'
...
...
PC38-SpringJersey/src/main/java/sklep/model/Order.java
View file @
7f244aaa
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
org.hibernate.annotations.ColumnDefault
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.util.LinkedHashSet
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
org.hibernate.annotations.ColumnDefault
;
import
jakarta.persistence.Column
;
import
jakarta.persistence.Entity
;
import
jakarta.persistence.EnumType
;
import
jakarta.persistence.Enumerated
;
import
jakarta.persistence.FetchType
;
import
jakarta.persistence.GeneratedValue
;
import
jakarta.persistence.GenerationType
;
import
jakarta.persistence.Id
;
import
jakarta.persistence.JoinColumn
;
import
jakarta.persistence.ManyToOne
;
import
jakarta.persistence.OneToMany
;
import
jakarta.persistence.Table
;
@Entity
@Table
(
name
=
"orders"
)
public
class
Order
{
...
...
@@ -27,8 +40,8 @@ public class Order {
@Column
(
name
=
"delivery_date"
)
private
LocalDate
deliveryDate
;
@OneToMany
(
mappedBy
=
"order"
)
private
Set
<
OrderProduct
>
orderProducts
=
new
LinkedHashSe
t
<>();
@OneToMany
(
mappedBy
=
"order"
,
fetch
=
FetchType
.
EAGER
)
private
List
<
OrderProduct
>
orderProducts
=
new
ArrayLis
t
<>();
public
Integer
getId
()
{
return
id
;
...
...
@@ -62,11 +75,11 @@ public class Order {
this
.
deliveryDate
=
deliveryDate
;
}
public
Se
t
<
OrderProduct
>
getOrderProducts
()
{
public
Lis
t
<
OrderProduct
>
getOrderProducts
()
{
return
orderProducts
;
}
public
void
setOrderProducts
(
Se
t
<
OrderProduct
>
orderProducts
)
{
public
void
setOrderProducts
(
Lis
t
<
OrderProduct
>
orderProducts
)
{
this
.
orderProducts
=
orderProducts
;
}
...
...
PC38-SpringJersey/src/main/java/sklep/model/OrderProduct.java
View file @
7f244aaa
...
...
@@ -16,13 +16,13 @@ public class OrderProduct {
private
OrderProductPK
id
;
@MapsId
(
"orderId"
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@ManyToOne
@JoinColumn
(
name
=
"order_id"
,
nullable
=
false
)
@JsonIgnore
private
Order
order
;
@MapsId
(
"productId"
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@ManyToOne
@JoinColumn
(
name
=
"product_id"
,
nullable
=
false
)
private
Product
product
;
...
...
PC38-SpringJersey/src/main/java/sklep/rest/JerseyConfig.java
View file @
7f244aaa
...
...
@@ -15,6 +15,7 @@ public class JerseyConfig extends ResourceConfig {
register
(
Kalkulator
.
class
);
register
(
RProducts
.
class
);
register
(
ROrders
.
class
);
register
(
RCustomers
.
class
);
}
}
PC38-SpringJersey/src/main/java/sklep/rest/RCustomers.java
View file @
7f244aaa
...
...
@@ -3,6 +3,8 @@ package sklep.rest;
import
java.util.List
;
import
java.util.Optional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
jakarta.ws.rs.Consumes
;
import
jakarta.ws.rs.DELETE
;
import
jakarta.ws.rs.GET
;
...
...
@@ -21,6 +23,7 @@ import sklep.repository.CustomerRepository;
@Produces
({
"application/xml"
,
"application/json"
,
"text/plain"
})
@Consumes
({
"application/xml"
,
"application/json"
})
public
class
RCustomers
{
@Autowired
private
CustomerRepository
customerRepository
;
@POST
...
...
PC38-SpringJersey/src/main/resources/application.properties
View file @
7f244aaa
...
...
@@ -5,3 +5,4 @@ spring.datasource.username=alx
spring.datasource.password
=
abc123
alx.photo_dir
=
/home/patryk/sklep/foto
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS
=
false
\ No newline at end of file
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