-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
616 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package db | ||
|
||
import db.generated.OriginalsDao | ||
import io.apibuilder.api.v0.models.{Original, OriginalType} | ||
|
||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
case class InternalOriginal(db: generated.Original) { | ||
val id: Long = db.id | ||
val versionGuid: UUID = db.versionGuid | ||
val `type`: OriginalType = OriginalType(db.`type`) | ||
val data: String = db.data | ||
} | ||
|
||
class InternalOriginalsDao @Inject()(dao: OriginalsDao) { | ||
|
||
def create( | ||
implicit c: java.sql.Connection, | ||
user: InternalUser, | ||
versionGuid: UUID, | ||
original: Original | ||
): Unit = { | ||
dao.insert(c, user.guid, generated.OriginalForm( | ||
versionGuid = versionGuid, | ||
`type` = original.`type`.toString, | ||
data = original.data, | ||
)) | ||
} | ||
|
||
def softDeleteByVersionGuid( | ||
implicit c: java.sql.Connection, | ||
user: InternalUser, | ||
versionGuid: UUID | ||
): Unit = { | ||
dao.deleteAllByVersionGuid(c, user.guid, versionGuid) | ||
} | ||
|
||
def findAllByVersionGuids(versionGuids: Seq[UUID]): Seq[InternalOriginal] = { | ||
dao.findAll( | ||
versionGuids = Some(versionGuids), | ||
limit = None, | ||
) { q => q.isNull("deleted_at") }.map(InternalOriginal(_)) | ||
} | ||
|
||
def findByVersionGuid(guid: UUID): Option[InternalOriginal] = { | ||
findAllByVersionGuids(Seq(guid)).headOption | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.