-2
我覺得這並不困難,但我正在努力與futures
並將對象或Int
s添加到不可變的Seq
。將期貨添加到不可變的Seq並返回
def createCopyOfProcessTemplate(processTemplateId: Int): Action[AnyContent] = Action.async {
//val copies = Seq()
processTemplateDTO.createCopyOfProcessTemplate(processTemplateId).flatMap { process =>
processTemplateDTO.getProcessStepTemplates(processTemplateId).map { steps =>
steps.foreach(processStep =>
copy: Future[Option[ProcessTemplateModel] = processTemplateDTO.createCopyOfStepTemplates(processTemplateId, process.get.id.get, processStep))
//Seq should look something like this: [{processStep.id, copy.id},{processStep.id, copy.id},...] or [[processStep.id, copy.id],[processStep.id, copy.id],...]
}
Ok(Json.obj("copies" -> copies))
}
我在哪裏需要定義seq
,我應該如何返回它,因爲它的操控Futures
?
任何想法?提前致謝!
請先看看[documentation](http://docs.scala-lang.org/overviews/collections/overview.html),試試看 – cchantep