Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20240528-BJava
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
20240528-BJava
Commits
31b71fc5
Commit
31b71fc5
authored
Jun 27, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dodanie adnotacji Jakarta Validation
parent
01d153dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
Customer.java
PC33-SklepSpring/src/main/java/sklep/model/Customer.java
+4
-0
Product.java
PC33-SklepSpring/src/main/java/sklep/model/Product.java
+6
-0
No files found.
PC33-SklepSpring/src/main/java/sklep/model/Customer.java
View file @
31b71fc5
package
sklep
.
model
;
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Email
;
import
jakarta.validation.constraints.Pattern
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -10,6 +12,7 @@ import java.util.Set;
...
@@ -10,6 +12,7 @@ import java.util.Set;
public
class
Customer
{
public
class
Customer
{
@Id
@Id
@Column
(
name
=
"customer_email"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"customer_email"
,
nullable
=
false
,
length
=
100
)
@Email
private
String
customerEmail
;
private
String
customerEmail
;
@Column
(
name
=
"customer_name"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"customer_name"
,
nullable
=
false
,
length
=
100
)
...
@@ -22,6 +25,7 @@ public class Customer {
...
@@ -22,6 +25,7 @@ public class Customer {
private
String
address
;
private
String
address
;
@Column
(
name
=
"postal_code"
,
length
=
10
)
@Column
(
name
=
"postal_code"
,
length
=
10
)
@Pattern
(
regexp
=
"[0-9]{2}-[0-9]{3}"
)
private
String
postalCode
;
private
String
postalCode
;
@Column
(
name
=
"city"
,
length
=
100
)
@Column
(
name
=
"city"
,
length
=
100
)
...
...
PC33-SklepSpring/src/main/java/sklep/model/Product.java
View file @
31b71fc5
package
sklep
.
model
;
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.*
;
import
org.hibernate.annotations.ColumnDefault
;
import
org.hibernate.annotations.ColumnDefault
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -16,12 +17,17 @@ public class Product {
...
@@ -16,12 +17,17 @@ public class Product {
private
Integer
id
;
private
Integer
id
;
@Column
(
name
=
"product_name"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"product_name"
,
nullable
=
false
,
length
=
100
)
@NotBlank
@Size
(
min
=
1
,
max
=
20
)
private
String
productName
;
private
String
productName
;
@Column
(
name
=
"price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
@Column
(
name
=
"price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
@DecimalMin
(
"0.01"
)
@DecimalMax
(
"99999.99"
)
// ceny od 100 tys nie będą akceptowane
private
BigDecimal
price
;
private
BigDecimal
price
;
@Column
(
name
=
"vat"
,
precision
=
2
,
scale
=
2
)
@Column
(
name
=
"vat"
,
precision
=
2
,
scale
=
2
)
@Min
(
0
)
private
BigDecimal
vat
;
private
BigDecimal
vat
;
@Column
(
name
=
"description"
,
length
=
Integer
.
MAX_VALUE
)
@Column
(
name
=
"description"
,
length
=
Integer
.
MAX_VALUE
)
...
...
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