Set initial database schema
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.springframework.boot' version '4.0.2'
|
id 'org.springframework.boot' version '4.0.5'
|
||||||
id 'io.spring.dependency-management' version '1.1.7'
|
id 'io.spring.dependency-management' version '1.1.7'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.kpuig.concord'
|
group = 'net.kpuig.concord'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
description = 'Demo project for Spring Boot'
|
description = 'Concord REST Server'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
@@ -25,12 +25,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
|
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
|
||||||
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.3'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-websocket'
|
implementation 'org.springframework.boot:spring-boot-starter-websocket'
|
||||||
|
//implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
|
//implementation 'org.springframework.boot:spring-boot-starter-security-oauth2-resource-server'
|
||||||
compileOnly 'org.projectlombok:lombok'
|
compileOnly 'org.projectlombok:lombok'
|
||||||
runtimeOnly 'org.postgresql:postgresql'
|
runtimeOnly 'org.postgresql:postgresql'
|
||||||
runtimeOnly 'com.h2database:h2:2.4.240'
|
runtimeOnly 'com.h2database:h2:2.4.240'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-h2console'
|
||||||
annotationProcessor 'org.projectlombok:lombok'
|
annotationProcessor 'org.projectlombok:lombok'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
jdk25
|
jdk25
|
||||||
gradle
|
gradle
|
||||||
|
keycloak
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
mkdir -p .vscode
|
mkdir -p .vscode
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.kpuig.concord.backend.datamodels;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.kpuig.concord.backend.datamodels.enums.ChannelType;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity(name = "channel")
|
||||||
|
public class Channel {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long position;
|
||||||
|
|
||||||
|
private ChannelType type;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Server server;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.kpuig.concord.backend.datamodels;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity(name = "message")
|
||||||
|
public class Message {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private Long timestamp;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private UserProfile userProfile;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Channel channel;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.kpuig.concord.backend.datamodels;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity(name = "server")
|
||||||
|
public class Server {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private URL image;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.kpuig.concord.backend.datamodels;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity(name = "user_profile")
|
||||||
|
public class UserProfile {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package net.kpuig.concord.backend.datamodels.enums;
|
||||||
|
|
||||||
|
public enum ChannelType {
|
||||||
|
TEXT_CHANNEL,
|
||||||
|
VOICE_CHANNEL
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.kpuig.concord.backend.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import net.kpuig.concord.backend.datamodels.Channel;
|
||||||
|
|
||||||
|
public interface ChannelRepository extends JpaRepository<Channel, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.kpuig.concord.backend.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import net.kpuig.concord.backend.datamodels.Message;
|
||||||
|
|
||||||
|
public interface MessageRepository extends JpaRepository<Message, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.kpuig.concord.backend.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import net.kpuig.concord.backend.datamodels.Server;
|
||||||
|
|
||||||
|
public interface ServerRepository extends JpaRepository<Server, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.kpuig.concord.backend.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import net.kpuig.concord.backend.datamodels.UserProfile;
|
||||||
|
|
||||||
|
public interface UserProfileRepository extends JpaRepository<UserProfile, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1 +1,11 @@
|
|||||||
spring.application.name=backend
|
spring.application.name=backend
|
||||||
|
spring.h2.console.enabled=true
|
||||||
|
spring.h2.console.path=/h2-console
|
||||||
|
spring.datasource.url=jdbc:h2:mem:testdb
|
||||||
|
spring.datasource.driverClassName=org.h2.Driver
|
||||||
|
spring.datasource.username=sa
|
||||||
|
spring.datasource.password=password
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
logging.level.org.springframework=INFO
|
||||||
|
logging.level.com.example=DEBUG
|
||||||
|
server.port=8080
|
||||||
Reference in New Issue
Block a user