blob: 572edb6c29c4ddcfe745469a9d4fc5eabb40a3ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
package xyz.driver.pdsuidomain.services
import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext
import xyz.driver.pdsuicommon.db.Sorting
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuicommon.error.DomainError
import xyz.driver.pdsuidomain.entities.Hypothesis
import scala.concurrent.Future
object HypothesisService {
trait DefaultNotFoundError {
def userMessage: String = "Hypothesis not found"
}
trait DefaultAccessDeniedError {
def userMessage: String = "Access denied"
}
sealed trait GetListReply
object GetListReply {
final case class EntityList(xs: Seq[Hypothesis], totalFound: Int) extends GetListReply
case object AuthorizationError extends GetListReply with DomainError.AuthorizationError {
def userMessage: String = "Access denied"
}
}
sealed trait CreateReply
object CreateReply {
final case class Created(x: Hypothesis) extends CreateReply
type Error = CreateReply with DomainError
case object AuthorizationError
extends CreateReply with DefaultAccessDeniedError with DomainError.AuthorizationError
final case class CommonError(userMessage: String) extends CreateReply with DomainError
}
sealed trait DeleteReply
object DeleteReply {
case object Deleted extends DeleteReply
type Error = DeleteReply with DomainError
case object NotFoundError extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError
case object AuthorizationError
extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError
final case class CommonError(userMessage: String) extends DeleteReply with DomainError
}
}
trait HypothesisService {
import HypothesisService._
def getAll(sorting: Option[Sorting] = None)(
implicit requestContext: AuthenticatedRequestContext): Future[GetListReply]
def create(draftHypothesis: Hypothesis)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply]
def delete(id: UuidId[Hypothesis])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply]
}
|