-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add flyway migration-v1; add hibernate mapping #11
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
version: '3.5' | ||
networks: | ||
lan: | ||
driver: bridge | ||
services: | ||
mysql: | ||
docker-mysql: | ||
image: mysql:8 | ||
command: --default-authentication-plugin=mysql_native_password | ||
restart: always | ||
hostname: localhost | ||
ports: | ||
- 5432:5432 | ||
- '3308:3306' | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: rootpass | ||
MYSQL_USER: testuser | ||
MYSQL_PASSWORD: testpass | ||
MYSQL_DB: teste | ||
server: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: test_db | ||
MYSQL_USER: root | ||
MYSQL_PASSWORD: password | ||
networks: | ||
- lan | ||
docker-server: | ||
image: spring-mysql | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
networks: | ||
- lan | ||
depends_on: | ||
- mysql | ||
- docker-mysql | ||
ports: | ||
- 8080:8080 | ||
environment: | ||
- DATABASE_HOST=localhost | ||
- DATABASE_USER=testuser | ||
- DATABASE_NAME=teste | ||
- DATABASE_PORT=5432 | ||
- '8091:8091' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.natlex.backend_module.model; | ||
|
||
import javax.persistence.*; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Table (name = "DatePoint") | ||
public class DatePoint { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(nullable = false) | ||
private Long id; | ||
|
||
private String description; | ||
private String photo; | ||
private Date date; | ||
private String links; | ||
private Long point_id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @OnetoOne and fetch - lazy |
||
|
||
public DatePoint(Long id, String description, String photo, Date date, String links, Long point_id) { | ||
this.id = id; | ||
this.description = description; | ||
this.photo = photo; | ||
this.date = date; | ||
this.links = links; | ||
this.point_id = point_id; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getPhoto() { | ||
return photo; | ||
} | ||
|
||
public void setPhoto(String photo) { | ||
this.photo = photo; | ||
} | ||
|
||
public Date getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
public String getLinks() { | ||
return links; | ||
} | ||
|
||
public void setLinks(String links) { | ||
this.links = links; | ||
} | ||
|
||
public Long getPoint_id() { | ||
return point_id; | ||
} | ||
|
||
public void setPoint_id(Long point_id) { | ||
this.point_id = point_id; | ||
} | ||
|
||
public DatePoint() { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.natlex.backend_module.model; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
|
||
@Table (name = "Point") | ||
public class Point { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "coordinates", nullable = false) | ||
private org.springframework.data.geo.Point coordinates; | ||
|
||
private int count; | ||
private String adress; | ||
|
||
public Point() { | ||
} | ||
|
||
public Point(Long id, org.springframework.data.geo.Point coordinates, int count, String adress) { | ||
this.id = id; | ||
this.coordinates = coordinates; | ||
this.count = count; | ||
this.adress = adress; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public org.springframework.data.geo.Point getCoordinates() { | ||
return coordinates; | ||
} | ||
|
||
public void setCoordinates(org.springframework.data.geo.Point coordinates) { | ||
this.coordinates = coordinates; | ||
} | ||
|
||
public int getCount() { | ||
return count; | ||
} | ||
|
||
public void setCount(int count) { | ||
this.count = count; | ||
} | ||
|
||
public String getAdress() { | ||
return adress; | ||
} | ||
|
||
public void setAdress(String adress) { | ||
this.adress = adress; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.natlex.backend_module.model; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Table (name = "User") | ||
public class User { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(nullable = false) | ||
private Long id; | ||
|
||
private String email; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. email validation, you can check already exist validator |
||
private boolean inAdmin; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is |
||
private String authData; | ||
|
||
public User() { | ||
} | ||
|
||
public User(Long id, String email, boolean inAdmin, String authData) { | ||
this.id = id; | ||
this.email = email; | ||
this.inAdmin = inAdmin; | ||
this.authData = authData; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public boolean isInAdmin() { | ||
return inAdmin; | ||
} | ||
|
||
public void setInAdmin(boolean inAdmin) { | ||
this.inAdmin = inAdmin; | ||
} | ||
|
||
public String getAuthData() { | ||
return authData; | ||
} | ||
|
||
public void setAuthData(String authData) { | ||
this.authData = authData; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
#spring.datasource.url=jdbc:mysql://docker-mysql:3308/test_db?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false | ||
spring.datasource.username=root | ||
spring.datasource.password=password | ||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||
|
||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test_db?serverTimezone=Europe/Moscow&autoReconnect=true&useSSL=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE TABLE Point (id INT AUTO_INCREMENT NOT NULL, | ||
coordinates POINT NOT NULL, | ||
count INT, | ||
adress VARCHAR(200), | ||
PRIMARY KEY(id)); | ||
|
||
CREATE TABLE DatePoint (id INT AUTO_INCREMENT NOT NULL, | ||
description VARCHAR(300), | ||
photo VARCHAR(300), | ||
date DATE, | ||
links VARCHAR(200), | ||
point_id INT, | ||
PRIMARY KEY (id), | ||
FOREIGN KEY (point_id) REFERENCES Point(id)); | ||
|
||
CREATE TABLE User (id INT AUTO_INCREMENT NOT NULL, | ||
email VARCHAR(200), | ||
inAdmin BOOL, | ||
authData VARCHAR(300), | ||
PRIMARY KEY (id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you create parent class for id