-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement database #17
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
Open
SHACRAM
wants to merge
3
commits into
main
Choose a base branch
from
feature#4/Connect-database-and-create-tables
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,6 @@ build/ | |
|
|
||
| ### VS Code ### | ||
| .vscode/ | ||
|
|
||
| ### Fichier properties ### | ||
| *.properties | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| 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 | ||
SHACRAM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public class Station { | ||
|
|
||
SHACRAM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private int id; | ||
| private String name; | ||
| private String station_code; | ||
| private double latitude; | ||
| private double longitude; | ||
SHACRAM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private String address; | ||
| private String city; | ||
| private String description; | ||
| private LocalDateTime last_update; | ||
|
|
||
|
|
||
| public Station(){} | ||
|
|
||
| public Station(String name, String stationCode, double latitude, double longitude, String description) { | ||
| this.name = name; | ||
| 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 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; | ||
| } | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package fr.host_dcode.vlib.model; | ||
|
|
||
| public enum Status { | ||
| User, | ||
| Admin | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package fr.host_dcode.vlib.model; | ||
|
|
||
| import jakarta.persistence.*; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Entity | ||
| @Table(name = "users") | ||
| public class User { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private int id; | ||
SHACRAM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private String email; | ||
| private String password; | ||
SHACRAM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/resources/db/migration/V1__Create_tables_User_and_Station.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| CREATE TABLE users ( | ||
| id SERIAL PRIMARY KEY, | ||
| email VARCHAR(50) NOT NULL, | ||
| password VARCHAR(200) NOT NULL, | ||
| status VARCHAR(20) NOT NULL, | ||
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE TABLE station ( | ||
| id SERIAL PRIMARY KEY, | ||
| 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 | ||
| ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.