diff --git a/src/main/kotlin/no/fg/hilflingbackend/controller/AlbumController.kt b/src/main/kotlin/no/fg/hilflingbackend/controller/AlbumController.kt index 599713ff..d21730ef 100644 --- a/src/main/kotlin/no/fg/hilflingbackend/controller/AlbumController.kt +++ b/src/main/kotlin/no/fg/hilflingbackend/controller/AlbumController.kt @@ -9,6 +9,9 @@ import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import java.util.UUID @RestController @RequestMapping("/albums") @@ -23,4 +26,13 @@ class AlbumController(override val repository: AlbumRepository, val service: Alb dto ) } + + @GetMapping("/getUuidByTitle") + fun getAlbumIdByName( + @RequestParam( + "albumTitle", + ) albumTitle: String, + ): UUID? { + return repository.findUuidByMotive(albumTitle) + } } diff --git a/src/main/kotlin/no/fg/hilflingbackend/controller/MotiveController.kt b/src/main/kotlin/no/fg/hilflingbackend/controller/MotiveController.kt index 1e33bf24..a6c633ef 100644 --- a/src/main/kotlin/no/fg/hilflingbackend/controller/MotiveController.kt +++ b/src/main/kotlin/no/fg/hilflingbackend/controller/MotiveController.kt @@ -34,6 +34,15 @@ class MotiveController { return repository.findAll(page ?: 0, pageSize ?: 100) } + @GetMapping("/getUuidByTitle") + fun getAlbumIdByName( + @RequestParam( + "motiveTitle", + ) motiveTitle: String, + ): UUID? { + return repository.findUuidByMotive(motiveTitle) + } + @PostMapping fun create( @RequestBody dto: MotiveDto diff --git a/src/main/kotlin/no/fg/hilflingbackend/controller/PlaceController.kt b/src/main/kotlin/no/fg/hilflingbackend/controller/PlaceController.kt index b8adb80d..8c7d9a90 100644 --- a/src/main/kotlin/no/fg/hilflingbackend/controller/PlaceController.kt +++ b/src/main/kotlin/no/fg/hilflingbackend/controller/PlaceController.kt @@ -4,9 +4,21 @@ import no.fg.hilflingbackend.dto.PlaceDto import no.fg.hilflingbackend.dto.PlacePatchRequestDto import no.fg.hilflingbackend.model.Place import no.fg.hilflingbackend.repository.PlaceRepository +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import java.util.UUID @RestController @RequestMapping("/places") -open class PlaceController(override val repository: PlaceRepository) : BaseController(repository) +open class PlaceController(override val repository: PlaceRepository) : BaseController(repository) { + @GetMapping("/getUuidByTitle") + fun getUuidByPlace( + @RequestParam( + "placeTitle", + ) placeTitle: String, + ): UUID? { + return repository.findUuidByPlace(placeTitle) + } +} diff --git a/src/main/kotlin/no/fg/hilflingbackend/repository/AlbumRepository.kt b/src/main/kotlin/no/fg/hilflingbackend/repository/AlbumRepository.kt index 38056f2a..350d61d7 100644 --- a/src/main/kotlin/no/fg/hilflingbackend/repository/AlbumRepository.kt +++ b/src/main/kotlin/no/fg/hilflingbackend/repository/AlbumRepository.kt @@ -2,6 +2,8 @@ package no.fg.hilflingbackend.repository import me.liuwj.ktorm.database.Database import me.liuwj.ktorm.dsl.QueryRowSet +import me.liuwj.ktorm.dsl.eq +import me.liuwj.ktorm.entity.find import me.liuwj.ktorm.entity.add import me.liuwj.ktorm.entity.update import no.fg.hilflingbackend.dto.AlbumDto @@ -13,6 +15,7 @@ import no.fg.hilflingbackend.model.Albums import no.fg.hilflingbackend.model.albums import org.springframework.stereotype.Repository import javax.persistence.EntityNotFoundException +import java.util.UUID @Repository open class AlbumRepository(database: Database) : BaseRepository(table = Albums, database = database) { @@ -38,4 +41,15 @@ open class AlbumRepository(database: Database) : BaseRepository(table = Places, database = database) { @@ -47,4 +48,15 @@ open class PlaceRepository(database: Database) : BaseRepository