Skip to content

Commit 1c98735

Browse files
authored
Merge pull request #21 from Raouf25/feature/use-lombok-library
chore() use-lombok-library
2 parents 03e73e7 + 261173b commit 1c98735

File tree

97 files changed

+1659
-2499
lines changed

Some content is hidden

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

97 files changed

+1659
-2499
lines changed

.github/workflows/greetings.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
greeting:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/first-interaction@v1
10-
with:
11-
repo-token: ${{ secrets.GITHUB_TOKEN }}
12-
issue-message: 'Welcome to Spring-Boot-Blog-REST-API community! Thanks so much for creating your first issue :)'
13-
pr-message: 'Thanks so much for creating your first PR, the Spring-Boot-Blog-REST-API community thanks you :)'
9+
- uses: actions/first-interaction@v1
10+
with:
11+
repo-token: ${{ secrets.GITHUB_TOKEN }}
12+
issue-message: 'Welcome to Spring-Boot-Blog-REST-API community! Thanks so much for creating your first issue :)'
13+
pr-message: 'Thanks so much for creating your first PR, the Spring-Boot-Blog-REST-API community thanks you :)'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM openjdk:11-jre-slim
1+
FROM adoptopenjdk/openjdk11:alpine-jre
22
VOLUME /tmp
33
ARG JAR_FILE=target/*.jar
44
COPY ${JAR_FILE} app.jar

data/blogapi.sql

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
USE blogapi;
2+
3+
UNLOCK TABLES;
4+
5+
DROP TABLE IF EXISTS `post_tag`;
6+
DROP TABLE IF EXISTS `tags`;
7+
DROP TABLE IF EXISTS `user_role`;
8+
DROP TABLE IF EXISTS `roles`;
9+
DROP TABLE IF EXISTS `comments`;
10+
DROP TABLE IF EXISTS `posts`;
11+
DROP TABLE IF EXISTS `photos`;
12+
DROP TABLE IF EXISTS `albums`;
13+
DROP TABLE IF EXISTS `todos`;
14+
DROP TABLE IF EXISTS `users`;
15+
DROP TABLE IF EXISTS `address`;
16+
DROP TABLE IF EXISTS `company`;
17+
DROP TABLE IF EXISTS `geo`;
18+
19+
CREATE TABLE `tags` (
20+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
21+
`name` varchar(255) NOT NULL,
22+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
23+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
24+
`created_by` bigint(19) unsigned NOT NULL,
25+
`updated_by` bigint(19) unsigned NOT NULL,
26+
PRIMARY KEY (`id`)
27+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
28+
29+
CREATE TABLE `geo` (
30+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
31+
`lat` varchar(255),
32+
`lng` varchar(255),
33+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
34+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
35+
`created_by` bigint(19) unsigned DEFAULT NULL,
36+
`updated_by` bigint(19) unsigned DEFAULT NULL,
37+
PRIMARY KEY (`id`)
38+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
39+
40+
CREATE TABLE `company` (
41+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
42+
`name` varchar(255),
43+
`catch_phrase` varchar(255),
44+
`bs` varchar(255),
45+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
46+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
47+
`created_by` bigint(19) unsigned DEFAULT NULL,
48+
`updated_by` bigint(19) unsigned DEFAULT NULL,
49+
PRIMARY KEY (`id`)
50+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
51+
52+
CREATE TABLE `address` (
53+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
54+
`street` varchar(255),
55+
`suite` varchar(255),
56+
`city` varchar(255),
57+
`zipcode` varchar(255),
58+
`geo_id` bigint(19) unsigned DEFAULT NULL,
59+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
60+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
61+
`created_by` bigint(19) unsigned DEFAULT NULL,
62+
`updated_by` bigint(19) unsigned DEFAULT NULL,
63+
PRIMARY KEY (`id`),
64+
KEY `fk_geo` (`geo_id`),
65+
CONSTRAINT `fk_geo` FOREIGN KEY (`geo_id`) REFERENCES `geo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
66+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
67+
68+
CREATE TABLE `users` (
69+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
70+
`first_name` varchar(255) NOT NULL,
71+
`last_name` varchar(255) NOT NULL,
72+
`username` varchar(255) NOT NULL,
73+
`password` varchar(255) NOT NULL,
74+
`email` varchar(255) NOT NULL,
75+
`address_id` bigint(19) unsigned DEFAULT NULL,
76+
`phone` varchar(255),
77+
`website` varchar(255),
78+
`company_id` bigint(19) unsigned DEFAULT NULL,
79+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
80+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
81+
PRIMARY KEY (`id`),
82+
KEY `fk_address` (`address_id`),
83+
KEY `fk_company` (`company_id`),
84+
CONSTRAINT `fk_address` FOREIGN KEY (`address_id`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
85+
CONSTRAINT `fk_company` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
86+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
87+
88+
CREATE TABLE `todos` (
89+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
90+
`title` varchar(255) NOT NULL,
91+
`completed` boolean default false,
92+
`user_id` bigint(19) unsigned DEFAULT NULL,
93+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
94+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
95+
`created_by` bigint(19) unsigned DEFAULT NULL,
96+
`updated_by` bigint(19) unsigned DEFAULT NULL,
97+
PRIMARY KEY (`id`),
98+
KEY `fk_user_todos` (`user_id`),
99+
CONSTRAINT `fk_user_todos` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
100+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
101+
102+
CREATE TABLE `albums` (
103+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
104+
`title` varchar(255) NOT NULL,
105+
`user_id` bigint(19) unsigned DEFAULT NULL,
106+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
107+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
108+
`created_by` bigint(19) unsigned DEFAULT NULL,
109+
`updated_by` bigint(19) unsigned DEFAULT NULL,
110+
PRIMARY KEY (`id`),
111+
KEY `fk_user_album` (`user_id`),
112+
CONSTRAINT `fk_user_album` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
113+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
114+
115+
CREATE TABLE `photos` (
116+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
117+
`title` varchar(255) NOT NULL,
118+
`url` varchar(255) NOT NULL,
119+
`thumbnail_url` varchar(255) NOT NULL,
120+
`album_id` bigint(19) unsigned DEFAULT NULL,
121+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
122+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
123+
`created_by` bigint(19) unsigned DEFAULT NULL,
124+
`updated_by` bigint(19) unsigned DEFAULT NULL,
125+
PRIMARY KEY (`id`),
126+
KEY `fk_album` (`album_id`),
127+
CONSTRAINT `fk_album` FOREIGN KEY (`album_id`) REFERENCES `albums` (`id`)
128+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
129+
130+
CREATE TABLE `posts` (
131+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
132+
`title` varchar(255) NOT NULL,
133+
`body` text NOT NULL,
134+
`user_id` bigint(19) unsigned DEFAULT NULL,
135+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
136+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
137+
`created_by` bigint(19) unsigned DEFAULT NULL,
138+
`updated_by` bigint(19) unsigned DEFAULT NULL,
139+
PRIMARY KEY (`id`),
140+
KEY `fk_user_post` (`user_id`),
141+
CONSTRAINT `fk_user_post` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
142+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
143+
144+
CREATE TABLE `post_tag` (
145+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
146+
`post_id` bigint(19) unsigned NOT NULL,
147+
`tag_id` bigint(19) unsigned NOT NULL,
148+
PRIMARY KEY (`id`),
149+
KEY `fk_posttag_post_id` (`post_id`),
150+
KEY `fk_posttag_tag_id` (`tag_id`),
151+
CONSTRAINT `fk_posttag_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
152+
CONSTRAINT `fk_posttag_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`)
153+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
154+
155+
CREATE TABLE `comments` (
156+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
157+
`name` varchar(255) NOT NULL,
158+
`email` varchar(255) NOT NULL,
159+
`body` text NOT NULL,
160+
`post_id` bigint(19) unsigned DEFAULT NULL,
161+
`user_id` bigint(19) unsigned DEFAULT NULL,
162+
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
163+
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
164+
`created_by` bigint(19) unsigned NOT NULL,
165+
`updated_by` bigint(19) unsigned NOT NULL,
166+
PRIMARY KEY (`id`),
167+
KEY `fk_comment_post` (`post_id`),
168+
KEY `fk_comment_user` (`user_id`),
169+
CONSTRAINT `fk_comment_post` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
170+
CONSTRAINT `fk_comment_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
171+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
172+
173+
CREATE TABLE `roles` (
174+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
175+
`name` varchar(255) NOT NULL,
176+
PRIMARY KEY (`id`)
177+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
178+
179+
CREATE TABLE `user_role` (
180+
`id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
181+
`user_id` bigint(19) unsigned NOT NULL,
182+
`role_id` bigint(19) unsigned NOT NULL,
183+
PRIMARY KEY (`id`),
184+
KEY `fk_security_user_id` (`user_id`),
185+
KEY `fk_security_role_id` (`role_id`),
186+
CONSTRAINT `fk_security_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
187+
CONSTRAINT `fk_security_role_id` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`)
188+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
189+
190+
LOCK TABLES `roles` WRITE;
191+
INSERT INTO `roles` VALUES (1,'ROLE_ADMIN'),(2,'ROLE_USER');
192+
UNLOCK TABLES;

docker-compose.yml

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
version: '3'
1+
version: '3.8'
22
services:
3-
mysql:
4-
image: mysql
5-
restart: always
6-
environment:
7-
MYSQL_DATABASE: 'blogapi'
8-
MYSQL_USER: 'root'
9-
MYSQL_PASSWORD: 'root'
10-
MYSQL_ROOT_PASSWORD: 'root'
11-
ports:
12-
- '3306'
13-
networks:
14-
- production-network
15-
application:
16-
build:
17-
dockerfile: ./Dockerfile
18-
context: .
19-
image: michel-eckhardt/spring-boot-blog
20-
container_name: spring-boot-blog
21-
ports:
22-
- "8080:8080"
23-
networks:
24-
- production-network
25-
depends_on:
26-
- "mysql"
27-
networks:
28-
production-network:
29-
driver: bridge
3+
db:
4+
image: mysql
5+
container_name: blogapi-db
6+
restart: always
7+
environment:
8+
MYSQL_DATABASE: 'blogapi'
9+
MYSQL_PASSWORD: 'root'
10+
MYSQL_ROOT_PASSWORD: 'root'
11+
ports:
12+
- '3306:3306'
13+
networks:
14+
- blogapi-network
15+
healthcheck:
16+
test: "/usr/bin/mysql --user=root --password=root --execute \"SHOW DATABASES;\""
17+
interval: 2s
18+
timeout: 20s
19+
retries: 10
20+
volumes:
21+
- ./data:/docker-entrypoint-initdb.d
22+
application:
23+
container_name: blogapi-application
24+
build:
25+
context: ./
26+
dockerfile: Dockerfile
27+
ports:
28+
- "8080:8080"
29+
networks:
30+
- blogapi-network
31+
depends_on:
32+
- "db"
33+
networks:
34+
blogapi-network:
35+
name: blogapi-network
36+
driver: bridge

pom.xml

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
7-
<groupId>com.sopromadze</groupId>
8-
<artifactId>blogapi</artifactId>
9-
<version>0.0.1-SNAPSHOT</version>
10-
<packaging>jar</packaging>
11-
12-
<name>BlogAPI</name>
13-
<description>Blog API project with Spring Boot</description>
14-
15-
<parent>
16-
<groupId>org.springframework.boot</groupId>
17-
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>2.1.8.RELEASE</version>
19-
<relativePath /> <!-- lookup parent from repository -->
20-
</parent>
21-
22-
<properties>
23-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
25-
<java.version>1.8</java.version>
26-
</properties>
27-
28-
<dependencies>
29-
<dependency>
30-
<groupId>org.springframework.boot</groupId>
31-
<artifactId>spring-boot-starter</artifactId>
32-
</dependency>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.sopromadze</groupId>
8+
<artifactId>blogapi</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>BlogAPI</name>
13+
<description>Blog API project with Spring Boot</description>
14+
15+
<parent>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-parent</artifactId>
18+
<version>2.1.8.RELEASE</version>
19+
<relativePath/> <!-- lookup parent from repository -->
20+
</parent>
21+
22+
<properties>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
25+
<java.version>1.8</java.version>
26+
</properties>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter</artifactId>
32+
</dependency>
3333

34-
<dependency>
35-
<groupId>mysql</groupId>
36-
<artifactId>mysql-connector-java</artifactId>
37-
<scope>runtime</scope>
38-
</dependency>
34+
<dependency>
35+
<groupId>mysql</groupId>
36+
<artifactId>mysql-connector-java</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
3939

4040
<dependency>
4141
<groupId>org.projectlombok</groupId>
@@ -48,12 +48,12 @@
4848
<groupId>org.springframework.boot</groupId>
4949
<artifactId>spring-boot-starter-web</artifactId>
5050
</dependency>
51-
52-
<dependency>
51+
52+
<dependency>
5353
<groupId>org.springframework.boot</groupId>
5454
<artifactId>spring-boot-starter-aop</artifactId>
5555
</dependency>
56-
56+
5757
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
5858
<dependency>
5959
<groupId>org.springframework.boot</groupId>
@@ -160,5 +160,4 @@
160160
</plugins>
161161
</build>
162162

163-
164163
</project>

0 commit comments

Comments
 (0)