Skip to content
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

lab-6 #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
version: "3.9"
services:
postgres:
hostname: event_sourcing_db
image: postgres:14.9-alpine
env_file:
- ./.env
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- ${POSTGRES_DB_PORT}:${POSTGRES_DB_PORT}
restart: unless-stopped
# postgres:
# hostname: event_sourcing_db
# image: postgres:14.9-alpine
# env_file:
# - ./.env
# environment:
# POSTGRES_DB: ${POSTGRES_DB}
# POSTGRES_USER: ${POSTGRES_USER}
# POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
# ports:
# - ${POSTGRES_DB_PORT}:${POSTGRES_DB_PORT}
# restart: unless-stopped
mongo:
build:
context: mongoDb
# dockerfile: mongoDb/Dockerfile
dockerfile: mongoDb/Dockerfile
restart: always
ports:
- 27017:27017
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@
<version>${tiny.es.version}</version>
</dependency>

<dependency>
<groupId>ru.quipy</groupId>
<artifactId>tiny-postgres-event-store-spring-boot-starter</artifactId>
<version>${tiny.es.version}</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>ru.quipy</groupId>-->
<!-- <artifactId>tiny-mongo-event-store-spring-boot-starter</artifactId>-->
<!-- <artifactId>tiny-postgres-event-store-spring-boot-starter</artifactId>-->
<!-- <version>${tiny.es.version}</version>-->
<!-- </dependency>-->

<dependency>
<groupId>ru.quipy</groupId>
<artifactId>tiny-mongo-event-store-spring-boot-starter</artifactId>
<version>${tiny.es.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
55 changes: 0 additions & 55 deletions src/main/kotlin/ru/quipy/api/ProjectAggregateDomainEvents.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.quipy.api
package ru.quipy.api.project

import ru.quipy.core.annotations.AggregateType
import ru.quipy.domain.Aggregate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ru.quipy.api.project

import ru.quipy.core.annotations.DomainEvent
import ru.quipy.domain.Event
import java.util.*

const val PROJECT_CREATED_EVENT = "PROJECT_CREATED_EVENT"
const val PARTICIPANT_ADDED_EVENT = "PARTICIPANT_ADDED_EVENT"

@DomainEvent(name = PROJECT_CREATED_EVENT)
class ProjectCreatedEvent(
val projectId: UUID,
val title: String,
val creatorId: String,
createdAt: Long = System.currentTimeMillis(),
) : Event<ProjectAggregate>(
name = PROJECT_CREATED_EVENT,
createdAt = createdAt,
)

@DomainEvent(name = PARTICIPANT_ADDED_EVENT)
class ParticipantAddedEvent(
val projectId: UUID,
val userId: UUID,
val userName: String,
createdAt: Long = System.currentTimeMillis(),
) : Event<ProjectAggregate>(
name = PARTICIPANT_ADDED_EVENT,
createdAt = createdAt
)
7 changes: 7 additions & 0 deletions src/main/kotlin/ru/quipy/api/status/StatusAggregate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.quipy.api.status

import ru.quipy.core.annotations.AggregateType
import ru.quipy.domain.Aggregate

@AggregateType(aggregateEventsTableName = "aggregate-status")
class StatusAggregate : Aggregate
40 changes: 40 additions & 0 deletions src/main/kotlin/ru/quipy/api/status/StatusAggregateDomainEvents.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ru.quipy.api.status

import ru.quipy.core.annotations.DomainEvent
import ru.quipy.domain.Event
import java.util.*

const val STATUS_CREATED_EVENT = "STATUS_CREATED_EVENT"
const val STATUS_TITLE_UPDATED_EVENT = "STATUS_TITLE_UPDATED_EVENT"
const val STATUS_COLOR_UPDATED_EVENT = "STATUS_COLOR_UPDATED_EVENT"

@DomainEvent(name = STATUS_CREATED_EVENT)
class StatusCreatedEvent(
val statusId: UUID,
val title: String,
val color: String,
createdAt: Long = System.currentTimeMillis()
) : Event<StatusAggregate>(
name = STATUS_CREATED_EVENT,
createdAt = createdAt
) {}

@DomainEvent(name = STATUS_TITLE_UPDATED_EVENT)
class StatusTitleUpdatedEvent(
val statusId: UUID,
val newTitle: String,
createdAt: Long = System.currentTimeMillis()
) : Event<StatusAggregate>(
name = STATUS_TITLE_UPDATED_EVENT,
createdAt = createdAt
)

@DomainEvent(name = STATUS_COLOR_UPDATED_EVENT)
class StatusColorUpdatedEvent(
val statusId: UUID,
val newColor: String,
createdAt: Long = System.currentTimeMillis()
) : Event<StatusAggregate>(
name = STATUS_COLOR_UPDATED_EVENT,
createdAt = createdAt
)
7 changes: 7 additions & 0 deletions src/main/kotlin/ru/quipy/api/task/TaskAggregate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.quipy.api.task

import ru.quipy.core.annotations.AggregateType
import ru.quipy.domain.Aggregate

@AggregateType(aggregateEventsTableName = "aggregate-task")
class TaskAggregate : Aggregate
81 changes: 81 additions & 0 deletions src/main/kotlin/ru/quipy/api/task/TaskAggregateDomainEvents.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ru.quipy.api.task

import ru.quipy.core.annotations.DomainEvent
import ru.quipy.domain.Event
import ru.quipy.logic.task.TaskExecutor
import java.time.LocalDateTime
import java.util.*

// константы для идентификации различных типов событий, связанных с задачей
const val EVENT_TASK_CREATED = "EVENT_TASK_CREATED"
const val EVENT_TASK_STATUS_UPDATED = "EVENT_TASK_STATUS_UPDATED"
const val EVENT_TASK_TITLE_UPDATED = "EVENT_TASK_TITLE_UPDATED"
const val EVENT_TASK_DESCRIPTION_UPDATED = "EVENT_TASK_DESCRIPTION_UPDATED"
const val EVENT_TASK_EXECUTOR_ADDED = "EVENT_TASK_EXECUTOR_ADDED"
const val EVENT_TASK_REMOVED = "EVENT_TASK_REMOVED"

// определение событий для задач
@DomainEvent(name = EVENT_TASK_CREATED)
class TaskCreatedEvent(
val taskId: UUID,
val projectId: UUID, // id проекта, к которому относится задача
val title: String,
val description: String,
val deadlineTimestamp: LocalDateTime,
val statusId: UUID, // начальный статус задачи
val executors: Map<UUID, TaskExecutor> = emptyMap(), // назначенные исполнители задачи
createdAt: Long = System.currentTimeMillis() // временная метка создания
) : Event<TaskAggregate>(
name = EVENT_TASK_CREATED,
createdAt = createdAt
)

@DomainEvent(name = EVENT_TASK_STATUS_UPDATED)
class TaskStatusUpdatedEvent(
val taskId: UUID,
val newStatusId: UUID, // новый статус задачи
updatedAt: Long = System.currentTimeMillis() // временная метка обновления
) : Event<TaskAggregate>(
name = EVENT_TASK_STATUS_UPDATED,
createdAt = updatedAt
)

@DomainEvent(name = EVENT_TASK_TITLE_UPDATED)
class TaskTitleUpdatedEvent(
val taskId: UUID,
val newTitle: String,
updatedAt: Long = System.currentTimeMillis()
) : Event<TaskAggregate>(
name = EVENT_TASK_TITLE_UPDATED,
createdAt = updatedAt
)

@DomainEvent(name = EVENT_TASK_DESCRIPTION_UPDATED)
class TaskDescriptionUpdatedEvent(
val taskId: UUID,
val newDescription: String, // новое описание задачи
updatedAt: Long = System.currentTimeMillis()
) : Event<TaskAggregate>(
name = EVENT_TASK_DESCRIPTION_UPDATED,
createdAt = updatedAt
)

@DomainEvent(name = EVENT_TASK_EXECUTOR_ADDED)
class TaskExecutorAddedEvent(
val taskId: UUID,
val executorId: UUID, // идентификатор назначенного пользователя
assignedAt: Long = System.currentTimeMillis()
) : Event<TaskAggregate>(
name = EVENT_TASK_EXECUTOR_ADDED,
createdAt = assignedAt
)

@DomainEvent(name = EVENT_TASK_REMOVED)
class TaskDeletedEvent(
val taskId: UUID,
val projectId: UUID, // id проекта, к которому привязана задача
removedAt: Long = System.currentTimeMillis() // временная метка удаления
) : Event<TaskAggregate>(
name = EVENT_TASK_REMOVED,
createdAt = removedAt
)
8 changes: 8 additions & 0 deletions src/main/kotlin/ru/quipy/api/user/UserAggregate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ru.quipy.api.user

import ru.quipy.core.annotations.AggregateType
import ru.quipy.domain.Aggregate

@AggregateType(aggregateEventsTableName = "aggregate-user")
class UserAggregate : Aggregate

19 changes: 19 additions & 0 deletions src/main/kotlin/ru/quipy/api/user/UserAggregateDomainEvents.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ru.quipy.api.user

import ru.quipy.core.annotations.DomainEvent
import ru.quipy.domain.Event
import java.util.*

const val USER_CREATED_EVENT = "USER_CREATED_EVENT"

@DomainEvent(name = USER_CREATED_EVENT)
class UserCreatedEvent(
val userId: UUID,
val username: String,
val login: String,
val password: String,
createdAt: Long = System.currentTimeMillis()
) : Event<UserAggregate>(
name = USER_CREATED_EVENT,
createdAt = createdAt
)
Loading