我遵循功能和反应域建模这本书的设计
对于某些服务方法,它仅将工作委托给存储库层。有没有办法减少这个样板:
trait FeedbackServiceImpl extends FeedbackService {
override def saveTFE(feedback: TripFeedbackEvent) =
Kleisli[Future, Context, Either[String, Id]] { ctx => ctx.feedbackRepo.save(feedback) }
override def saveLFE(feedback: LibraryFeedbackEvent) =
Kleisli[Future, Context, Either[String, Id]] { ctx => ctx.feedbackRepo.save(feedback) }
override def findByUser(userId: Id) =
Kleisli[Future, Context, Seq[FeedbackEvent]] { ctx => ctx.feedbackRepo.findByUser(userId) }
override def all =
Kleisli[Future, Context, Seq[FeedbackEvent]] { ctx => ctx.feedbackRepo.all }
override def findByTip(tipId: Id) =
Kleisli[Future, Context, Seq[FeedbackEvent]] { ctx => ctx.feedbackRepo.findByTip(tipId) }
}