-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feaf406
commit 55c366d
Showing
52 changed files
with
1,531 additions
and
169 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,38 +1,61 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.springframework.boot") version "3.0.0-M3" | ||
id("org.springframework.boot") version "2.7.1" | ||
id("io.spring.dependency-management") version "1.0.11.RELEASE" | ||
kotlin("jvm") version "1.6.21" | ||
kotlin("plugin.spring") version "1.6.21" | ||
id("org.jetbrains.kotlin.plugin.noarg") version "1.7.10" | ||
kotlin("jvm") version "1.7.10" | ||
kotlin("plugin.jpa") version "1.7.10" | ||
kotlin("plugin.spring") version "1.7.10" | ||
} | ||
|
||
group = "com.todo" | ||
group = "com.app" | ||
version = "0.0.1-SNAPSHOT" | ||
java.sourceCompatibility = JavaVersion.VERSION_17 | ||
java.sourceCompatibility = JavaVersion.VERSION_18 | ||
|
||
noArg { | ||
annotation("javax.persistence.Entity") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = uri("https://repo.spring.io/milestone") } | ||
maven { url = uri("https://repo.spring.io/snapshot") } | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||
implementation("org.springframework.boot:spring-boot-starter-validation") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
developmentOnly("org.springframework.boot:spring-boot-devtools") | ||
implementation("com.linecorp.kotlin-jdsl:spring-data-kotlin-jdsl-starter:2.0.4.RELEASE") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
developmentOnly("org.springframework.boot:spring-boot-devtools") | ||
implementation("org.junit.jupiter:junit-jupiter:5.8.2") | ||
implementation("org.springdoc:springdoc-openapi-data-rest:1.6.9") | ||
implementation("org.springdoc:springdoc-openapi-ui:1.6.9") | ||
implementation("org.springdoc:springdoc-openapi-kotlin:1.6.9") | ||
implementation("org.springdoc:springdoc-openapi-webflux-ui:1.6.9") | ||
implementation("io.arrow-kt:arrow-core:1.1.2") | ||
runtimeOnly("com.h2database:h2") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation(kotlin("test")) | ||
testImplementation("io.kotest:kotest-runner-junit5:5.3.2") | ||
testImplementation("io.kotest:kotest-assertions-core:5.3.2") | ||
testImplementation("io.kotest:kotest-property:5.3.2") | ||
testImplementation("io.kotest.extensions:kotest-assertions-arrow") | ||
testImplementation("io.kotest.extensions:kotest-extensions-spring") | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = "17" | ||
jvmTarget = "18" | ||
} | ||
} | ||
|
||
tasks.withType<Test> { | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package com.todo.tododdd | ||
package com.app | ||
|
||
import io.swagger.v3.oas.models.OpenAPI | ||
import io.swagger.v3.oas.models.info.Info | ||
import org.springdoc.core.GroupedOpenApi | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
import org.springframework.context.annotation.Bean | ||
|
||
|
||
@SpringBootApplication | ||
class TodoDddApplication | ||
class TodoDDDApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<TodoDddApplication>(*args) | ||
val context = runApplication<TodoDDDApplication>(*args) | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/app/core/exceptions/EntityNotFoundException.kt
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.app.core.exceptions | ||
|
||
class EntityNotFound( | ||
class EntityNotFoundException( | ||
message: String = "Entity Not Found" | ||
) : Exception(message = message) | ||
) : Exception(message) |
4 changes: 1 addition & 3 deletions
4
src/main/kotlin/com/app/core/exceptions/InvalidOperationException.kt
This file contains 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package com.app.core.exceptions | ||
|
||
import java.util.* | ||
|
||
class InvalidOperationException(message: String) : Exception( | ||
message = message | ||
message | ||
) |
This file contains 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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package com.app.core.failures | ||
|
||
class BadRequestFailure { | ||
} | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import java.util.* | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
class BadRequestFailure( | ||
override val id: UUID, | ||
override val message: String, | ||
) : BaseFailure(), IBaseFailure |
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
package com.app.core.failures | ||
|
||
class NotFoundFailure { | ||
} | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import java.util.* | ||
|
||
@ResponseStatus(HttpStatus.NOT_FOUND) | ||
class NotFoundFailure( | ||
override val id: UUID, | ||
override val message: String, | ||
) : BaseFailure() { | ||
|
||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
package com.app.core.failures | ||
|
||
class ServerFailure { | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import java.util.* | ||
|
||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | ||
class ServerFailure( | ||
override val id: UUID, | ||
override val message: String | ||
) : BaseFailure() { | ||
|
||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package com.app.core.failures | ||
|
||
class ValidationFailure { | ||
} | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import java.util.* | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
class ValidationFailure( | ||
override val id: UUID, | ||
override val message: String | ||
) : BaseFailure() |
This file contains 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
package com.app.core.routes | ||
|
||
class BaseRoute { | ||
import org.springframework.web.reactive.function.server.RouterFunction | ||
import org.springframework.web.reactive.function.server.ServerResponse | ||
|
||
interface BaseRoute { | ||
operator fun invoke(): RouterFunction<ServerResponse> | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
package com.app.core.unitofwork | ||
|
||
class UnitOfWork { | ||
} | ||
interface IUnitOfWork<out T> { | ||
|
||
fun begin(): Unit | ||
fun commit(): Unit | ||
fun rollback(): Unit | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package com.app.core.usecases | ||
|
||
class Usecase { | ||
} | ||
import arrow.core.Either | ||
|
||
interface IUseCaseNoParams<Type> { | ||
operator fun invoke(): Either<Exception, Type> | ||
} | ||
|
||
interface IUseCase<Type, Params> { | ||
operator fun invoke(params: Params): Either<Exception, Type> | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,80 @@ | ||
package com.app.features.todo.data.models | ||
|
||
class Todo { | ||
import com.app.features.todo.domain.entities.TodoReadModel | ||
import com.app.features.user.data.models.User | ||
import com.app.features.todo.domain.entities.Todo as TodoEntity | ||
import org.hibernate.annotations.DynamicUpdate | ||
import org.springframework.data.annotation.LastModifiedDate | ||
import java.util.Date | ||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.ForeignKey | ||
import javax.persistence.GeneratedValue | ||
import javax.persistence.Id | ||
import javax.persistence.JoinColumn | ||
import javax.persistence.ManyToOne | ||
import javax.persistence.OneToMany | ||
|
||
@Entity(name = "Todos") | ||
@DynamicUpdate | ||
class Todo( | ||
@Id | ||
@GeneratedValue | ||
val id: Int, | ||
val title: String, | ||
@Column( | ||
nullable = false | ||
) | ||
val ownerId: Int, | ||
@Column( | ||
updatable = false | ||
) | ||
val createdAt: Date, | ||
@LastModifiedDate | ||
val updatedAt: Date, | ||
val isCompleted: Boolean, | ||
val isDeleted: Boolean, | ||
) { | ||
@ManyToOne | ||
@JoinColumn( | ||
name = "ownerId", | ||
nullable = false, | ||
insertable = false, | ||
updatable = false | ||
) | ||
lateinit var owner: User | ||
|
||
constructor(todo: TodoEntity) : this( | ||
id = todo.id, | ||
title = todo.title, | ||
ownerId = todo.ownerId, | ||
createdAt = todo.createdAt, | ||
updatedAt = todo.updatedAt, | ||
isCompleted = todo.isCompleted, | ||
isDeleted = todo.isDeleted | ||
) | ||
|
||
fun toDomainEntity(): TodoEntity{ | ||
return TodoEntity( | ||
id = this.id, | ||
title = this.title, | ||
ownerId = this.ownerId, | ||
createdAt = this.createdAt, | ||
updatedAt = this.updatedAt, | ||
isCompleted = this.isCompleted, | ||
isDeleted = this.isDeleted | ||
) | ||
} | ||
|
||
fun toReadModel(): TodoReadModel { | ||
return TodoReadModel( | ||
id = this.id, | ||
title = this.title, | ||
ownerId = this.ownerId, | ||
createdAt = this.createdAt, | ||
updatedAt = this.updatedAt, | ||
isCompleted = this.isCompleted, | ||
isDeleted = this.isDeleted | ||
) | ||
} | ||
} |
Oops, something went wrong.