我是Scala和Play Framework的新手。
我有一个要注入控制器的后续类。
reader.close();
writer.close();
控制器
class BoardRepositoryImpl extends BoardRepository {
private val tableName = "tyo_boards"
private val table = DynamoDBProvider.db.getTable(tableName)
override def findAll: List[Board] = {
val hashCondition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue("841120161129"))
table.scan(new ScanSpec())
.asScala
.toList
.map( i => new Board(
i.getString(BoardRepository.codeDate),
i.getList(BoardRepository.withLimit)
.asScala
.toList,
i.getString(BoardRepository.time)
)
)
}
}
object BoardRepository {
val codeDate = "code_date"
val withLimit = "with_limit"
val time = "time"
}
结果是
@Singleton
class BoardsController @Inject()(repository: BoardRepositoryImpl) extends Controller {
def index = Action {
val boards = repository.findAll
Ok(views.html.boards(boards))
}
}
老实说,我不知道为什么会这样。