ADD database integration & ADD simple dummy user entity
This commit is contained in:
@@ -11,6 +11,6 @@ post {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body:form-urlencoded {
|
body:form-urlencoded {
|
||||||
startPoint: 30
|
startPoint: 130
|
||||||
endPoint: 120
|
endPoint: 140
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: myuser
|
POSTGRES_USER: myuser
|
||||||
POSTGRES_PASSWORD: mypassword
|
POSTGRES_PASSWORD: mypassword
|
||||||
POSTGRES_DB: mydb
|
POSTGRES_DB: vodSystem
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
32
src/main/java/com/ddf/vodsystem/entities/User.java
Normal file
32
src/main/java/com/ddf/vodsystem/entities/User.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.ddf.vodsystem.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "users")
|
||||||
|
@Data
|
||||||
|
public class User {
|
||||||
|
@Column(name = "id", nullable = false, unique = true)
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Id
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "google_id", nullable = false, unique = true)
|
||||||
|
private String googleId;
|
||||||
|
|
||||||
|
@Column(name = "username", nullable = false, unique = true)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Column(name = "email", nullable = false, unique = true)
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Column(name = "name", nullable = false)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ddf.vodsystem.repositories;
|
||||||
|
|
||||||
|
import com.ddf.vodsystem.entities.User;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
|
}
|
||||||
@@ -7,13 +7,16 @@ temp.vod.storage=videos/inputs/
|
|||||||
temp.vod.output=videos/outputs/
|
temp.vod.output=videos/outputs/
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
|
spring.datasource.url=jdbc:postgresql://postgres:5432/vodSystem
|
||||||
spring.datasource.username=myuser
|
spring.datasource.username=myuser
|
||||||
spring.datasource.password=mypassword
|
spring.datasource.password=mypassword
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
spring.sql.init.mode=always
|
||||||
|
|
||||||
|
spring.sql.init.schema-locations=classpath:db/schema.sql
|
||||||
|
spring.sql.init.data-locations=classpath:db/data.sql
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
logging.level.org.springframework.web=DEBUG
|
logging.level.org.springframework.web=DEBUG
|
||||||
12
src/main/resources/db/data.sql
Normal file
12
src/main/resources/db/data.sql
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
INSERT INTO users (id, google_id, username, email, name)
|
||||||
|
VALUES
|
||||||
|
(1, 'google-uid-001', 'alice', 'alice@example.com', 'Alice Example'),
|
||||||
|
(2, 'google-uid-002', 'bob', 'bob@example.com', 'Bob Example'),
|
||||||
|
(3, 'google-uid-003', 'carol', 'carol@example.com', 'Carol Example'),
|
||||||
|
(4, 'google-uid-004', 'wizard42', 'gandalf@middle.earth', 'Gandalf the Grey'),
|
||||||
|
(5, 'google-uid-005', 'catnap', 'whiskers@meowmail.com', 'Sir Whiskers McFluff'),
|
||||||
|
(6, 'google-uid-006', 'robotron', 'bender@futurama.tv', 'Bender Rodriguez'),
|
||||||
|
(7, 'google-uid-007', 'unicorn', 'sparkle@rainbow.com', 'Princess Sparklehoof'),
|
||||||
|
(8, 'google-uid-008', 'pirate', 'blackbeard@seas.com', 'Edward Teach'),
|
||||||
|
(9, 'google-uid-009', 'detective', 'holmes@bakerstreet.uk', 'Sherlock Holmes'),
|
||||||
|
(10, 'google-uid-010', 'timey', 'docbrown@delorean.net', 'Dr. Emmett Brown');
|
||||||
9
src/main/resources/db/schema.sql
Normal file
9
src/main/resources/db/schema.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
DROP TABLE IF EXISTS users;
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id BIGINT PRIMARY KEY,
|
||||||
|
google_id VARCHAR(64),
|
||||||
|
username VARCHAR(50) NOT NULL UNIQUE,
|
||||||
|
email VARCHAR(100) NOT NULL UNIQUE,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user