Implementation of getAll and create products endpoints.

This commit is contained in:
Florian THIERRY
2025-04-23 23:13:48 +02:00
parent ed0acfc5dc
commit f98e1227e8
14 changed files with 136 additions and 31 deletions

View File

@@ -0,0 +1,3 @@
package com.example.demo.domain.core.error
open class DomainError(val message: String)

View File

@@ -0,0 +1,3 @@
package com.example.demo.domain.core.error
class FunctionalError(message: String) : DomainError(message)

View File

@@ -0,0 +1,3 @@
package com.example.demo.domain.core.error
class TechnicalError(message: String) : DomainError(message)

View File

@@ -0,0 +1,11 @@
package com.example.demo.domain.product.inputport
import com.example.demo.domain.core.error.FunctionalError
import com.example.demo.domain.product.model.Product
import com.example.demo.domain.product.model.ProductType
import com.github.michaelbull.result.Result
interface ProductInputPort {
suspend fun create(name: String, type: ProductType): Result<Product, FunctionalError>
suspend fun getAll(): Result<List<Product>, FunctionalError>
}

View File

@@ -0,0 +1,16 @@
package com.example.demo.domain.product.outputport
import com.example.demo.domain.core.error.TechnicalError
import com.example.demo.domain.product.model.Product
import com.github.michaelbull.result.Result
import java.util.UUID
interface ProductOutputPort {
fun getById(id: UUID): Product?
suspend fun getAll(): Result<List<Product>, TechnicalError>
fun save(product: Product): Result<Unit, TechnicalError>
fun deleteById(id: UUID)
}

View File

@@ -1,14 +0,0 @@
package com.example.demo.domain.product.port
import com.example.demo.domain.product.model.Product
import java.util.UUID
interface ProductPort {
fun getById(id: UUID): Product?
fun getAll(): List<Product>
fun save(product: Product)
fun deleteById(id: UUID)
}