Add all layers.
This commit is contained in:
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
sporthub-database:
|
||||||
|
container_name: "sportshub-database"
|
||||||
|
image: "postgres:16"
|
||||||
|
ports:
|
||||||
|
- "50001:5432"
|
||||||
|
networks:
|
||||||
|
- "sportshub-local-network"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
sportshub-local-network:
|
||||||
20
pom.xml
20
pom.xml
@@ -13,9 +13,14 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
<module>sportshub-domain</module>
|
||||||
|
<module>sportshub-application</module>
|
||||||
|
<module>sportshub-infrastructure</module>
|
||||||
<module>sportshub-exposition</module>
|
<module>sportshub-exposition</module>
|
||||||
<module>sportshub-launcher</module>
|
<module>sportshub-launcher</module>
|
||||||
</modules>
|
</modules>
|
||||||
@@ -34,6 +39,21 @@
|
|||||||
<artifactId>sportshub-exposition</artifactId>
|
<artifactId>sportshub-exposition</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-application</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-domain</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-infrastructure</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
29
sportshub-application/pom.xml
Normal file
29
sportshub-application/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-parent</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>sportshub-application</artifactId>
|
||||||
|
|
||||||
|
<name>sportshub-application</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.sportshub.application.user;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.sportshub.domain.user.model.User;
|
||||||
|
import org.sportshub.domain.user.port.UserPort;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserUseCases {
|
||||||
|
private final UserPort userPort;
|
||||||
|
|
||||||
|
public UserUseCases(final UserPort userPort) {
|
||||||
|
this.userPort = userPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> findById(UUID userId) {
|
||||||
|
return userPort.findById(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
sportshub-domain/pom.xml
Normal file
30
sportshub-domain/pom.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-parent</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>sportshub-domain</artifactId>
|
||||||
|
|
||||||
|
<name>sportshub-domain</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>16</source>
|
||||||
|
<target>16</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.sportshub.domain.user.model;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public record User(
|
||||||
|
UUID id,
|
||||||
|
String password
|
||||||
|
) {}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.sportshub.domain.user.port;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.sportshub.domain.user.model.User;
|
||||||
|
|
||||||
|
public interface UserPort {
|
||||||
|
Optional<User> findById(UUID userId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.sportshub.exposition.user;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.sportshub.application.user.UserUseCases;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/users")
|
||||||
|
public class UserController {
|
||||||
|
private final UserUseCases userUseCases;
|
||||||
|
|
||||||
|
public UserController(final UserUseCases userUseCases) {
|
||||||
|
this.userUseCases = userUseCases;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public String login() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
29
sportshub-infrastructure/pom.xml
Normal file
29
sportshub-infrastructure/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-parent</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>sportshub-infrastructure</artifactId>
|
||||||
|
|
||||||
|
<name>sportshub-infrastructure</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.sportshub.infrastructure.user.adapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.sportshub.domain.user.model.User;
|
||||||
|
import org.sportshub.domain.user.port.UserPort;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class UserInMemoryAdapter implements UserPort {
|
||||||
|
private static final List<User> users = List.of(
|
||||||
|
new User(UUID.fromString("c1a0805f-c618-47dc-bae7-bee70503644e"), "password"),
|
||||||
|
new User(UUID.fromString("4eff194d-dd8e-463e-974f-034bfd509f84"), "password"),
|
||||||
|
new User(UUID.fromString("c78d7d7c-0386-415d-86dc-98a470591e07"), "password")
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<User> findById(final UUID userId) {
|
||||||
|
return users.stream()
|
||||||
|
.filter(user -> userId.equals(user.id()))
|
||||||
|
.findFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,18 @@
|
|||||||
<groupId>org.sportshub</groupId>
|
<groupId>org.sportshub</groupId>
|
||||||
<artifactId>sportshub-exposition</artifactId>
|
<artifactId>sportshub-exposition</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-application</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sportshub</groupId>
|
||||||
|
<artifactId>sportshub-infrastructure</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan(basePackages = "org.sportshub.exposition")
|
@ComponentScan(basePackages = {
|
||||||
|
"org.sportshub.exposition",
|
||||||
|
"org.sportshub.application",
|
||||||
|
"org.sportshub.domain",
|
||||||
|
"org.sportshub.infrastructure"
|
||||||
|
})
|
||||||
public class ApplicationLauncher {
|
public class ApplicationLauncher {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ApplicationLauncher.class, args);
|
SpringApplication.run(ApplicationLauncher.class, args);
|
||||||
|
|||||||
Reference in New Issue
Block a user