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
797684d6
Commit
797684d6
authored
Nov 07, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adnotacje Validation
parent
9f5074b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
Customer.java
PC30-SklepSpring/src/main/java/sklep/model/Customer.java
+4
-0
OrderProduct.java
PC30-SklepSpring/src/main/java/sklep/model/OrderProduct.java
+2
-0
Product.java
PC30-SklepSpring/src/main/java/sklep/model/Product.java
+13
-0
No files found.
PC30-SklepSpring/src/main/java/sklep/model/Customer.java
View file @
797684d6
...
...
@@ -2,6 +2,8 @@ package sklep.model;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Email
;
import
jakarta.validation.constraints.Pattern
;
import
java.util.List
;
...
...
@@ -18,6 +20,7 @@ public class Customer implements Serializable {
@Id
@Column
(
name
=
"customer_email"
,
updatable
=
false
)
@Email
private
String
customerEmail
;
private
String
address
;
...
...
@@ -31,6 +34,7 @@ public class Customer implements Serializable {
private
String
phoneNumber
;
@Column
(
name
=
"postal_code"
)
@Pattern
(
regexp
=
"[0-9]{2}-[0-9]{3}"
)
private
String
postalCode
;
//bi-directional many-to-one association to Order
...
...
PC30-SklepSpring/src/main/java/sklep/model/OrderProduct.java
View file @
797684d6
...
...
@@ -2,6 +2,7 @@ package sklep.model;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Min
;
import
java.math.BigDecimal
;
...
...
@@ -25,6 +26,7 @@ public class OrderProduct implements Serializable {
@Column
(
name
=
"actual_vat"
)
private
BigDecimal
actualVat
;
@Min
(
1
)
private
Integer
quantity
;
//bi-directional many-to-one association to Order
...
...
PC30-SklepSpring/src/main/java/sklep/model/Product.java
View file @
797684d6
...
...
@@ -2,9 +2,15 @@ package sklep.model;
import
java.io.Serializable
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.DecimalMax
;
import
jakarta.validation.constraints.DecimalMin
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
org.hibernate.validator.constraints.Length
;
/**
* The persistent class for the products database table.
...
...
@@ -23,11 +29,18 @@ public class Product implements Serializable {
private
String
description
;
@NotNull
@DecimalMin
(
"0.01"
)
@DecimalMax
(
"9999.99"
)
// celowo tak obniżamy, aby sprawdzić błędy
private
BigDecimal
price
;
@Column
(
name
=
"product_name"
)
@NotBlank
@Length
(
max
=
20
)
private
String
productName
;
@DecimalMin
(
"0.00"
)
@DecimalMax
(
"0.99"
)
private
BigDecimal
vat
;
public
Product
()
{
...
...
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