Implementation of getAll and create products endpoints.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package com.example.demo.domain.core.error
|
||||
|
||||
open class DomainError(val message: String)
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.example.demo.domain.core.error
|
||||
|
||||
class FunctionalError(message: String) : DomainError(message)
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.example.demo.domain.core.error
|
||||
|
||||
class TechnicalError(message: String) : DomainError(message)
|
||||
@@ -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>
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user