Skip to content

Commit 18be6b4

Browse files
author
Mohaned Atef
committed
added a pom.xml file for the monolithic structure, set up MVC file structure, and added basic model files using H2 database since its light and efficient
1 parent b375919 commit 18be6b4

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

Monolithic-Ecommerce/pom.xml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
This project is licensed under the MIT license. Module Monolithic-Ecommerce is part of the Java Design Patterns project.
5+
6+
The MIT License
7+
Copyright © 2014-2022 Ilkka Seppälä
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
27+
-->
28+
<project xmlns="http://maven.apache.org/POM/4.0.0"
29+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
31+
<modelVersion>4.0.0</modelVersion>
32+
33+
<parent>
34+
<groupId>com.iluwatar</groupId>
35+
<artifactId>java-design-patterns</artifactId>
36+
<version>1.26.0-SNAPSHOT</version>
37+
</parent>
38+
39+
<artifactId>Monolithic-Ecommerce</artifactId>
40+
41+
42+
<dependencies>
43+
<!-- Spring Boot Starter Web -->
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-web</artifactId>
47+
</dependency>
48+
49+
<!-- Spring Boot Starter Data JPA -->
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-data-jpa</artifactId>
53+
</dependency>
54+
55+
<!-- H2 Database -->
56+
<dependency>
57+
<groupId>com.h2database</groupId>
58+
<artifactId>h2</artifactId>
59+
<scope>runtime</scope>
60+
</dependency>
61+
62+
<!-- Jakarta Persistence API -->
63+
<dependency>
64+
<groupId>jakarta.persistence</groupId>
65+
<artifactId>jakarta.persistence-api</artifactId>
66+
<version>3.1.0</version>
67+
</dependency>
68+
69+
<!-- JUnit for Testing -->
70+
<dependency>
71+
<groupId>org.junit.jupiter</groupId>
72+
<artifactId>junit-jupiter-engine</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
76+
<!-- Mockito for Unit Testing -->
77+
<dependency>
78+
<groupId>org.mockito</groupId>
79+
<artifactId>mockito-core</artifactId>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
</project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.iluwatar.monolithic.model;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.ManyToOne;
8+
import lombok.Data;
9+
10+
/**
11+
* Represents a Database in which Orders are stored.
12+
*/
13+
@Entity
14+
@Data
15+
public class Orders {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.IDENTITY) // Auto-increment ID
18+
private Long id;
19+
20+
@ManyToOne // Relationship with User
21+
private User user;
22+
23+
@ManyToOne // Relationship with Product
24+
private Products product;
25+
26+
private Integer quantity;
27+
28+
private Double totalPrice;
29+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.iluwatar.monolithic.model;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
import lombok.Data;
8+
9+
/**
10+
* Represents a databse of products .
11+
*/
12+
@Entity
13+
@Data
14+
public class Products {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY) // Generated Auto-increment ID
17+
private Long id;
18+
19+
private String name;
20+
21+
private String description;
22+
23+
private Double price;
24+
25+
private Integer stock;
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.iluwatar.monolithic.model;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Id;
8+
import lombok.Data;
9+
10+
/**
11+
* Represents a User entity for the database to interact with the rest of the project.
12+
*/
13+
@Entity
14+
@Data
15+
public class User {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.IDENTITY) // Generated Auto-increment ID
18+
private Long id;
19+
20+
private String name;
21+
22+
@Column(unique = true) // Ensures unique emails
23+
private String email;
24+
25+
private String password;
26+
}

0 commit comments

Comments
 (0)