Skip to content

Commit

Permalink
Changes: Move to generated DAO
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed Aug 2, 2024
1 parent afa0e74 commit ceccf44
Show file tree
Hide file tree
Showing 15 changed files with 1,011 additions and 259 deletions.
17 changes: 10 additions & 7 deletions api/app/controllers/Changes.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package controllers

import io.apibuilder.api.v0.models.json._
import db.ChangesDao
import io.apibuilder.api.v0.models.json.*
import db.InternalChangesDao
import models.ChangesModel

import javax.inject.{Inject, Singleton}
import play.api.mvc._
import play.api.libs.json._
import play.api.mvc.*
import play.api.libs.json.*

@Singleton
class Changes @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents,
changesDao: ChangesDao
changesDao: InternalChangesDao,
model: ChangesModel
) extends ApiBuilderController {

def get(
Expand All @@ -28,10 +31,10 @@ class Changes @Inject() (
fromVersion = from,
toVersion = to,
`type` = `type`,
limit = limit,
limit = Some(limit),
offset = offset
)
Ok(Json.toJson(changes))
Ok(Json.toJson(model.toModels(changes)))
}

}
2 changes: 1 addition & 1 deletion api/app/controllers/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Versions @Inject() (
versionsDao.findAll(
request.authorization,
applicationGuid = Some(application.guid),
limit = limit,
limit = Some(limit),
offset = offset
)
}.getOrElse(Nil)
Expand Down
206 changes: 0 additions & 206 deletions api/app/db/ChangesDao.scala

This file was deleted.

4 changes: 4 additions & 0 deletions api/app/db/InternalApplicationsDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ class InternalApplicationsDao @Inject()(
findAll(authorization, guid = Some(guid), limit = Some(1)).headOption
}

def findAllByGuids(authorization: Authorization, guids: Seq[UUID]): Seq[InternalApplication] = {
findAll(authorization, guids = Some(guids), limit = None)
}

def findAll(
authorization: Authorization,
orgKey: Option[String] = None,
Expand Down
Loading

0 comments on commit ceccf44

Please sign in to comment.