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
73a7a8cc
Commit
73a7a8cc
authored
Nov 10, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skopiowanie klas modelu sklep
parent
61049f7c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
453 additions
and
1 deletions
+453
-1
Customer.java
PC40-RestRepo/src/main/java/sklep/model/Customer.java
+114
-0
Order.java
PC40-RestRepo/src/main/java/sklep/model/Order.java
+109
-0
OrderProduct.java
PC40-RestRepo/src/main/java/sklep/model/OrderProduct.java
+92
-0
OrderProductPK.java
PC40-RestRepo/src/main/java/sklep/model/OrderProductPK.java
+58
-0
Product.java
PC40-RestRepo/src/main/java/sklep/model/Product.java
+77
-0
application.properties
PC40-RestRepo/src/main/resources/application.properties
+3
-1
No files found.
PC40-RestRepo/src/main/java/sklep/model/Customer.java
0 → 100644
View file @
73a7a8cc
package
sklep
.
model
;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
java.util.List
;
/**
* The persistent class for the customers database table.
*
*/
@Entity
@Table
(
name
=
"customers"
)
@NamedQuery
(
name
=
"Customer.findAll"
,
query
=
"SELECT c FROM Customer c"
)
public
class
Customer
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@Column
(
name
=
"customer_email"
,
updatable
=
false
)
private
String
customerEmail
;
private
String
address
;
private
String
city
;
@Column
(
name
=
"customer_name"
)
private
String
customerName
;
@Column
(
name
=
"phone_number"
)
private
String
phoneNumber
;
@Column
(
name
=
"postal_code"
)
private
String
postalCode
;
//bi-directional many-to-one association to Order
@OneToMany
(
mappedBy
=
"customer"
)
private
List
<
Order
>
orders
;
public
Customer
()
{
}
public
String
getCustomerEmail
()
{
return
this
.
customerEmail
;
}
public
void
setCustomerEmail
(
String
customerEmail
)
{
this
.
customerEmail
=
customerEmail
;
}
public
String
getAddress
()
{
return
this
.
address
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
String
getCity
()
{
return
this
.
city
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
String
getCustomerName
()
{
return
this
.
customerName
;
}
public
void
setCustomerName
(
String
customerName
)
{
this
.
customerName
=
customerName
;
}
public
String
getPhoneNumber
()
{
return
this
.
phoneNumber
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
;
}
public
String
getPostalCode
()
{
return
this
.
postalCode
;
}
public
void
setPostalCode
(
String
postalCode
)
{
this
.
postalCode
=
postalCode
;
}
public
List
<
Order
>
getOrders
()
{
return
this
.
orders
;
}
public
void
setOrders
(
List
<
Order
>
orders
)
{
this
.
orders
=
orders
;
}
public
Order
addOrder
(
Order
order
)
{
getOrders
().
add
(
order
);
order
.
setCustomer
(
this
);
return
order
;
}
public
Order
removeOrder
(
Order
order
)
{
getOrders
().
remove
(
order
);
order
.
setCustomer
(
null
);
return
order
;
}
}
\ No newline at end of file
PC40-RestRepo/src/main/java/sklep/model/Order.java
0 → 100644
View file @
73a7a8cc
package
sklep
.
model
;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
java.util.Date
;
import
java.sql.Timestamp
;
import
java.util.List
;
/**
* The persistent class for the orders database table.
*
*/
@Entity
@Table
(
name
=
"orders"
)
@NamedQuery
(
name
=
"Order.findAll"
,
query
=
"SELECT o FROM Order o"
)
public
class
Order
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"order_id"
,
insertable
=
false
,
updatable
=
false
)
private
Integer
orderId
;
@Temporal
(
TemporalType
.
DATE
)
@Column
(
name
=
"delivery_date"
)
private
Date
deliveryDate
;
@Column
(
name
=
"order_date"
)
private
Timestamp
orderDate
;
private
String
status
;
//bi-directional many-to-one association to OrderProduct
@OneToMany
(
mappedBy
=
"order"
)
private
List
<
OrderProduct
>
orderProducts
;
//bi-directional many-to-one association to Customer
@ManyToOne
@JoinColumn
(
name
=
"customer_email"
)
private
Customer
customer
;
public
Order
()
{
}
public
Integer
getOrderId
()
{
return
this
.
orderId
;
}
public
void
setOrderId
(
Integer
orderId
)
{
this
.
orderId
=
orderId
;
}
public
Date
getDeliveryDate
()
{
return
this
.
deliveryDate
;
}
public
void
setDeliveryDate
(
Date
deliveryDate
)
{
this
.
deliveryDate
=
deliveryDate
;
}
public
Timestamp
getOrderDate
()
{
return
this
.
orderDate
;
}
public
void
setOrderDate
(
Timestamp
orderDate
)
{
this
.
orderDate
=
orderDate
;
}
public
String
getStatus
()
{
return
this
.
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
List
<
OrderProduct
>
getOrderProducts
()
{
return
this
.
orderProducts
;
}
public
void
setOrderProducts
(
List
<
OrderProduct
>
orderProducts
)
{
this
.
orderProducts
=
orderProducts
;
}
public
OrderProduct
addOrderProduct
(
OrderProduct
orderProduct
)
{
getOrderProducts
().
add
(
orderProduct
);
orderProduct
.
setOrder
(
this
);
return
orderProduct
;
}
public
OrderProduct
removeOrderProduct
(
OrderProduct
orderProduct
)
{
getOrderProducts
().
remove
(
orderProduct
);
orderProduct
.
setOrder
(
null
);
return
orderProduct
;
}
public
Customer
getCustomer
()
{
return
this
.
customer
;
}
public
void
setCustomer
(
Customer
customer
)
{
this
.
customer
=
customer
;
}
}
\ No newline at end of file
PC40-RestRepo/src/main/java/sklep/model/OrderProduct.java
0 → 100644
View file @
73a7a8cc
package
sklep
.
model
;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
java.math.BigDecimal
;
/**
* The persistent class for the order_products database table.
*
*/
@Entity
@Table
(
name
=
"order_products"
)
@NamedQuery
(
name
=
"OrderProduct.findAll"
,
query
=
"SELECT o FROM OrderProduct o"
)
public
class
OrderProduct
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@EmbeddedId
private
OrderProductPK
id
;
@Column
(
name
=
"actual_price"
)
private
BigDecimal
actualPrice
;
@Column
(
name
=
"actual_vat"
)
private
BigDecimal
actualVat
;
private
Integer
quantity
;
//bi-directional many-to-one association to Order
@ManyToOne
@JoinColumn
(
name
=
"order_id"
,
insertable
=
false
,
updatable
=
false
)
private
Order
order
;
//uni-directional many-to-one association to Product
@ManyToOne
@JoinColumn
(
name
=
"product_id"
,
insertable
=
false
,
updatable
=
false
)
private
Product
product
;
public
OrderProduct
()
{
}
public
OrderProductPK
getId
()
{
return
this
.
id
;
}
public
void
setId
(
OrderProductPK
id
)
{
this
.
id
=
id
;
}
public
BigDecimal
getActualPrice
()
{
return
this
.
actualPrice
;
}
public
void
setActualPrice
(
BigDecimal
actualPrice
)
{
this
.
actualPrice
=
actualPrice
;
}
public
BigDecimal
getActualVat
()
{
return
this
.
actualVat
;
}
public
void
setActualVat
(
BigDecimal
actualVat
)
{
this
.
actualVat
=
actualVat
;
}
public
Integer
getQuantity
()
{
return
this
.
quantity
;
}
public
void
setQuantity
(
Integer
quantity
)
{
this
.
quantity
=
quantity
;
}
public
Order
getOrder
()
{
return
this
.
order
;
}
public
void
setOrder
(
Order
order
)
{
this
.
order
=
order
;
}
public
Product
getProduct
()
{
return
this
.
product
;
}
public
void
setProduct
(
Product
product
)
{
this
.
product
=
product
;
}
}
\ No newline at end of file
PC40-RestRepo/src/main/java/sklep/model/OrderProductPK.java
0 → 100644
View file @
73a7a8cc
package
sklep
.
model
;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
/**
* The primary key class for the order_products database table.
*
*/
@Embeddable
public
class
OrderProductPK
implements
Serializable
{
//default serial version id, required for serializable classes.
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"order_id"
,
insertable
=
false
,
updatable
=
false
)
private
Integer
orderId
;
@Column
(
name
=
"product_id"
,
insertable
=
false
,
updatable
=
false
)
private
Integer
productId
;
public
OrderProductPK
()
{
}
public
Integer
getOrderId
()
{
return
this
.
orderId
;
}
public
void
setOrderId
(
Integer
orderId
)
{
this
.
orderId
=
orderId
;
}
public
Integer
getProductId
()
{
return
this
.
productId
;
}
public
void
setProductId
(
Integer
productId
)
{
this
.
productId
=
productId
;
}
public
boolean
equals
(
Object
other
)
{
if
(
this
==
other
)
{
return
true
;
}
if
(!(
other
instanceof
OrderProductPK
))
{
return
false
;
}
OrderProductPK
castOther
=
(
OrderProductPK
)
other
;
return
this
.
orderId
.
equals
(
castOther
.
orderId
)
&&
this
.
productId
.
equals
(
castOther
.
productId
);
}
public
int
hashCode
()
{
final
int
prime
=
31
;
int
hash
=
17
;
hash
=
hash
*
prime
+
this
.
orderId
.
hashCode
();
hash
=
hash
*
prime
+
this
.
productId
.
hashCode
();
return
hash
;
}
}
\ No newline at end of file
PC40-RestRepo/src/main/java/sklep/model/Product.java
0 → 100644
View file @
73a7a8cc
package
sklep
.
model
;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
java.math.BigDecimal
;
/**
* The persistent class for the products database table.
*
*/
@Entity
@Table
(
name
=
"products"
)
@NamedQuery
(
name
=
"Product.findAll"
,
query
=
"SELECT p FROM Product p"
)
public
class
Product
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"product_id"
,
insertable
=
false
,
updatable
=
false
)
private
Integer
productId
;
private
String
description
;
private
BigDecimal
price
;
@Column
(
name
=
"product_name"
)
private
String
productName
;
private
BigDecimal
vat
;
public
Product
()
{
}
public
Integer
getProductId
()
{
return
this
.
productId
;
}
public
void
setProductId
(
Integer
productId
)
{
this
.
productId
=
productId
;
}
public
String
getDescription
()
{
return
this
.
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
BigDecimal
getPrice
()
{
return
this
.
price
;
}
public
void
setPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
}
public
String
getProductName
()
{
return
this
.
productName
;
}
public
void
setProductName
(
String
productName
)
{
this
.
productName
=
productName
;
}
public
BigDecimal
getVat
()
{
return
this
.
vat
;
}
public
void
setVat
(
BigDecimal
vat
)
{
this
.
vat
=
vat
;
}
}
\ No newline at end of file
PC40-RestRepo/src/main/resources/application.properties
View file @
73a7a8cc
spring.datasource.url
=
jdbc:postgresql://localhost:5432/sklep
spring.datasource.username
=
kurs
spring.datasource.password
=
abc123
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