Skip to content

Commit fc07198

Browse files
committed
Backend Shopping Mall
1 parent 7abe5de commit fc07198

File tree

119 files changed

+204
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+204
-17
lines changed

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/pom.xml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.4.0</version>
8+
<version>2.3.5.RELEASE</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.urunov</groupId>
@@ -91,7 +91,37 @@
9191
<groupId>org.thymeleaf.extras</groupId>
9292
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
9393
</dependency>
94+
<dependency>
95+
<groupId>com.fasterxml.jackson.core</groupId>
96+
<artifactId>jackson-annotations</artifactId>
97+
<version>2.11.2</version>
98+
</dependency>
99+
100+
<!--flywaydb-->
101+
<!-- <dependency>-->
102+
<!-- <groupId>org.flywaydb</groupId>-->
103+
<!-- <artifactId>flyway-core</artifactId>-->
104+
<!-- </dependency>-->
94105

106+
<!-- JAXB -->
107+
<dependency>
108+
<groupId>javax.xml.bind</groupId>
109+
<artifactId>jaxb-api</artifactId>
110+
<version>2.3.0</version>
111+
</dependency>
112+
<dependency>
113+
<groupId>com.sun.xml.bind</groupId>
114+
<artifactId>jaxb-core</artifactId>
115+
<version>2.3.0</version>
116+
</dependency>
117+
118+
119+
<!-- JSON -->
120+
<dependency>
121+
<groupId>io.jsonwebtoken</groupId>
122+
<artifactId>jjwt</artifactId>
123+
<version>0.9.1</version>
124+
</dependency>
95125

96126
<!-- -->
97127
</dependencies>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,75 @@
1-
package com.urunov.domain;
2-
3-
/**
4-
* User: hamdamboy
5-
* Project: Ecommerce
6-
* Github: @urunov
7-
*/
8-
public class Order {
9-
}
1+
//package com.urunov.domain;
2+
//
3+
//import lombok.AllArgsConstructor;
4+
//import lombok.Getter;
5+
//import lombok.NoArgsConstructor;
6+
//import lombok.Setter;
7+
//
8+
//import javax.persistence.*;
9+
//import javax.validation.constraints.Email;
10+
//import javax.validation.constraints.NotBlank;
11+
//import java.time.LocalDate;
12+
//import java.util.List;
13+
//
14+
///**
15+
// * User: hamdamboy
16+
// * Project: Ecommerce
17+
// * Github: @urunov
18+
// */
19+
//@Getter
20+
//@Setter
21+
//@AllArgsConstructor
22+
//@NoArgsConstructor
23+
//@Entity
24+
//public class Order {
25+
//
26+
// @Id
27+
// @GeneratedValue(strategy = GenerationType.IDENTITY)
28+
// private Long id;
29+
//
30+
//
31+
// private Double totalPrice;
32+
//
33+
// private LocalDate date;
34+
//
35+
// private String lastName;
36+
//
37+
// private String firstName;
38+
//
39+
// private String city;
40+
// /**
41+
// * Delivery address of the order.
42+
// * The @NotBlank annotation says the field should not be empty.
43+
// */
44+
// @NotBlank(message = "Пожалуйста заполните поле")
45+
// private String address;
46+
//
47+
// /**
48+
// * Customer email.
49+
// * The @Email annotation says the string has to be a well-formed email address.
50+
// * The @NotBlank annotation says the field should not be empty.
51+
// */
52+
//
53+
// @Email(message = "Некорректный email")
54+
// @NotBlank(message = "Email не может быть пустым")
55+
// private String email;
56+
//
57+
// @NotBlank(message = "Номер телефона не может быть пустым")
58+
// private String phoneNumber;
59+
//
60+
// private Integer postIndex;
61+
//
62+
//// @OrderColumn
63+
//// @ManyToMany(fetch = FetchType.EAGER)
64+
//// private List<Perfume> perfumeList;
65+
////
66+
//// /**
67+
//// * The customer who made the order.
68+
//// * Between the {@link Order} and {@link User} objects, there is a many-to-one relationship, that is,
69+
//// * each record in one table is directly related to a single record in another table.
70+
//// */
71+
//// @ManyToOne(cascade = CascadeType.ALL)
72+
//// private User user;
73+
//
74+
//
75+
//}

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/src/main/java/com/urunov/domain/Perfume.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.urunov.domain;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
34
import lombok.*;
45
import org.hibernate.validator.constraints.Length;
56

@@ -8,6 +9,7 @@
89
import javax.persistence.GenerationType;
910
import javax.persistence.Id;
1011
import javax.validation.constraints.NotBlank;
12+
import javax.validation.constraints.NotNull;
1113

1214
/**
1315
* User: hamdamboy
@@ -21,14 +23,59 @@
2123
@NoArgsConstructor
2224
@AllArgsConstructor
2325
@EqualsAndHashCode(of = {"id", "perfumer", "perfumeTitle", "perfumeGender", "price"})
26+
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
2427
@Entity
2528
public class Perfume {
2629

2730
@Id
2831
@GeneratedValue(strategy = GenerationType.AUTO)
2932
private Long id;
3033

31-
@NotBlank(message = "Please, not empty title/Пожалуйста заполните поле ")
34+
@NotBlank(message = "Please, not empty field/Пожалуйста заполните поле ")
3235
@Length(max = 255)
3336
private String perfumeTitle;
37+
38+
@NotBlank(message = "Пожалуйста заполните поле")
39+
@Length(max = 255)
40+
private String perfumer;
41+
42+
@NotNull(message = "Please,fill in field/ Пожалуйста заполните поле")
43+
private Integer year;
44+
45+
@NotNull(message = "Please, fill in field/ Пожалуйста заполните поле")
46+
private String country;
47+
48+
@NotBlank(message = "Please, fill in field / Пожалуйста заполните поле")
49+
private String perfumeGender;
50+
51+
@NotBlank(message = "Please, fill in field, Пожалуйста заполните поле")
52+
@Length(max = 255)
53+
private String fragranceTopNotes;
54+
55+
@NotBlank(message = "Please, fill in field/ Пожалуйста заполните поле")
56+
private String fragranceMiddleNotes;
57+
58+
@NotBlank(message = "Please, fill in field/ Пожалуйста заполните поле")
59+
@Length(max = 255)
60+
private String fragranceBaseNotes;
61+
62+
63+
private String description;
64+
65+
private String fileName;
66+
67+
@NotBlank(message = "Please, fill in field/ Пожалуйста заполните поле")
68+
private Integer price;
69+
70+
@NotBlank(message = "Please, fill in field/ Пожалуйста заполните поле")
71+
@Length(max = 255)
72+
private String value;
73+
74+
@NotBlank(message = "Please, fill in field/ Пожалуйста заполните поле")
75+
@Length(max = 255)
76+
private String type;
77+
78+
// @ManyToMany(mappedBy = "perfumes")
79+
// private List<User> users;
80+
3481
}

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/src/main/java/com/urunov/domain/User.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.security.core.userdetails.UserDetails;
66

77
import javax.persistence.*;
8+
import java.util.ArrayList;
89
import java.util.Collection;
910
import java.util.List;
1011
import java.util.Set;
@@ -41,8 +42,20 @@ public class User implements UserDetails {
4142
@Enumerated(EnumType.ORDINAL)
4243
private Set<Role> roles;
4344

44-
@ManyToMany(fetch = FetchType.EAGER)
45-
private List<Perfume> perfumeList;
45+
46+
47+
// @ManyToMany(cascade = CascadeType.ALL)
48+
// @JoinTable(name="perfumes_user", joinColumns = @JoinColumn(name = "user_id"),
49+
// inverseJoinColumns = @JoinColumn(name = "perfumes_id"))
50+
// private List<Perfume> perfumes = new ArrayList<>();
51+
//
52+
//
53+
// @OneToMany(mappedBy = "user")
54+
// private List<Order> orders;
55+
56+
public boolean isAdmin(){
57+
return roles.contains(Role.ADMIN);
58+
}
4659

4760
@Override
4861
public Collection<? extends GrantedAuthority> getAuthorities() {
@@ -61,21 +74,21 @@ public String getUsername() {
6174

6275
@Override
6376
public boolean isAccountNonExpired() {
64-
return false;
77+
return true;
6578
}
6679

6780
@Override
6881
public boolean isAccountNonLocked() {
69-
return false;
82+
return true;
7083
}
7184

7285
@Override
7386
public boolean isCredentialsNonExpired() {
74-
return false;
87+
return true;
7588
}
7689

7790
@Override
7891
public boolean isEnabled() {
79-
return false;
92+
return isActive();
8093
}
8194
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//package com.urunov.repository;
2+
//
3+
//import com.urunov.domain.Order;
4+
//import org.springframework.data.jpa.repository.JpaRepository;
5+
//
6+
//
7+
///**
8+
// * User: hamdamboy
9+
// * Project: Ecommerce
10+
// * Github: @urunov
11+
// */
12+
//public interface OrderRepository extends JpaRepository<Order, Long> {
13+
//}
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11

2+
#spring.flyway.locations=classpath:db/migration
3+
4+
#datasource
5+
# //------------- MYSQL DB --------------------
6+
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
7+
spring.datasource.url = jdbc:mysql://localhost:3306/ecommerce?useSSL=false&serverTimezone=UTC&AllowPublicKeyRetrieval=True
8+
spring.datasource.username=root
9+
spring.datasource.password=posilka2020
10+
11+
#The SQL dialect makes Hibernate generate better SQL for the chosen database
12+
13+
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
14+
spring.jpa.hibernate.ddl-auto=update
15+
16+
17+
18+
19+

0 commit comments

Comments
 (0)