diff --git a/.gitignore b/.gitignore index 667aaef..c877022 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ build/ ### VS Code ### .vscode/ + +### Fichier properties ### +*.properties diff --git a/pom.xml b/pom.xml index bfc3040..5dea947 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,19 @@ spring-boot-starter-test test - + + org.postgresql + postgresql + + + org.flywaydb + flyway-core + + + org.flywaydb + flyway-database-postgresql + + diff --git a/src/main/java/fr/host_dcode/vlib/model/Station.java b/src/main/java/fr/host_dcode/vlib/model/Station.java new file mode 100644 index 0000000..1859b59 --- /dev/null +++ b/src/main/java/fr/host_dcode/vlib/model/Station.java @@ -0,0 +1,77 @@ +package fr.host_dcode.vlib.model; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +import java.time.LocalDateTime; + +@Entity +public class Station { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + private String id; + private String recordId; + private String name; + private String station_code; + private double latitude; + private double longitude; + private String address; + private String city; + private String description; + private LocalDateTime last_update; + + + public Station(){} + + public Station(String name, String recordId, String stationCode, double latitude, double longitude, String description) { + this.name = name; + this.recordId = recordId; + this.station_code = stationCode; + this.latitude = latitude; + this.longitude = longitude; + this.description = description; + } + + public String getStationCode(){ + return this.station_code; + } + + public String getName(){ + return this.name; + } + + public void setName(String name){ + this.name = name; + } + + public String getRecordId(){ + return this.recordId; + } + + public String getDescription(){ + return this.description; + } + + public void setDescription(String description){ + this.description = description; + } + public Double getLatitude(){ + return this.latitude; + } + public Double getLongitude(){ + return this.longitude; + } + + public String getAddress(){ + return this.address; + } + + public void setAddress(String address){ + this.address = address; + } + + +} diff --git a/src/main/java/fr/host_dcode/vlib/model/User.java b/src/main/java/fr/host_dcode/vlib/model/User.java new file mode 100644 index 0000000..f097a9d --- /dev/null +++ b/src/main/java/fr/host_dcode/vlib/model/User.java @@ -0,0 +1,43 @@ +package fr.host_dcode.vlib.model; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; + + +@Entity +@Table(name = "users") +public class User { + public enum Status { + USER, + ADMIN + } + + @Id + @GeneratedValue(strategy = GenerationType.UUID) + private String id; + private String email; + private String password; + @Enumerated(EnumType.STRING) + private Status status; + private LocalDateTime created_at; + + + public User(){} + + public User(String email, String password){ + this.email = email; + this.password = password; + } + + public String getEmail(){ + return this.email; + } + + public Status getStatus(){ + return this.status; + } + + + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 6b0fade..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=vlib diff --git a/src/main/resources/db/migration/V1__Create_tables_User_and_Station.sql b/src/main/resources/db/migration/V1__Create_tables_User_and_Station.sql new file mode 100644 index 0000000..215b6a3 --- /dev/null +++ b/src/main/resources/db/migration/V1__Create_tables_User_and_Station.sql @@ -0,0 +1,21 @@ +CREATE TABLE users ( + id VARCHAR(40) PRIMARY KEY, + email VARCHAR(50) NOT NULL, + password VARCHAR(200) NOT NULL, + status VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UNIQUE (email) +); + +CREATE TABLE station ( + id VARCHAR(40) PRIMARY KEY, + recordId VARCHAR(100) NOT NULL, + name VARCHAR(100) NOT NULL, + station_code VARCHAR(20) NOT NULL, + latitude DECIMAL(9,6) NOT NULL, + longitude DECIMAL(9,6) NOT NULL, + address VARCHAR(100), + city VARCHAR(20), + description VARCHAR(300), + last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file